JetBrains / resharper-unity

Unity support for both ReSharper and Rider
Apache License 2.0
1.21k stars 134 forks source link

resharper command line tools with unity plugin is failing on macOS #1870

Closed girshfeld closed 4 years ago

girshfeld commented 4 years ago

Follow instructions from https://github.com/JetBrains/resharper-unity/issues/536

  1. Create simple project in Unity.
  2. Generate solution and project files with batch mode script with any method from: https://forum.unity.com/threads/any-way-to-tell-unity-to-generate-the-sln-file-via-script-or-command-line.392314/
  3. Run Command Tools

As a result tools will not see .net runtime and will show compile errors logs.txt

Opening project in unity and rider not in batch mode fixes the issue and inspections starts working

Versions:

van800 commented 4 years ago

What are you trying to do? I guess, it is automated run inspectcode in some build agent? For Unity 2019.2+, I have just added entry point to do this https://github.com/van800/com.unity.ide.rider/commit/f781bf2df0b03f8249f10e3c62cb499362dac335 It would become available with Rider package 2.0.8.

For older Unity versions it is a bit complicated. Rider EditorPlugin contains CsprojAssetPostprocessor and SlnAssetPostprocessor, which change generated csproj and sln files to ensure dotnetframework target pack is not required to be installed. Normally EditorPlugin should not be pushed to vcs. https://github.com/JetBrains/resharper-unity/blob/32e336d21a55688654670c142165f09aab7f0e0f/unity/EditorPlugin/AssetPostprocessors/CsprojAssetPostprocessor.cs#L15 https://github.com/JetBrains/resharper-unity/blob/32e336d21a55688654670c142165f09aab7f0e0f/unity/EditorPlugin/AssetPostprocessors/SlnAssetPostprocessor.cs#L13

If you want those post-processors to do work, you need

  1. to somehow copy EditorPlugin to Assets before generating solution
  2. avoid them exit by
      if (UnityUtils.IsInBatchModeAndNotInRiderTests)
        return contents;

    This code changed a bit in Rider 2020.3 and with 2020.3, you may just pass -riderIntegrationTests commandline param. For Rider 2020.2, you'd need to recompile your own version of EditorPlugin.

van800 commented 4 years ago

Let me know if that works for you.

girshfeld commented 4 years ago

We have to use mac for building game for ios. So we use mac mini build agents for all build (ios, android, testing) for unifications.

We stick with Unity 2018.4 for some time because it is LTS. I can copy rider plugin into project befor build, so there no need to commitit vcs. So I'll try to make it work.

girshfeld commented 4 years ago

I made it work with Rider Plugin EAP 2020.3 and flag -riderIntegrationTests. EditorPlugin is added to project on build agent by build script. I hope with Unity 2019.x I will can skip this step. Thank you!