JetBrains / resharper-unity

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

Rider does not install plugin into Unity Project, no `sln` file generated. #598

Closed tompave closed 6 years ago

tompave commented 6 years ago

Hello,

I'm trying to use Rider 2018.1.2 with Unity 2018.1.4f1 on macOS 10.13.5, and it looks like Rider is not properly installing the Unity plugin into the Unity project.

This is a clean installation of both applications on this machine. I've already used Unity with MonoDevelop on macOS on another machine, and I already use several IntelliJ-derived IDEs on this machine where I'm experiencing the issue.

I've installed Unity without Visual Studio for Mac, because I figured that I wouldn't need it since I'm going to use Rider instead. A possibly related side effect is that creating a new project in Unity (or opening a stock project, e.g. the standard assets project that comes bundled with the installation), will not create a .sln file. I'm not sure if this is normal.

Without the .sln file I can't have Rider open the Unity project as recommended in the docs (one, two), so I resorted to open the entire Unity project directory using:

Rider Splash Screen > Open Solution or Project

With that, Rider opens and indexes the project and it generates a new .sln file, but it doesn't look like the integration is set up:

  1. there is no Unity icon in the lower-right corner in the Rider status bar;
  2. there are no special Unity buttons in the toolbar;
  3. the other editor integrations don't seem to be there;
  4. Rider is not auto-configured as the external editor;
  5. There is nothing in the Assets/Plugins/ directory of the project.

Interestingly, the Unity Explorer project view is available:

screen shot 2018-06-18 at 17 21 41

Any idea of what's happening? If it's just a matter of installing Unity with Visual Studio for Mac, possibly it would be better to say so in the docs.


Possibly related to this: https://github.com/JetBrains/resharper-unity/issues/387

van800 commented 6 years ago

Hi! I am aware of the inconvenience. AFAIK it was solved on the Unity side https://issuetracker.unity3d.com/issues/notepad-selected-as-an-external-script-editoris-not-generating-the-csproj-and-sln-files But unfortunately it will work only for future releases.

From the other hand Rider tries to install the EditorPlugin only when present reference to UnityEngine.dll and the Assets folder. So opening folder will not work, there are no references at all.

Workaround is to select Rider as an External Editor manually in Unity. Selecting any "know editor", like Rider, devenv, vscode switches Unity to sln-generation mode.

tompave commented 6 years ago

Hi, thanks for the reply.

Rider tries to install the EditorPlugin only when present reference to UnityEngine.dll and the Assets folder. So opening folder will not work, there are no references at all.

I am not sure what you mean, sorry. Do you mean references in the sln file?

tompave commented 6 years ago

Workaround is to select Rider as an External Editor manually in Unity. Selecting any "know editor", like Rider, devenv, vscode switches Unity to sln-generation mode.

I've done it, and this is what gets preselected by Unity:

screen shot 2018-06-19 at 20 06 10

Now, if I select Assets > Open C# Project in the menu, it opens the project in Rider. When it launches, Rider seems to be creating these files:

Assembly-CSharp-Editor-firstpass.csproj
Assembly-CSharp-firstpass.csproj
Assembly-CSharp.csproj
Standard Assets Example Project.sln

However, the plugin is still not installed in the Unity project, and Rider still seems to not enable all the extra Unity features. You can check the list in my opening post, as none of this has changed:

  • there is no Unity icon in the lower-right corner in the Rider status bar;
  • there are no special Unity buttons in the toolbar;
  • the other editor integrations don't seem to be there;
  • There is nothing in the Assets/Plugins/ directory of the project.
tompave commented 6 years ago

I've found this article and tried to install the plugin manually:

mkdir -p $PATH_TO_MY_PROJECT/Plugins/Editor/JetBrains

cp \
/Applications/Rider\ 2018.1.2.app/Contents/plugins/rider-unity/EditorPlugin/JetBrains.Rider.Unity.Editor.Plugin.Repacked.dll \
$PATH_TO_MY_PROJECT/Assets/Plugins/Editor/JetBrains/JetBrains.Rider.Unity.Editor.Plugin.Repacked.dll'

Reloading Unity seems to have had some effect, because now I can see the plugin in the project tree and inspect it:

screen shot 2018-06-19 at 20 21 24

I can access the plugin settings:

screen shot 2018-06-19 at 20 39 05

And there are a few more menu items to open the project:

screen shot 2018-06-19 at 20 19 03

Still no luck with Rider though. All the Unity-integration features are still not available.

tompave commented 6 years ago

Restarting the applications and reopening the project in Rider through the menu resulted in a new UI item to appear, but nothing else yet:

screen shot 2018-06-19 at 20 46 05
tompave commented 6 years ago

I've re-downloaded the Unity installer and installed Visual Studio for Mac. Now everything works as intended.

Things that changed:

If any of these is a hard requirement to get the Rider-Unity integration to work, I recommend to state so clearly in the readme and the documentation.

van800 commented 6 years ago

Thank you for sharing all the info, I will reproduce it and fix. Update: It seems that it doesn't reproduce for me easily. Could please anyone, who is having this, attach all Rider logs, which can be found by Help->"Show log in Finder" command in Rider?

tompave commented 6 years ago

I can send you the log file. It's a bit long and messy because it contains everything, before and after the problem was resolved. Can I send it to your github email address?

Also, can you already make an educated guess about the cause? The reason is that I'd rather not keep Visual Studio for Mac and the Mono framework installed, if I can avoid it. At the moment it's not clear to me if /Library/Frameworks/Mono.framework is required to run Visual Studio, or if it's needed to get Unity C# scripting to work.

van800 commented 6 years ago

You would need mono. At least for newest Unity versions with Incremental Compiler, you would need it. For older versions, which bundle MonoDevelop, you can use mono+xbuild, which comes with Unity. But if we fail to find it, it might be unnecessary complicated to be found manually.

tompave commented 6 years ago

I see, thank you for the explanation.

I'd say that then there is an issue with the macOS Unity installer, because it marks Visual Studio for Mac as an optional install and allows you to disable it, but without installing VS the Mono runtime won't be installed. Well, I suppose that for very simple Unity projects, where no C# scripting is required, Unity could still work without it.

Still, I'd recommend to add a big warning to the docs: in order to use Rider with Unity on macOS, you will need to have Visual Studio for Mac and Mono installed.

van800 commented 6 years ago

To be more precise, latest Mono is desirable and VS for Mac is not needed at all. I will push the updates in documentation. But I am still curious to see the logs, when plugin is not installed. Even when I remove Mono, it doesn't reproduce for me, I will try again later and I will ask QA to try it for me, but if you can reproduce it easily, please zip and post the logs here.

xahon commented 6 years ago

The same issue for me. I'm using archlinux, rider 2018.1.3 RD 181.4952.311, Unity 2018.2.0f2 I tried to install monodevelop and generate solutions from it and it generated them but if I add new c# script rider code features disapears for that script Rider doesn't generate sln files itself

van800 commented 6 years ago

@xahon Can I assist you? Yeah Rider can't generate sln. That is true. The expected workflow is the following: a) If you know path to "rider.sh", just put it in Unity Setting - External Editor Be sure to use exactly rider.sh, not just some symlink named "rider". b) else if you already have some sln file generated by Unity - just open it in Rider. Rider will add its UnityEditorPlugin and next time you focus Unity you will get path to Rider added to list of Known External Editors in Unity settings.

van800 commented 6 years ago

And vote this Unity issue please: https://issuetracker.unity3d.com/issues/notepad-selected-as-an-external-script-editoris-not-generating-the-csproj-and-sln-files

xahon commented 6 years ago

@van800 That looks like the voting is disabled. I don't know if I set path to rider on symlink or to shell script but using generated sln file doesn't work as expected. Yes, it installs unity plugin and coding features work until you add a new c# script in unity. If add new script you can see that coding features will not work for this file (previous will work fine). I think the reason is that rider doesn't create solution files itself but using generated by another program. You said "sln file generated by Unity" but as I understand right Unity can't create these files for you. You should use instead some IDEs like rider, vs (not code), monodevelop, etc. may be I think wrong

P.S. I'm currently working on Windows with the latest unity and rider and they work fine. I will check shortly if I set path to symlink and give you know

P.P.S. I've noticed that on Windows unity make one more operation with copying .dll file (Something like ***.Generated.dll). May be I'm really set wrong path to editor in linux

xahon commented 6 years ago

@van800 Thanks, you was right. I should set path to .sh file instead of /usr/bin/rider or .desktop file. In my case path was /usr/share/rider/bin/rider.sh (Installed from AUR)

van800 commented 6 years ago

It is a Unity bug which I mentioned https://issuetracker.unity3d.com/issues/notepad-selected-as-an-external-script-editoris-not-generating-the-csproj-and-sln-files 2018.3 already has the fix and maybe they will backport it to all new 2018.x.x.

van800 commented 6 years ago

Having mono as a prerequisite for Rider is listed in the help and for Unity it will be specifically addressed in https://youtrack.jetbrains.com/issue/RIDER-18214