OmniSharp 回归 System.IO.FileNotFoundException
OmniSharp returning System.IO.FileNotFoundException
我正在尝试使用 Unity 自动完成,但我不断收到此消息:
Starting OmniSharp server at 12/28/2021, 4:12:57 AM
Target: d:\UnityHub\Igor\Igor.sln
OmniSharp server started.
Path: c:\Users\james\.vscode\extensions\ms-dotnettools.csharp-1.23.17\.omnisharp.37.17\OmniSharp.exe
PID: 21752
[info]: OmniSharp.Stdio.Host
Starting OmniSharp on Windows 6.2.9200.0 (x64)
[info]: OmniSharp.Services.DotNetCliService
Checking the 'DOTNET_ROOT' environment variable to find a .NET SDK
[info]: OmniSharp.Services.DotNetCliService
Using the 'dotnet' on the PATH.
[info]: OmniSharp.Services.DotNetCliService
DotNetPath set to dotnet
System.IO.FileNotFoundException: C:\Program Files (x86)\Microsoft Visual Studio17\Community\MSBuild.0\Bin\Microsoft.Build.dll
at System.Diagnostics.FileVersionInfo.GetVersionInfo(String fileName)
at OmniSharp.MSBuild.Discovery.MSBuildInstanceProvider.GetMSBuildVersion(String microsoftBuildPath) in D:\a\s\src\OmniSharp.Host\MSBuild\Discovery\MSBuildInstanceProvider.cs:line 104
at OmniSharp.MSBuild.Discovery.Providers.MicrosoftBuildLocatorInstanceProvider.<>c.<GetInstances>b__1_0(VisualStudioInstance instance) in D:\a\s\src\OmniSharp.Host\MSBuild\Discovery\Providers\MicrosoftBuildLocatorInstanceProvider.cs:line 30
at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
at System.Collections.Immutable.ImmutableArray.CreateRange[T](IEnumerable`1 items)
at OmniSharp.MSBuild.Discovery.MSBuildLocator.GetInstances() in D:\a\s\src\OmniSharp.Host\MSBuild\Discovery\MSBuildLocator.cs:line 115
at OmniSharp.MSBuild.Discovery.Extensions.GetBestInstance(IMSBuildLocator msbuildLocator, Version minimumMSBuildVersion, ILogger logger, Boolean& invalidVSFound, Boolean& vsWithoutSdkResolver) in D:\a\s\src\OmniSharp.Host\MSBuild\Discovery\Extensions.cs:line 109
at OmniSharp.MSBuild.Discovery.Extensions.RegisterDefaultInstance(IMSBuildLocator msbuildLocator, ILogger logger, DotNetInfo dotNetInfo) in D:\a\s\src\OmniSharp.Host\MSBuild\Discovery\Extensions.cs:line 17
at OmniSharp.CompositionHostBuilder.Build(String workingDirectory) in D:\a\s\src\OmniSharp.Host\CompositionHostBuilder.cs:line 71
at OmniSharp.Stdio.Host..ctor(TextReader input, ISharedTextWriter writer, IOmniSharpEnvironment environment, IServiceProvider serviceProvider, CompositionHostBuilder compositionHostBuilder, ILoggerFactory loggerFactory, CancellationTokenSource cancellationTokenSource) in D:\a\s\src\OmniSharp.Stdio\Host.cs:line 49
at OmniSharp.Stdio.Driver.Program.<>c__DisplayClass0_1.<Main>b__1() in D:\a\s\src\OmniSharp.Stdio.Driver\Program.cs:line 74
at McMaster.Extensions.CommandLineUtils.CommandLineApplication.<>c__DisplayClass146_0.<OnExecute>b__0(CancellationToken _)
at McMaster.Extensions.CommandLineUtils.CommandLineApplication.<ExecuteAsync>d__157.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at McMaster.Extensions.CommandLineUtils.CommandLineApplication.Execute(String[] args)
at OmniSharp.HostHelpers.Start(Func`1 action) in D:\a\s\src\OmniSharp.Host\HostHelpers.cs:line 29
我不太确定发生了什么,但我也安装了 Visual Studio,但作为解决方案也失败了。
我遇到了同样的问题,我从这个 reddit post 得到了这个:
https://www.reddit.com/r/vscode/comments/ooyijp/issue_with_omnisharpc_extension/
“您需要告诉 VS Code 仅使用 omnisharp 附带的捆绑 MSBuild 版本。
每 https://github.com/OmniSharp/omnisharp-vscode/issues/4358
您可以使用以下内容将 omnisharp.json 添加到工作空间的根目录中
{ "msbuild": { "useBundledOnly": true } }
对于全局效果,文件可以放入 %USERPROFILE%/.omnisharp/
我正在尝试使用 Unity 自动完成,但我不断收到此消息:
Starting OmniSharp server at 12/28/2021, 4:12:57 AM
Target: d:\UnityHub\Igor\Igor.sln
OmniSharp server started.
Path: c:\Users\james\.vscode\extensions\ms-dotnettools.csharp-1.23.17\.omnisharp.37.17\OmniSharp.exe
PID: 21752
[info]: OmniSharp.Stdio.Host
Starting OmniSharp on Windows 6.2.9200.0 (x64)
[info]: OmniSharp.Services.DotNetCliService
Checking the 'DOTNET_ROOT' environment variable to find a .NET SDK
[info]: OmniSharp.Services.DotNetCliService
Using the 'dotnet' on the PATH.
[info]: OmniSharp.Services.DotNetCliService
DotNetPath set to dotnet
System.IO.FileNotFoundException: C:\Program Files (x86)\Microsoft Visual Studio17\Community\MSBuild.0\Bin\Microsoft.Build.dll
at System.Diagnostics.FileVersionInfo.GetVersionInfo(String fileName)
at OmniSharp.MSBuild.Discovery.MSBuildInstanceProvider.GetMSBuildVersion(String microsoftBuildPath) in D:\a\s\src\OmniSharp.Host\MSBuild\Discovery\MSBuildInstanceProvider.cs:line 104
at OmniSharp.MSBuild.Discovery.Providers.MicrosoftBuildLocatorInstanceProvider.<>c.<GetInstances>b__1_0(VisualStudioInstance instance) in D:\a\s\src\OmniSharp.Host\MSBuild\Discovery\Providers\MicrosoftBuildLocatorInstanceProvider.cs:line 30
at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
at System.Collections.Immutable.ImmutableArray.CreateRange[T](IEnumerable`1 items)
at OmniSharp.MSBuild.Discovery.MSBuildLocator.GetInstances() in D:\a\s\src\OmniSharp.Host\MSBuild\Discovery\MSBuildLocator.cs:line 115
at OmniSharp.MSBuild.Discovery.Extensions.GetBestInstance(IMSBuildLocator msbuildLocator, Version minimumMSBuildVersion, ILogger logger, Boolean& invalidVSFound, Boolean& vsWithoutSdkResolver) in D:\a\s\src\OmniSharp.Host\MSBuild\Discovery\Extensions.cs:line 109
at OmniSharp.MSBuild.Discovery.Extensions.RegisterDefaultInstance(IMSBuildLocator msbuildLocator, ILogger logger, DotNetInfo dotNetInfo) in D:\a\s\src\OmniSharp.Host\MSBuild\Discovery\Extensions.cs:line 17
at OmniSharp.CompositionHostBuilder.Build(String workingDirectory) in D:\a\s\src\OmniSharp.Host\CompositionHostBuilder.cs:line 71
at OmniSharp.Stdio.Host..ctor(TextReader input, ISharedTextWriter writer, IOmniSharpEnvironment environment, IServiceProvider serviceProvider, CompositionHostBuilder compositionHostBuilder, ILoggerFactory loggerFactory, CancellationTokenSource cancellationTokenSource) in D:\a\s\src\OmniSharp.Stdio\Host.cs:line 49
at OmniSharp.Stdio.Driver.Program.<>c__DisplayClass0_1.<Main>b__1() in D:\a\s\src\OmniSharp.Stdio.Driver\Program.cs:line 74
at McMaster.Extensions.CommandLineUtils.CommandLineApplication.<>c__DisplayClass146_0.<OnExecute>b__0(CancellationToken _)
at McMaster.Extensions.CommandLineUtils.CommandLineApplication.<ExecuteAsync>d__157.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at McMaster.Extensions.CommandLineUtils.CommandLineApplication.Execute(String[] args)
at OmniSharp.HostHelpers.Start(Func`1 action) in D:\a\s\src\OmniSharp.Host\HostHelpers.cs:line 29
我不太确定发生了什么,但我也安装了 Visual Studio,但作为解决方案也失败了。
我遇到了同样的问题,我从这个 reddit post 得到了这个: https://www.reddit.com/r/vscode/comments/ooyijp/issue_with_omnisharpc_extension/
“您需要告诉 VS Code 仅使用 omnisharp 附带的捆绑 MSBuild 版本。 每 https://github.com/OmniSharp/omnisharp-vscode/issues/4358
您可以使用以下内容将 omnisharp.json 添加到工作空间的根目录中
{ "msbuild": { "useBundledOnly": true } }
对于全局效果,文件可以放入 %USERPROFILE%/.omnisharp/