介绍

最近,Rider 调试 Unity 突然失效了,表现为没有 Attach to Unity 按钮,调试按钮无法点击。

Errors 面板中有如下提示:

1
2
3
4
Project 'Assembly-CSharp-firstpass' load finished with warnings: The reference assemblies for .NETFramework,Version=v3.5 were not found. To resolve this, install the Developer Pack (SDK/Targeting Pack) for this framework version or retarget your application. You can download .NET Framework Developer Packs at https://aka.ms/msbuild/developerpacks at (1175:5)
Project 'Assembly-CSharp' load finished with warnings: The reference assemblies for .NETFramework,Version=v3.5 were not found. To resolve this, install the Developer Pack (SDK/Targeting Pack) for this framework version or retarget your application. You can download .NET Framework Developer Packs at https://aka.ms/msbuild/developerpacks at (1175:5)
Project 'Assembly-CSharp-Editor-firstpass' load finished with warnings: The reference assemblies for .NETFramework,Version=v3.5 were not found. To resolve this, install the Developer Pack (SDK/Targeting Pack) for this framework version or retarget your application. You can download .NET Framework Developer Packs at https://aka.ms/msbuild/developerpacks at (1175:5)
Project 'Assembly-CSharp-Editor' load finished with warnings: The reference assemblies for .NETFramework,Version=v3.5 were not found. To resolve this, install the Developer Pack (SDK/Targeting Pack) for this framework version or retarget your application. You can download .NET Framework Developer Packs at https://aka.ms/msbuild/developerpacks at (1175:5)

环境

  • Rider 2019.1.1
  • Unity 5.6.6f2
  • macOS 10.14.6

查找

尝试重启 Unity、Rider、换用不同版本 Rider、同步 Unity Rider 插件等等操作,发现依然无效。

搜索后发现有可能是因为 MSBuild 发生变化,Rider | Preferences | Build, Execution, Deployment | Toolset and Build 打开设置后发现问题果然出在这儿:最近安装了 dotnet core 3.1,这里的路径也变成 dotnet core 中的了。

尝试自定义 Mono executable path 发现可以同步修改 MSBuild,改完后依然无效,最终确定需要耐心等待 Rider 使用新配置的 MSBuild 扫描完工程才能使用。

最后记得要切换回 Unity 确保 Unity Rider 插件正常工作,Rider 右下角中 Unity 标志提示已连接。

注意:这里的选项最好根据当前项目使用的 Unity 版本修改,不同的 Unity 版本使用不同的 MSBuild。例如,Unity 5.6.6f2 与 Unity 2018.4.12f1 的版本就不同。