[英]Visual Studio Code .NET framework not working when launched through unity
I am having trouble getting the .net framework to run inside vscode.我无法让 .net 框架在 vscode 中运行。 I can get the .net framework running fine when I open vscode normally.
当我正常打开vscode时,我可以让.net框架运行良好。 However, when I open a.cs file in unity and use vscode as my default editor, I get error messages because the .net framework no longer works inside vscode.
但是,当我统一打开 a.cs 文件并使用 vscode 作为我的默认编辑器时,我收到错误消息,因为 .net 框架不再在 vscode 中工作。 I need the framework for c# specific autocomplete and syntax errors.
我需要 c# 特定自动完成和语法错误的框架。 I have gotten comments on another post that has been closed saying I need to be more specific about this issue.
我收到了另一篇已关闭的帖子的评论,说我需要更具体地说明这个问题。 This is not an issue with unity not supporting the .net framework.
这不是统一不支持 .net 框架的问题。 I have tried restarting my pc, restarting vscode, restarting unity, reimporting unity packages, and redownloading the .net framework.
我试过重启我的电脑,重启vscode,重启unity,重新导入unity包,重新下载.net框架。 All c# code runs fine inside and outside of unity regardless of whether vscode was launched using the unity shortcut, but running the dotnet command and any c# related autocomplete/syntax do not work.
无论是否使用统一快捷方式启动 vscode,所有 c# 代码在统一内部和外部都运行良好,但运行 dotnet 命令和任何 c# 相关的自动完成/语法都不起作用。 I can edit c# code from unity by running vscode without unity and navigating to the file.
我可以通过在没有统一的情况下运行 vscode 并导航到文件来从统一编辑 c# 代码。 Thanks for your help.
谢谢你的帮助。
dotnet command run in vscode launched by unity dotnet 命令在统一启动的 vscode 中运行
dotnet command run in vscode launched via shortcut dotnet 命令在通过快捷方式启动的 vscode 中运行
c# code working inside of unity c# 代码在统一内部工作
Omnisharp error message/log: Omnisharp 错误消息/日志:
Starting OmniSharp server at 5/30/2020, 9:41:51 PM Target: a:\Github\Unity\2_Terminal_Hacker\2_Terminal_Hacker.sln
在 2020 年 5 月 30 日晚上 9:41:51 启动 OmniSharp 服务器目标:a:\Github\Unity\2_Terminal_Hacker\2_Terminal_Hacker.sln
OmniSharp server started.
OmniSharp 服务器已启动。 Path: c:\Users\0dps1.vscode\extensions\ms-dotnettools.csharp-1.22.0.omnisharp\1.35.2\OmniSharp.exe PID: 15076
路径:c:\Users\0dps1.vscode\extensions\ms-dotnettools.csharp-1.22.0.omnisharp\1.35.2\OmniSharp.exe PID:15076
[info]: OmniSharp.Stdio.Host Starting OmniSharp on Windows 6.2.9200.0 (x64) [info]: OmniSharp.Services.DotNetCliService DotNetPath set to dotnet [info]: OmniSharp.MSBuild.Discovery.MSBuildLocator Located 2 MSBuild instance(s) 1: Visual Studio Community 2019 16.6.30114.105 - "A:\Program Files\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin" 2: StandAlone 16.4 - "c:\Users\0dps1.vscode\extensions\ms-dotnettools.csharp-1.22.0.omnisharp\1.35.2.msbuild\Current\Bin" [info]: OmniSharp.MSBuild.Discovery.MSBuildLocator Registered MSBuild instance: Visual Studio Community 2019 16.6.30114.105 - "A:\Program Files\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin" [info]: OmniSharp.Cake.CakeProjectSystem Detecting Cake files in 'a:\Github\Unity\2_Terminal_Hacker'.
[info]: OmniSharp.Stdio.Host Starting OmniSharp on Windows 6.2.9200.0 (x64) [info]: OmniSharp.Services.DotNetCliService DotNetPath set to dotnet [info]: OmniSharp.MSBuild.Discovery.MSBuildLocator Located 2 MSBuild instance(s) 1:Visual Studio 社区 2019 16.6.30114.105 -“A:\Program Files\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin”2:StandAlone 16.4 -“c:\Users\0dps1.vscode\extensions\ms- dotnettools.csharp-1.22.0.omnisharp\1.35.2.msbuild\Current\Bin" [信息]: OmniSharp.MSBuild.Discovery.MSBuildLocator 已注册 MSBuild 实例 "A:\Program Files 2019 16.6.3" Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin" [信息]:OmniSharp.Cake.CakeProjectSystem 检测 'a:\Github\Unity\2_Terminal_Hacker' 中的 Cake 文件。 [info]: OmniSharp.Cake.CakeProjectSystem Could not find any Cake files [info]: OmniSharp.MSBuild.ProjectSystem Detecting projects in 'a:\Github\Unity\2_Terminal_Hacker\2_Terminal_Hacker.sln'.
[信息]:OmniSharp.Cake.CakeProjectSystem 找不到任何蛋糕文件 [信息]:OmniSharp.MSBuild.ProjectSystem 检测“a:\Github\Unity\2_Terminal_Hacker\2_Terminal_Hacker.sln”中的项目。 [info]: OmniSharp.MSBuild.ProjectManager Queue project update for 'a:\Github\Unity\2_Terminal_Hacker\Assembly-CSharp.csproj' [info]: OmniSharp.Script.ScriptProjectSystem Detecting CSX files in 'a:\Github\Unity\2_Terminal_Hacker'.
[信息]:OmniSharp.MSBuild.ProjectManager 'a:\Github\Unity\2_Terminal_Hacker\Assembly-CSharp.csproj' 的队列项目更新 [信息]:OmniSharp.Script.ScriptProjectSystem 检测 'a:\Github\Unity\ 中的 CSX 文件2_Terminal_Hacker'。 [info]: OmniSharp.Script.ScriptProjectSystem Could not find any CSX files [info]: OmniSharp.WorkspaceInitializer Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.CSharpFormattingWorkspaceOptionsProvider, Order: 0 [info]: OmniSharp.MSBuild.ProjectManager Loading project: a:\Github\Unity\2_Terminal_Hacker\Assembly-CSharp.csproj [info]: OmniSharp.WorkspaceInitializer Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.RenameWorkspaceOptionsProvider, Order: 100 [info]: OmniSharp.WorkspaceInitializer Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.ImplementTypeWorkspaceOptionsProvider, Order: 110 [info]: OmniSharp.WorkspaceInitializer Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.BlockStructureWorkspaceOptionsProvider, Order: 140 [info]: OmniSharp.WorkspaceInitializer Configuration finished.
[信息]:OmniSharp.Script.ScriptProjectSystem 找不到任何 CSX 文件 [信息]:OmniSharp.WorkspaceInitializer 调用工作区选项提供程序:OmniSharp.Roslyn.CSharp.Services.CSharpFormattingWorkspaceOptionsProvider,订单:0 [信息]:OmniSharp.MSBuild.ProjectManager 正在加载项目:a:\Github\Unity\2_Terminal_Hacker\Assembly-CSharp.csproj [信息]:OmniSharp.WorkspaceInitializer 调用工作区选项提供程序:OmniSharp.Roslyn.CSharp.Services.RenameWorkspaceOptionsProvider,订单:100 [信息]:OmniSharp.WorkspaceInitializer 调用工作区选项提供程序:OmniSharp.Roslyn.CSharp.Services.ImplementTypeWorkspaceOptionsProvider,订单:110 [信息]:OmniSharp.WorkspaceInitializer 调用工作区选项提供程序:OmniSharp.Roslyn.CSharp.Services.BlockStructureWorkspaceOptionsProvider,订单:140 [信息]:OmniSharp.WorkspaceInitializer 配置完成. [info]: OmniSharp.Stdio.Host Omnisharp server running using Stdio at location 'a:\Github\Unity\2_Terminal_Hacker' on host 13388. [fail]: OmniSharp.MSBuild.ProjectLoader The reference assemblies for .NETFramework,Version=v4.7.1 were not found.
[信息]:OmniSharp.Stdio.Host Omnisharp 服务器使用 Stdio 在主机 13388 上的位置“a:\Github\Unity\2_Terminal_Hacker”运行。[失败]:OmniSharp.MSBuild.ProjectLoader .NETFramework 的参考程序集,版本 = v4。 7.1 没有找到。 To resolve this, install the Developer Pack (SDK/Targeting Pack) for this framework version or retarget your application.
要解决此问题,请为此框架版本安装开发包(SDK/Targeting Pack)或重新定位您的应用程序。 You can download .NET Framework Developer Packs at https://aka.ms/msbuild/developerpacks [warn]: OmniSharp.MSBuild.ProjectManager Failed to load project file 'a:\Github\Unity\2_Terminal_Hacker\Assembly-CSharp.csproj'.
You can download .NET Framework Developer Packs at https://aka.ms/msbuild/developerpacks [warn]: OmniSharp.MSBuild.ProjectManager Failed to load project file 'a:\Github\Unity\2_Terminal_Hacker\Assembly-CSharp.csproj'. a:\Github\Unity\2_Terminal_Hacker\Assembly-CSharp.csproj A:\Program Files\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(1177,5): Error: The reference assemblies for .NETFramework,Version=v4.7.1 were not found.
a:\Github\Unity\2_Terminal_Hacker\Assembly-CSharp.csproj A:\Program Files\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(1177,5):错误:The .NETFramework,Version=v4.7.1 的参考程序集未找到。 To resolve this, install the Developer Pack (SDK/Targeting Pack) for this framework version or retarget your application.
要解决此问题,请为此框架版本安装开发包(SDK/Targeting Pack)或重新定位您的应用程序。 You can download .NET Framework Developer Packs at https://aka.ms/msbuild/developerpacks
您可以在https://aka.ms/msbuild/developerpacks下载 .NET 框架开发人员包
[fail]: OmniSharp.MSBuild.ProjectManager Attempted to update project that is not loaded: a:\Github\Unity\2_Terminal_Hacker\Assembly-CSharp.csproj
[失败]:OmniSharp.MSBuild.ProjectManager 尝试更新未加载的项目:a:\Github\Unity\2_Terminal_Hacker\Assembly-CSharp.csproj
The answer is in the log:答案在日志中:
[fail]: OmniSharp.MSBuild.ProjectLoader The reference assemblies for .NETFramework,Version=v4.7.1 were not found.
[失败]:OmniSharp.MSBuild.ProjectLoader .NETFramework,Version=v4.7.1 的参考程序集未找到。 To resolve this, install the Developer Pack (SDK/Targeting Pack) for this framework version or retarget your application.
要解决此问题,请为此框架版本安装开发包(SDK/Targeting Pack)或重新定位您的应用程序。 You can download .NET Framework Developer Packs at https://aka.ms/msbuild/developerpacks [warn]: OmniSharp.MSBuild.ProjectManager Failed to load project file 'a:\Github\Unity\2_Terminal_Hacker\Assembly-CSharp.csproj'.
You can download .NET Framework Developer Packs at https://aka.ms/msbuild/developerpacks [warn]: OmniSharp.MSBuild.ProjectManager Failed to load project file 'a:\Github\Unity\2_Terminal_Hacker\Assembly-CSharp.csproj'. a:\Github\Unity\2_Terminal_Hacker\Assembly-CSharp.csproj A:\Program Files\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(1177,5): Error: The reference assemblies for .NETFramework,Version=v4.7.1 were not found.
a:\Github\Unity\2_Terminal_Hacker\Assembly-CSharp.csproj A:\Program Files\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(1177,5):错误:The .NETFramework,Version=v4.7.1 的参考程序集未找到。 To resolve this, install the Developer Pack (SDK/Targeting Pack) for this framework version or retarget your application.
要解决此问题,请为此框架版本安装开发包(SDK/Targeting Pack)或重新定位您的应用程序。 You can download .NET Framework Developer Packs at https://aka.ms/msbuild/developerpacks
您可以在https://aka.ms/msbuild/developerpacks下载 .NET 框架开发人员包
.Net sdk/system libraries are installed through Visual Studio, so vscode/omnisharp tried to pull them from your Visual Studio Community 16.6 installation (info for that is on the start of the log). .Net sdk/system 库是通过 Visual Studio 安装的,因此 vscode/omnisharp 尝试从您的 Visual Studio Community 16.6 安装中提取它们(相关信息在日志的开头)。 But it looks like VSCommunity is installed without v4.7.1 targetting pack.
但看起来 VSCommunity 是在没有 v4.7.1 目标包的情况下安装的。
To fix this, go to:为了解决这个问题,go 到:
Visual Studio Installer -> Visual Studio Community -> More -> Modify -> Individual Components
Visual Studio 安装程序 -> Visual Studio 社区 -> 更多 -> 修改 -> 单个组件
and check ".NETFramework v4.7.1" pack.并检查“.NETFramework v4.7.1”包。 Afrer this gets installed, reboot stuff and you should be good to go.
安装后,重新启动东西,你应该对 go 很好。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.