这个 Omnisharp 错误不允许我用 C# 开始我的第一个 Godot 项目



我一次又一次地得到这个Omnisharp错误。我现在不知道出了什么问题。

Starting OmniSharp server at 11/5/2022, 6:12:47 pm
Target: d:StudyProjectsGodotC# Project.sln
OmniSharp server started.
Path: c:Usersanime.vscodeextensionsms-dotnettools.csharp-1.24.4-win32-x64.omnisharp1.38.3-beta.78OmniSharp.exe
PID: 3536
[info]: OmniSharp.Stdio.Host
Starting OmniSharp on Windows 6.1.7601.65536 (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
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
Located 1 MSBuild instance(s)
1: Visual Studio Community 2019 16.11.32413.511 16.11.2 - "C:Program Files (x86)Microsoft Visual Studio2019CommunityMSBuildCurrentBin"
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
Registered MSBuild instance: Visual Studio Community 2019 16.11.32413.511 16.11.2 - "C:Program Files (x86)Microsoft Visual Studio2019CommunityMSBuildCurrentBin"
[info]: OmniSharp.WorkspaceInitializer
Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.CSharpFormattingWorkspaceOptionsProvider, Order: 0
[info]: OmniSharp.Cake.CakeProjectSystem
Detecting Cake files in 'd:StudyProjectsGodot'.
[info]: OmniSharp.Cake.CakeProjectSystem
Did not find any Cake files
[info]: OmniSharp.MSBuild.ProjectSystem
Detecting projects in 'd:StudyProjectsGodotC# Project.sln'.
[info]: OmniSharp.MSBuild.ProjectManager
Queue project update for 'd:StudyProjectsGodotC# Project.csproj'
[info]: OmniSharp.Script.ScriptProjectSystem
Detecting CSX files in 'd:StudyProjectsGodot'.
[info]: OmniSharp.Script.ScriptProjectSystem
Did not find any CSX files
[info]: OmniSharp.WorkspaceInitializer
Configuration finished.
[info]: OmniSharp.Stdio.Host
Omnisharp server running using Stdio at location 'd:StudyProjectsGodot' on host 5068.
[info]: OmniSharp.MSBuild.ProjectManager
Loading project: d:StudyProjectsGodotC# Project.csproj
[fail]: OmniSharp.MSBuild.ProjectLoader
The SDK 'Microsoft.NET.SDK.WorkloadAutoImportPropsLocator' specified could not be found.
[fail]: OmniSharp.MSBuild.ProjectManager
Failed to load project file 'd:StudyProjectsGodotC# Project.csproj'.
Microsoft.Build.Exceptions.InvalidProjectFileException: The SDK 'Microsoft.NET.SDK.WorkloadAutoImportPropsLocator' specified could not be found.  C:Program Filesdotnetsdk6.0.201SdksMicrosoft.NET.SdktargetsMicrosoft.NET.Sdk.ImportWorkloads.props
at Microsoft.Build.Shared.ProjectErrorUtilities.ThrowInvalidProject(String errorSubCategoryResourceName, IElementLocation elementLocation, String resourceName, Object[] args)
at Microsoft.Build.Evaluation.Evaluator`4.ExpandAndLoadImportsFromUnescapedImportExpressionConditioned(String directoryOfImportingFile, ProjectImportElement importElement, List`1& projects, SdkResult& sdkResult, Boolean throwOnFileNotExistsError)
at Microsoft.Build.Evaluation.Evaluator`4.ExpandAndLoadImports(String directoryOfImportingFile, ProjectImportElement importElement, SdkResult& sdkResult)
at Microsoft.Build.Evaluation.Evaluator`4.EvaluateImportElement(String directoryOfImportingFile, ProjectImportElement importElement)
at Microsoft.Build.Evaluation.Evaluator`4.PerformDepthFirstPass(ProjectRootElement currentProjectOrImport)
at Microsoft.Build.Evaluation.Evaluator`4.EvaluateImportElement(String directoryOfImportingFile, ProjectImportElement importElement)
at Microsoft.Build.Evaluation.Evaluator`4.PerformDepthFirstPass(ProjectRootElement currentProjectOrImport)
at Microsoft.Build.Evaluation.Evaluator`4.EvaluateImportElement(String directoryOfImportingFile, ProjectImportElement importElement)
at Microsoft.Build.Evaluation.Evaluator`4.PerformDepthFirstPass(ProjectRootElement currentProjectOrImport)
at Microsoft.Build.Evaluation.Evaluator`4.EvaluateImportElement(String directoryOfImportingFile, ProjectImportElement importElement)
at Microsoft.Build.Evaluation.Evaluator`4.PerformDepthFirstPass(ProjectRootElement currentProjectOrImport)
at Microsoft.Build.Evaluation.Evaluator`4.EvaluateImportElement(String directoryOfImportingFile, ProjectImportElement importElement)
at Microsoft.Build.Evaluation.Evaluator`4.PerformDepthFirstPass(ProjectRootElement currentProjectOrImport)
at Microsoft.Build.Evaluation.Evaluator`4.Evaluate()
at Microsoft.Build.Evaluation.Evaluator`4.Evaluate(IEvaluatorData`4 data, ProjectRootElement root, ProjectLoadSettings loadSettings, Int32 maxNodeCount, PropertyDictionary`1 environmentProperties, ILoggingService loggingService, IItemFactory`2 itemFactory, IToolsetProvider toolsetProvider, ProjectRootElementCacheBase projectRootElementCache, BuildEventContext buildEventContext, ISdkResolverService sdkResolverService, Int32 submissionId, EvaluationContext evaluationContext, Boolean interactive)
at Microsoft.Build.Evaluation.Project.ProjectImpl.Reevaluate(ILoggingService loggingServiceForEvaluation, ProjectLoadSettings loadSettings, EvaluationContext evaluationContext)
at Microsoft.Build.Evaluation.Project.ProjectImpl.ReevaluateIfNecessary(ILoggingService loggingServiceForEvaluation, ProjectLoadSettings loadSettings, EvaluationContext evaluationContext)
at Microsoft.Build.Evaluation.Project.ProjectImpl.ReevaluateIfNecessary(EvaluationContext evaluationContext)
at Microsoft.Build.Evaluation.Project.ProjectImpl.Initialize(IDictionary`2 globalProperties, String toolsVersion, String subToolsetVersion, ProjectLoadSettings loadSettings, EvaluationContext evaluationContext)
at Microsoft.Build.Evaluation.Project..ctor(String projectFile, IDictionary`2 globalProperties, String toolsVersion, String subToolsetVersion, ProjectCollection projectCollection, ProjectLoadSettings loadSettings, EvaluationContext evaluationContext)
at Microsoft.Build.Evaluation.ProjectCollection.LoadProject(String fileName, IDictionary`2 globalProperties, String toolsVersion)
at OmniSharp.MSBuild.ProjectLoader.EvaluateProjectFileCore(String filePath, IReadOnlyDictionary`2 projectConfigurationsInSolution, IList`1 loggers) in D:a1ssrcOmniSharp.MSBuildProjectLoader.cs:line 160
at OmniSharp.MSBuild.ProjectLoader.BuildProject(String filePath, IReadOnlyDictionary`2 configurationsInSolution) in D:a1ssrcOmniSharp.MSBuildProjectLoader.cs:line 84
at OmniSharp.MSBuild.ProjectFile.ProjectFileInfo.Load(String filePath, ProjectIdInfo projectIdInfo, ProjectLoader loader, Guid sessionId, DotNetInfo dotNetInfo) in D:a1ssrcOmniSharp.MSBuildProjectFileProjectFileInfo.cs:line 117
at OmniSharp.MSBuild.ProjectManager.<>c__DisplayClass32_0.<LoadProject>b__0() in D:a1ssrcOmniSharp.MSBuildProjectManager.cs:line 305
at OmniSharp.MSBuild.ProjectManager.LoadOrReloadProject(String projectFilePath, Func`1 loader) in D:a1ssrcOmniSharp.MSBuildProjectManager.cs:line 316
d:StudyProjectsGodotC# Project.csproj(0,0)
Microsoft.Build.Exceptions.InvalidProjectFileException: The SDK 'Microsoft.NET.SDK.WorkloadAutoImportPropsLocator' specified could not be found.  C:Program Filesdotnetsdk6.0.201SdksMicrosoft.NET.SdktargetsMicrosoft.NET.Sdk.ImportWorkloads.props
at Microsoft.Build.Shared.ProjectErrorUtilities.ThrowInvalidProject(String errorSubCategoryResourceName, IElementLocation elementLocation, String resourceName, Object[] args)
at Microsoft.Build.Evaluation.Evaluator`4.ExpandAndLoadImportsFromUnescapedImportExpressionConditioned(String directoryOfImportingFile, ProjectImportElement importElement, List`1& projects, SdkResult& sdkResult, Boolean throwOnFileNotExistsError)
at Microsoft.Build.Evaluation.Evaluator`4.ExpandAndLoadImports(String directoryOfImportingFile, ProjectImportElement importElement, SdkResult& sdkResult)
at Microsoft.Build.Evaluation.Evaluator`4.EvaluateImportElement(String directoryOfImportingFile, ProjectImportElement importElement)
at Microsoft.Build.Evaluation.Evaluator`4.PerformDepthFirstPass(ProjectRootElement currentProjectOrImport)
at Microsoft.Build.Evaluation.Evaluator`4.EvaluateImportElement(String directoryOfImportingFile, ProjectImportElement importElement)
at Microsoft.Build.Evaluation.Evaluator`4.PerformDepthFirstPass(ProjectRootElement currentProjectOrImport)
at Microsoft.Build.Evaluation.Evaluator`4.EvaluateImportElement(String directoryOfImportingFile, ProjectImportElement importElement)
at Microsoft.Build.Evaluation.Evaluator`4.PerformDepthFirstPass(ProjectRootElement currentProjectOrImport)
at Microsoft.Build.Evaluation.Evaluator`4.EvaluateImportElement(String directoryOfImportingFile, ProjectImportElement importElement)
at Microsoft.Build.Evaluation.Evaluator`4.PerformDepthFirstPass(ProjectRootElement currentProjectOrImport)
at Microsoft.Build.Evaluation.Evaluator`4.EvaluateImportElement(String directoryOfImportingFile, ProjectImportElement importElement)
at Microsoft.Build.Evaluation.Evaluator`4.PerformDepthFirstPass(ProjectRootElement currentProjectOrImport)
at Microsoft.Build.Evaluation.Evaluator`4.Evaluate()
at Microsoft.Build.Evaluation.Evaluator`4.Evaluate(IEvaluatorData`4 data, ProjectRootElement root, ProjectLoadSettings loadSettings, Int32 maxNodeCount, PropertyDictionary`1 environmentProperties, ILoggingService loggingService, IItemFactory`2 itemFactory, IToolsetProvider toolsetProvider, ProjectRootElementCacheBase projectRootElementCache, BuildEventContext buildEventContext, ISdkResolverService sdkResolverService, Int32 submissionId, EvaluationContext evaluationContext, Boolean interactive)
at Microsoft.Build.Evaluation.Project.ProjectImpl.Reevaluate(ILoggingService loggingServiceForEvaluation, ProjectLoadSettings loadSettings, EvaluationContext evaluationContext)
at Microsoft.Build.Evaluation.Project.ProjectImpl.ReevaluateIfNecessary(ILoggingService loggingServiceForEvaluation, ProjectLoadSettings loadSettings, EvaluationContext evaluationContext)
at Microsoft.Build.Evaluation.Project.ProjectImpl.ReevaluateIfNecessary(EvaluationContext evaluationContext)
at Microsoft.Build.Evaluation.Project.ProjectImpl.Initialize(IDictionary`2 globalProperties, String toolsVersion, String subToolsetVersion, ProjectLoadSettings loadSettings, EvaluationContext evaluationContext)
at Microsoft.Build.Evaluation.Project..ctor(String projectFile, IDictionary`2 globalProperties, String toolsVersion, String subToolsetVersion, ProjectCollection projectCollection, ProjectLoadSettings loadSettings, EvaluationContext evaluationContext)
at Microsoft.Build.Evaluation.ProjectCollection.LoadProject(String fileName, IDictionary`2 globalProperties, String toolsVersion)
at OmniSharp.MSBuild.ProjectLoader.EvaluateProjectFileCore(String filePath, IReadOnlyDictionary`2 projectConfigurationsInSolution, IList`1 loggers) in D:a1ssrcOmniSharp.MSBuildProjectLoader.cs:line 160
at OmniSharp.MSBuild.ProjectLoader.BuildProject(String filePath, IReadOnlyDictionary`2 configurationsInSolution) in D:a1ssrcOmniSharp.MSBuildProjectLoader.cs:line 84
at OmniSharp.MSBuild.ProjectFile.ProjectFileInfo.Load(String filePath, ProjectIdInfo projectIdInfo, ProjectLoader loader, Guid sessionId, DotNetInfo dotNetInfo) in D:a1ssrcOmniSharp.MSBuildProjectFileProjectFileInfo.cs:line 117
at OmniSharp.MSBuild.ProjectManager.<>c__DisplayClass32_0.<LoadProject>b__0() in D:a1ssrcOmniSharp.MSBuildProjectManager.cs:line 305
at OmniSharp.MSBuild.ProjectManager.LoadOrReloadProject(String projectFilePath, Func`1 loader) in D:a1ssrcOmniSharp.MSBuildProjectManager.cs:line 316
[fail]: OmniSharp.MSBuild.ProjectManager
Attempted to update project that is not loaded: d:StudyProjectsGodotC# Project.csproj
[warn]: OmniSharp.Roslyn.CSharp.Services.InlayHints.InlayHintService
Inlay hints requested for document not in workspace Location { FileName = d:StudyProjectsGodotPlayerController.cs, Range = Range { Start = Point { Line = 0, Column = 0 }, End = Point { Line = 21, Column = 0 } } }
[warn]: OmniSharp.Roslyn.CSharp.Services.InlayHints.InlayHintService
Inlay hints requested for document not in workspace Location { FileName = d:StudyProjectsGodotPlayerController.cs, Range = Range { Start = Point { Line = 0, Column = 0 }, End = Point { Line = 21, Column = 0 } } }

我已经设置了"Omnisharp: Use Global monoquot;总是我还设置了" omnissharp .path";我也安装了Visual studio 2019版本,正如你所看到的,它正在拾取vs 2019的msbuild,但我想使用vs code,所以我改变了msbuild文件夹名称,并试图再次运行它然后我得到了这个错误


Starting OmniSharp server at 11/5/2022, 6:38:25 pm
Target: d:StudyProjectsGodotC# Project.sln
OmniSharp server started.
Path: c:Usersanime.vscodeextensionsms-dotnettools.csharp-1.24.4-win32-x64.omnisharp1.38.3-beta.78OmniSharp.exe
PID: 4236
[info]: OmniSharp.Stdio.Host
Starting OmniSharp on Windows 6.1.7601.65536 (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 Studio2019CommunityMSBuildCurrentBinMicrosoft.Build.dll
at System.Diagnostics.FileVersionInfo.GetVersionInfo(String fileName)
at OmniSharp.MSBuild.Discovery.MSBuildInstanceProvider.GetMSBuildVersion(String microsoftBuildPath) in D:a1ssrcOmniSharp.HostMSBuildDiscoveryMSBuildInstanceProvider.cs:line 67
at OmniSharp.MSBuild.Discovery.Providers.MicrosoftBuildLocatorInstanceProvider.<>c.<GetInstances>b__1_0(VisualStudioInstance instance) in D:a1ssrcOmniSharp.HostMSBuildDiscoveryProvidersMicrosoftBuildLocatorInstanceProvider.cs:line 29
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:a1ssrcOmniSharp.HostMSBuildDiscoveryMSBuildLocator.cs:line 120
at OmniSharp.MSBuild.Discovery.Extensions.GetBestInstance(IMSBuildLocator msbuildLocator, Version minimumMSBuildVersion, ILogger logger, Boolean& invalidVSFound, Boolean& vsWithoutSdkResolver) in D:a1ssrcOmniSharp.HostMSBuildDiscoveryExtensions.cs:line 84
at OmniSharp.MSBuild.Discovery.Extensions.RegisterDefaultInstance(IMSBuildLocator msbuildLocator, ILogger logger, DotNetInfo dotNetInfo) in D:a1ssrcOmniSharp.HostMSBuildDiscoveryExtensions.cs:line 17
at OmniSharp.CompositionHostBuilder.Build(String workingDirectory) in D:a1ssrcOmniSharp.HostCompositionHostBuilder.cs:line 71
at OmniSharp.Stdio.Host..ctor(TextReader input, ISharedTextWriter writer, IOmniSharpEnvironment environment, IServiceProvider serviceProvider, CompositionHostBuilder compositionHostBuilder, ILoggerFactory loggerFactory, CancellationTokenSource cancellationTokenSource) in D:a1ssrcOmniSharp.StdioHost.cs:line 49
at OmniSharp.Stdio.Driver.Program.<>c__DisplayClass0_1.<Main>b__1() in D:a1ssrcOmniSharp.Stdio.DriverProgram.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:a1ssrcOmniSharp.HostHostHelpers.cs:line 30

现在我没有更多的解决方案要做。请帮忙处理这件事

答案实际上就在问题中执行Omnisharpin告诉你的指令,你已经有了问题

[fail]: OmniSharp.MSBuild.ProjectLoader
The SDK 'Microsoft.NET.SDK.WorkloadAutoImportPropsLocator' specified could not be found. 
[fail]: OmniSharp.MSBuild.ProjectManager
Failed to load project file 'd:StudyProjectsGodotC# Project. csproj'."

它在这里告诉你"Microsoft.NET.SDK.WorkloadAutoImportPropsLocator">不可用。此外,d:StudyProjectsGodot c#项目也存在问题。csproj文件,如果你能复制它,创建这个文件。

Microsoft.NET.SDK.WorkloadAutoImportPropsLocator:使用。net卸载工具卸载此文件,并下载最新的net版本

我得到类似的错误关于OmniSharp.MSBuild.ProjectManager

安装dev SDK 6和。net Framework 4.7.2的目标包修复了这个问题。

相关内容

  • 没有找到相关文章

最新更新