我在Intellisense上无法完全使用C#遇到问题。对于某些事情,它确实起作用(例如:尝试使用using语句),而对于其他事情,则不起作用(例如:Linq查询或在startup.cs文件应用程序中。{enter what}什么都不显示)。但是对于我的其他同学,确实为他们展示了所有这些内容。 Omnisharp的绿色火焰表示服务器正在运行,并且我的语言设置为C#。抱歉,我不知道提供Omnisharp日志的最佳方法,它对于屏幕截图来说太大了,而且我还是第一次发布。编辑:当某些东西行不通时,什么也没加下划线,我不知道这是否有帮助,但这是我也注意到其他同学在使用VS代码时发生的事情
Starting OmniSharp server at 1/16/2019, 8:30:58 AM
Target: c:\Users\{NAME}\Documents\{NAME}\CSharp\MusicLinqSkeleton-master
OmniSharp server started.
Path: C:\Users\{NAME}\.vscode\extensions\ms-vscode.csharp-1.17.1\.omnisharp\1.32.8\OmniSharp.exe
PID: 12540
[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 3 MSBuild instance(s)
1: Visual Studio Build Tools 2017 15.9.28307.145 - "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin"
2: Visual Studio Community 2017 15.9.28307.222 - "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin"
3: StandAlone 15.0 - "C:\Users\{NAME}\.vscode\extensions\ms-vscode.csharp-1.17.1\.omnisharp\1.32.8\msbuild\15.0\Bin"
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
Registered MSBuild instance: Visual Studio Build Tools 2017 15.9.28307.145 - "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin"
[info]: OmniSharp.Cake.CakeProjectSystem
Detecting Cake files in 'c:\Users\{NAME}\Documents\{NAME}\CSharp\MusicLinqSkeleton-master'.
[info]: OmniSharp.Cake.CakeProjectSystem
Could not find any Cake files
[info]: OmniSharp.WorkspaceInitializer
Project system 'OmniSharp.DotNet.DotNetProjectSystem' is disabled in the configuration.
[info]: OmniSharp.MSBuild.ProjectSystem
No solution files found in 'c:\Users\{NAME}\Documents\{NAME}\CSharp\MusicLinqSkeleton-master'
[info]: OmniSharp.MSBuild.ProjectManager
Queue project update for 'c:\Users\{NAME}\Documents\{NAME}\CSharp\MusicLinqSkeleton-master\LinqSkeleton.csproj'
[info]: OmniSharp.Script.ScriptProjectSystem
Detecting CSX files in 'c:\Users\{NAME}\Documents\{NAME}\CSharp\MusicLinqSkeleton-master'.
[info]: OmniSharp.Script.ScriptProjectSystem
Could not find any CSX files
[info]: OmniSharp.WorkspaceInitializer
Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.CSharpWorkspaceOptionsProvider
[info]: OmniSharp.WorkspaceInitializer
Configuration finished.
[info]: OmniSharp.Stdio.Host
Omnisharp server running using Stdio at location 'c:\Users\{NAME}\Documents\{NAME}\CSharp\MusicLinqSkeleton-master' on host 9952.
[info]: OmniSharp.MSBuild.ProjectManager
Loading project: c:\Users\{NAME}\Documents\{NAME}\CSharp\MusicLinqSkeleton-master\LinqSkeleton.csproj
[warn]: OmniSharp.MSBuild.ProjectManager
Failed to load project file 'c:\Users\{NAME}\Documents\{NAME}\CSharp\MusicLinqSkeleton-master\LinqSkeleton.csproj'.
c:\Users\{NAME}\Documents\{NAME}\CSharp\MusicLinqSkeleton-master\LinqSkeleton.csproj(1,1)
Microsoft.Build.Exceptions.InvalidProjectFileException: Could not load SDK Resolver. A manifest file exists, but the path to the SDK Resolver DLL file could not be found. Manifest file path 'C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\SdkResolvers\Microsoft.Build.NuGetSdkResolver\Microsoft.Build.NuGetSdkResolver.xml'. SDK resolver path: C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\Common7\IDE\CommonExtensions\Microsoft\NuGet\Microsoft.Build.NuGetSdkResolver.dll c:\Users\{NAME}\Documents\{NAME}\CSharp\MusicLinqSkeleton-master\LinqSkeleton.csproj
at Microsoft.Build.Shared.ProjectFileErrorUtilities.VerifyThrowInvalidProjectFile(Boolean condition, String errorSubCategoryResourceName, BuildEventFileInfo projectFile, Exception innerException, String resourceName, Object[] args)
at Microsoft.Build.BackEnd.SdkResolution.SdkResolverLoader.TryAddAssemblyFromManifest(String pathToManifest, String manifestFolder, List`1 assembliesList, ElementLocation location)
at Microsoft.Build.BackEnd.SdkResolution.SdkResolverLoader.FindPotentialSdkResolvers(String rootFolder, ElementLocation location)
at Microsoft.Build.BackEnd.SdkResolution.SdkResolverLoader.LoadResolvers(LoggingContext loggingContext, ElementLocation location)
at Microsoft.Build.BackEnd.SdkResolution.SdkResolverService.Initialize(LoggingContext loggingContext, ElementLocation location)
at Microsoft.Build.BackEnd.SdkResolution.SdkResolverService.ResolveSdk(Int32 submissionId, SdkReference sdk, LoggingContext loggingContext, ElementLocation sdkReferenceLocation, String solutionPath, String projectPath, Boolean interactive)
at Microsoft.Build.BackEnd.SdkResolution.CachingSdkResolverService.<>c__DisplayClass3_0.<ResolveSdk>b__0(String key)
at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory)
at Microsoft.Build.BackEnd.SdkResolution.CachingSdkResolverService.ResolveSdk(Int32 submissionId, SdkReference sdk, LoggingContext loggingContext, ElementLocation sdkReferenceLocation, String solutionPath, String projectPath, Boolean interactive)
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.Evaluate(ILoggingService loggingService, BuildEventContext buildEventContext)
at Microsoft.Build.Evaluation.Project.Reevaluate(ILoggingService loggingServiceForEvaluation, ProjectLoadSettings loadSettings, EvaluationContext evaluationContext)
at Microsoft.Build.Evaluation.Project.ReevaluateIfNecessary(ILoggingService loggingServiceForEvaluation, ProjectLoadSettings loadSettings, EvaluationContext evaluationContext)
at Microsoft.Build.Evaluation.Project.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)
at OmniSharp.MSBuild.ProjectLoader.BuildProject(String filePath)
at OmniSharp.MSBuild.ProjectFile.ProjectFileInfo.Load(String filePath, ProjectLoader loader)
at OmniSharp.MSBuild.ProjectManager.LoadOrReloadProject(String projectFilePath, Func`1 loader)
[fail]: OmniSharp.MSBuild.ProjectManager
Attemped to update project that is not loaded: c:\Users\{NAME}\Documents\{NAME}\CSharp\MusicLinqSkeleton-master\LinqSkeleton.csproj
[info]: OmniSharp.OmniSharpWorkspace
Miscellaneous file: c:\Users\{NAME}\Documents\{NAME}\CSharp\MusicLinqSkeleton-master\Program.cs added to workspace
答案 0 :(得分:0)
遇到相同问题时,对我有帮助的是here的评论。
解决此问题的步骤
打开文件:
cd /usr/share/dotnet/sdk/$(dotnet --version)/Sdks/Microsoft.NET.Sdk/Sdk
sudo vim Sdk.props
找到一行:
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" />
并替换为以下命令的输出:
echo "<Import Project=\"/usr/share/dotnet/sdk/$(dotnet --version)/Current/Microsoft.Common.props\" />"
# <Import Project="/usr/share/dotnet/sdk/2.2.402/Current/Microsoft.Common.props" />
此外,我从项目目录中删除了 obj 目录,并运行dotnet restore
以确保所有内容都是新鲜的。