通过统一启动时,Visual Studio Code .NET框架不起作用 [英] Visual Studio Code .NET framework not working when launched through unity

查看:49
本文介绍了通过统一启动时,Visual Studio Code .NET框架不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法让.net框架在vscode中运行.正常打开vscode时,我可以使.net框架正常运行.但是,当我统一打开.cs文件并使用vscode作为默认编辑器时,由于.net框架不再在vscode中工作,因此会收到错误消息.我需要针对C#的自动完成和语法错误的框架.我在另一篇已关闭的帖子上发表了评论,说我需要更详细地说明这个问题.如果不支持.net框架,这不是问题.我尝试过重新启动计算机,重新启动vscode,重新启动unity,重新导入unity软件包以及重新下载.net框架.无论是否使用unity快捷方式启动了vscode,所有c#代码都可以在unity内部和外部正常运行,但是运行dotnet命令和任何与c#相关的自动完成/语法均无效.我可以通过运行vscode而无需统一并导航到该文件来统一编辑c#代码.感谢您的帮助.

I am having trouble getting the .net framework to run inside vscode. I can get the .net framework running fine when I open vscode normally. 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. I need the framework for c# specific autocomplete and syntax errors. 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. I have tried restarting my pc, restarting vscode, restarting unity, reimporting unity packages, and redownloading the .net framework. 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. I can edit c# code from unity by running vscode without unity and navigating to the file. Thanks for your help.

dotnet命令在unity启动的vscode中运行

dotnet command run in vscode launched by unity

dotnet命令在通过快捷方式启动的vscode中运行

dotnet command run in vscode launched via shortcut

c#代码在内部统一运作

c# code working inside of unity

Omnisharp错误消息/日志:

Omnisharp error message/log:

在5/30/2020,9:41:51 PM启动OmniSharp服务器目标:a:\ Github \ Unity \ 2_Terminal_Hacker \ 2_Terminal_Hacker.sln

Starting OmniSharp server at 5/30/2020, 9:41:51 PM Target: a:\Github\Unity\2_Terminal_Hacker\2_Terminal_Hacker.sln

OmniSharp服务器已启动.路径:c:\ Users \ 0dps1.vscode \ extensions \ ms-dotnettools.csharp-1.22.0.omnisharp \ 1.35.2 \ OmniSharp.exePID:15076

OmniSharp server started. Path: c:\Users\0dps1.vscode\extensions\ms-dotnettools.csharp-1.22.0.omnisharp\1.35.2\OmniSharp.exe PID: 15076

[信息]:OmniSharp.Stdio.Host在Windows 6.2.9200.0(x64)上启动OmniSharp [信息]:OmniSharp.Services.DotNetCliServiceDotNetPath设置为dotnet [info]:OmniSharp.MSBuild.Discovery.MSBuildLocator找到了2个MSBuild实例1:Visual Studio Community 2019 16.6.30114.105-"A:\ Program Files \ Microsoft VisualStudio \ 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实例:Visual Studio社区2019 16.6.30114.105-"A:\ Program Files \ Microsoft Visual Studio \ 2019 \ Community \ MSBuild \ Current \ Bin" [信息]:OmniSharp.Cake.CakeProjectSystem在"a:\ Github \ Unity \ 2_Terminal_Hacker"中检测Cake文件.[信息]:OmniSharp.Cake.CakeProjectSystem找不到任何Cake文件[信息]:OmniSharp.MSBuild.ProjectSystem在"a:\ Github \ Unity \ 2_Terminal_Hacker \ 2_Terminal_Hacker.sln"中检测项目.[信息]:OmniSharp.MSBuild.ProjectManager排队项目更新"a:\ Github \ Unity \ 2_Terminal_Hacker \ Assembly-CSharp.csproj" [信息]:OmniSharp.Script.ScriptProjectSystem在'a:\ Github \ Unity \ 2_Terminal_Hacker'中检测CSX文件.[信息]:OmniSharp.Script.ScriptProjectSystem找不到任何CSX文件[信息]:OmniSharp.WorkspaceInitializer调用工作区选项提供程序:OmniSharp.Roslyn.CSharp.Services.CSharpFormattingWorkspaceOptionsProvider,顺序:0 [信息]:OmniSharp.MSBuild.ProjectManager加载项目:a:\ Github \ Unity \ 2_Terminal_Hacker \ Assembly-CSharp.csproj [info]:OmniSharp.WorkspaceInitializer调用工作区选项提供程序:OmniSharp.Roslyn.CSharp.Services.RenameWorkspaceOptionsProvider,订单:100 [info]:OmniSharp.WorkspaceInitializer调用工作区选项提供程序:OmniSharp.Roslyn.CSharp.Services.ImplementTypeWorkspaceOptionsProvider,订单:110 [info]:OmniSharp.WorkspaceInitializer调用工作区选项提供程序:OmniSharp.Roslyn.CSharp.Services.BlockStructureWorkspaceOptionsProvider,订单:140 [info]:OmniSharp.WorkspaceInitializer配置完成.[信息]:OmniSharp.Stdio.Host在主机13388上的位置'a:\ Github \ Unity \ 2_Terminal_Hacker'上使用Stdio运行的Omnisharp服务器.[失败]:OmniSharp.MSBuild.ProjectLoader找不到.NETFramework,Version = v4.7.1的参考程序集.要解决此问题,请安装Developer Pack(SDK/定位Pack)以适合此框架版本,或重新定位您的应用程序.你可以在以下位置下载.NET Framework开发人员包 https://aka.ms/msbuild/developerpacks [警告]:OmniSharp.MSBuild.ProjectManager无法加载项目文件'a:\ Github \ Unity \ 2_Terminal_Hacker \ Assembly-CSharp.csproj'.A:\ Github \ Unity \ 2_Terminal_Hacker \ Assembly-CSharp.csproj A:\ Program文件\ Microsoft VisualStudio \ 2019 \ Community \ MSBuild \ Current \ Bin \ Microsoft.Common.CurrentVersion.targets(1177,5):错误:.NETFramework,Version = v4.7.1的引用程序集是未找到.要解决此问题,请安装Developer Pack(SDK/定位Pack)以适合此框架版本,或重新定位您的应用程序.你可以在以下位置下载.NET Framework开发人员包 https://aka.ms/msbuild/developerpacks

[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.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'. [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'. [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. [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. 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 [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. 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

[失败]:OmniSharp.MSBuild.ProjectManager尝试更新未加载的项目:a:\ Github \ Unity \ 2_Terminal_Hacker \ Assembly-CSharp.csproj

[fail]: OmniSharp.MSBuild.ProjectManager Attempted to update project that is not loaded: a:\Github\Unity\2_Terminal_Hacker\Assembly-CSharp.csproj

推荐答案

答案在日志中:

[失败]:OmniSharp.MSBuild.ProjectLoader用于的参考程序集找不到.NETFramework,Version = v4.7.1.要解决此问题,请安装此框架版本的开发者包(SDK/目标包),或重新定位您的应用程序.您可以下载.NET Framework Developer打包在 https://aka.ms/msbuild/developerpacks [警告]:OmniSharp.MSBuild.ProjectManager加载项目文件失败'a:\ Github \ Unity \ 2_Terminal_Hacker \ Assembly-CSharp.csproj'.A:\ Github \ Unity \ 2_Terminal_Hacker \ Assembly-CSharp.csproj A:\ Program文件\ Microsoft VisualStudio \ 2019 \ Community \ MSBuild \ Current \ Bin \ Microsoft.Common.CurrentVersion.targets(1177,5):错误:.NETFramework,Version = v4.7.1的引用程序集是未找到.要解决此问题,请安装Developer Pack(SDK/定位Pack)以适合此框架版本,或重新定位您的应用程序.你可以在以下位置下载.NET Framework开发人员包 https://aka.ms/msbuild/developerpacks

[fail]: OmniSharp.MSBuild.ProjectLoader The reference assemblies for .NETFramework,Version=v4.7.1 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 [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. 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

.net sdk/system库是通过Visual Studio安装的,因此vscode/omnisharp试图将其从Visual Studio Community 16.6安装中拉出(有关信息位于日志开头).但是看起来VSCommunity是在未安装v4.7.1定位包的情况下安装的.

.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). But it looks like VSCommunity is installed without v4.7.1 targetting pack.

要解决此问题,请转到:

To fix this, go to:

Visual Studio安装程序-> Visual Studio社区->更多->修改->单个组件

Visual Studio Installer -> Visual Studio Community -> More -> Modify -> Individual Components

并检查".NETFramework v4.7.1"包.重新安装后,重新启动东西,您应该会很好.

and check ".NETFramework v4.7.1" pack. Afrer this gets installed, reboot stuff and you should be good to go.

这篇关于通过统一启动时,Visual Studio Code .NET框架不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆