[Mac/Linux]Failed to load project in vscode with exception "Microsoft.Build.Exceptions.InvalidProjectFileException: The SDK 'Microsoft.NET.Sdk.Web' specified could not be found."
See original GitHub issueOriginal issue: https://github.com/aspnet/AspNetCore-ManualTests/issues/134
Azure DevOps work item: https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1162694
Repro Steps
- Open a normal Terminal Emulator
- Create mvc project and open it using VS code
mkdir test9
cd test9 dotnet new mvc code . - Install latest C# from: https://github.com/OmniSharp/omnisharp-vscode/releases
- Click “Reload Now”.
- Quite VS Code after the C# extension download and install completely
- Run ‘code .’ to open the project again
Actual
- Failed to load the project, output (omnisharp log) has exception.
- F5 to failed to run the project. Select .Net Core in the dropdown, launch.json file is created and has warning, missing task.json file under .vscode, debug page is target to “.Net Core launch (console)”
- Open _layout.cshtml file, intellisense for “asp” does not display
Expected
- Project load succeed.
- F5 succeed to run the project.
- Intellisense works well.
Comment from @vi-nzicol
OmniSharp in output: Starting OmniSharp server at 7/27/2020, 6:55:54 PM Target: /Users/vstester/test9
OmniSharp server started. Path: /Users/vstester/.vscode/extensions/ms-dotnettools.csharp-1.22.2/.omnisharp/1.35.4/run PID: 20571
Starting OmniSharp on MacOS 10.15.4 (x64)
DotNetPath set to dotnet
Located 1 MSBuild instance(s)
1: StandAlone 16.4 - "/Users/vstester/.vscode/extensions/ms-dotnettools.csharp-1.22.2/.omnisharp/1.35.4/omnisharp/.msbuild/Current/Bin"
MSBUILD_EXE_PATH environment variable set to '/Users/vstester/.vscode/extensions/ms-dotnettools.csharp-1.22.2/.omnisharp/1.35.4/omnisharp/.msbuild/Current/Bin/MSBuild.dll'
Registered MSBuild instance: StandAlone 16.4 - "/Users/vstester/.vscode/extensions/ms-dotnettools.csharp-1.22.2/.omnisharp/1.35.4/omnisharp/.msbuild/Current/Bin"
CscToolExe = csc.exe
MSBuildToolsPath = /Users/vstester/.vscode/extensions/ms-dotnettools.csharp-1.22.2/.omnisharp/1.35.4/omnisharp/.msbuild/Current/Bin
CscToolPath = /Users/vstester/.vscode/extensions/ms-dotnettools.csharp-1.22.2/.omnisharp/1.35.4/omnisharp/.msbuild/Current/Bin/Roslyn
BypassFrameworkInstallChecks = true
MSBuildExtensionsPath = /Users/vstester/.vscode/extensions/ms-dotnettools.csharp-1.22.2/.omnisharp/1.35.4/omnisharp/.msbuild
Detecting Cake files in '/Users/vstester/test9'.
Could not find any Cake files
No solution files found in '/Users/vstester/test9'
Queue project update for '/Users/vstester/test9/test9.csproj'
Detecting CSX files in '/Users/vstester/test9'.
Could not find any CSX files
Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.CSharpFormattingWorkspaceOptionsProvider, Order: 0
Loading project: /Users/vstester/test9/test9.csproj
Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.RenameWorkspaceOptionsProvider, Order: 100
Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.ImplementTypeWorkspaceOptionsProvider, Order: 110
Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.BlockStructureWorkspaceOptionsProvider, Order: 140
Configuration finished.
Omnisharp server running using Stdio at location '/Users/vstester/test9' on host 20552.
**Failed to load project file '/Users/vstester/test9/test9.csproj'.
/Users/vstester/test9/test9.csproj(1,1)
Microsoft.Build.Exceptions.InvalidProjectFileException: The SDK ‘Microsoft.NET.Sdk.Web’ specified could not be found.** /Users/vstester/test9/test9.csproj
at Microsoft.Build.Shared.ProjectErrorUtilities.ThrowInvalidProject (System.String errorSubCategoryResourceName, Microsoft.Build.Shared.IElementLocation elementLocation, System.String resourceName, System.Object[] args) [0x00040] in <bdd74047e372417e917de44285101d65>:0
at Microsoft.Build.Shared.ProjectErrorUtilities.VerifyThrowInvalidProject[T1] (System.Boolean condition, System.String errorSubCategoryResourceName, Microsoft.Build.Shared.IElementLocation elementLocation, System.String resourceName, T1 arg0) [0x00003] in <bdd74047e372417e917de44285101d65>:0
at Microsoft.Build.Shared.ProjectErrorUtilities.ThrowInvalidProject[T1] (Microsoft.Build.Shared.IElementLocation elementLocation, System.String resourceName, T1 arg0) [0x00000] in <bdd74047e372417e917de44285101d65>:0
at Microsoft.Build.Evaluation.Evaluator4[P,I,M,D].ExpandAndLoadImportsFromUnescapedImportExpressionConditioned (System.String directoryOfImportingFile, Microsoft.Build.Construction.ProjectImportElement importElement, System.Collections.Generic.List
1[Microsoft.Build.Construction.ProjectRootElement]& projects, Microsoft.Build.BackEnd.SdkResolution.SdkResult& sdkResult, System.Boolean throwOnFileNotExistsError) [0x00254] in <bdd74047e372417e917de44285101d65>:0
at Microsoft.Build.Evaluation.Evaluator4[P,I,M,D].ExpandAndLoadImports (System.String directoryOfImportingFile, Microsoft.Build.Construction.ProjectImportElement importElement, Microsoft.Build.BackEnd.SdkResolution.SdkResult& sdkResult) [0x00027] in <bdd74047e372417e917de44285101d65>:0 at Microsoft.Build.Evaluation.Evaluator
4[P,I,M,D].EvaluateImportElement (System.String directoryOfImportingFile, Microsoft.Build.Construction.ProjectImportElement importElement) [0x0000d] in <bdd74047e372417e917de44285101d65>:0
at Microsoft.Build.Evaluation.Evaluator4[P,I,M,D].PerformDepthFirstPass (Microsoft.Build.Construction.ProjectRootElement currentProjectOrImport) [0x000e6] in <bdd74047e372417e917de44285101d65>:0 at Microsoft.Build.Evaluation.Evaluator
4[P,I,M,D].Evaluate () [0x0013c] in <bdd74047e372417e917de44285101d65>:0
at Microsoft.Build.Evaluation.Evaluator4[P,I,M,D].Evaluate (Microsoft.Build.Evaluation.IEvaluatorData
4[P,I,M,D] data, Microsoft.Build.Construction.ProjectRootElement root, Microsoft.Build.Evaluation.ProjectLoadSettings loadSettings, System.Int32 maxNodeCount, Microsoft.Build.Collections.PropertyDictionary1[T] environmentProperties, Microsoft.Build.BackEnd.Logging.ILoggingService loggingService, Microsoft.Build.Evaluation.IItemFactory
2[S,T] itemFactory, Microsoft.Build.Evaluation.IToolsetProvider toolsetProvider, Microsoft.Build.Evaluation.ProjectRootElementCacheBase projectRootElementCache, Microsoft.Build.Framework.BuildEventContext buildEventContext, Microsoft.Build.BackEnd.SdkResolution.ISdkResolverService sdkResolverService, System.Int32 submissionId, Microsoft.Build.Evaluation.Context.EvaluationContext evaluationContext, System.Boolean interactive) [0x00048] in <bdd74047e372417e917de44285101d65>:0
at Microsoft.Build.Evaluation.Project+ProjectImpl.Reevaluate (Microsoft.Build.BackEnd.Logging.ILoggingService loggingServiceForEvaluation, Microsoft.Build.Evaluation.ProjectLoadSettings loadSettings, Microsoft.Build.Evaluation.Context.EvaluationContext evaluationContext) [0x00063] in <bdd74047e372417e917de44285101d65>:0
at Microsoft.Build.Evaluation.Project+ProjectImpl.ReevaluateIfNecessary (Microsoft.Build.BackEnd.Logging.ILoggingService loggingServiceForEvaluation, Microsoft.Build.Evaluation.ProjectLoadSettings loadSettings, Microsoft.Build.Evaluation.Context.EvaluationContext evaluationContext) [0x00035] in <bdd74047e372417e917de44285101d65>:0
at Microsoft.Build.Evaluation.Project+ProjectImpl.ReevaluateIfNecessary (Microsoft.Build.BackEnd.Logging.ILoggingService loggingServiceForEvaluation, Microsoft.Build.Evaluation.Context.EvaluationContext evaluationContext) [0x00000] in <bdd74047e372417e917de44285101d65>:0
at Microsoft.Build.Evaluation.Project+ProjectImpl.ReevaluateIfNecessary (Microsoft.Build.Evaluation.Context.EvaluationContext evaluationContext) [0x00007] in <bdd74047e372417e917de44285101d65>:0
at Microsoft.Build.Evaluation.Project+ProjectImpl.Initialize (System.Collections.Generic.IDictionary2[TKey,TValue] globalProperties, System.String toolsVersion, System.String subToolsetVersion, Microsoft.Build.Evaluation.ProjectLoadSettings loadSettings, Microsoft.Build.Evaluation.Context.EvaluationContext evaluationContext) [0x0012b] in <bdd74047e372417e917de44285101d65>:0 at Microsoft.Build.Evaluation.Project..ctor (System.String projectFile, System.Collections.Generic.IDictionary
2[TKey,TValue] globalProperties, System.String toolsVersion, System.String subToolsetVersion, Microsoft.Build.Evaluation.ProjectCollection projectCollection, Microsoft.Build.Evaluation.ProjectLoadSettings loadSettings, Microsoft.Build.Evaluation.Context.EvaluationContext evaluationContext) [0x00075] in <bdd74047e372417e917de44285101d65>:0
at Microsoft.Build.Evaluation.Project…ctor (System.String projectFile, System.Collections.Generic.IDictionary2[TKey,TValue] globalProperties, System.String toolsVersion, System.String subToolsetVersion, Microsoft.Build.Evaluation.ProjectCollection projectCollection, Microsoft.Build.Evaluation.ProjectLoadSettings loadSettings) [0x00000] in <bdd74047e372417e917de44285101d65>:0 at Microsoft.Build.Evaluation.Project..ctor (System.String projectFile, System.Collections.Generic.IDictionary
2[TKey,TValue] globalProperties, System.String toolsVersion, Microsoft.Build.Evaluation.ProjectCollection projectCollection, Microsoft.Build.Evaluation.ProjectLoadSettings loadSettings) [0x00000] in <bdd74047e372417e917de44285101d65>:0
at Microsoft.Build.Evaluation.Project…ctor (System.String projectFile, System.Collections.Generic.IDictionary2[TKey,TValue] globalProperties, System.String toolsVersion, Microsoft.Build.Evaluation.ProjectCollection projectCollection) [0x00000] in <bdd74047e372417e917de44285101d65>:0 at Microsoft.Build.Evaluation.ProjectCollection.LoadProject (System.String fileName, System.Collections.Generic.IDictionary
2[TKey,TValue] globalProperties, System.String toolsVersion) [0x000f7] in <bdd74047e372417e917de44285101d65>:0
at Microsoft.Build.Evaluation.ProjectCollection.LoadProject (System.String fileName, System.String toolsVersion) [0x00000] in <bdd74047e372417e917de44285101d65>:0
at OmniSharp.MSBuild.ProjectLoader.EvaluateProjectFileCore (System.String filePath) [0x0003f] in <7a72b8fb00e24de4bdc8f05dbf760119>:0
at OmniSharp.MSBuild.ProjectLoader.BuildProject (System.String filePath) [0x0000d] in <7a72b8fb00e24de4bdc8f05dbf760119>:0
at OmniSharp.MSBuild.ProjectFile.ProjectFileInfo.Load (System.String filePath, OmniSharp.MSBuild.ProjectIdInfo projectIdInfo, OmniSharp.MSBuild.ProjectLoader loader, System.Guid sessionId, OmniSharp.Services.DotNetInfo dotNetInfo) [0x00015] in <7a72b8fb00e24de4bdc8f05dbf760119>:0
at OmniSharp.MSBuild.ProjectManager+<>c__DisplayClass31_0.<LoadProject>b__0 () [0x00000] in <7a72b8fb00e24de4bdc8f05dbf760119>:0
at (wrapper delegate-invoke) System.Func1[System.ValueTuple
3[OmniSharp.MSBuild.ProjectFile.ProjectFileInfo,System.Collections.Immutable.ImmutableArray1[OmniSharp.MSBuild.Logging.MSBuildDiagnostic],OmniSharp.MSBuild.Notification.ProjectLoadedEventArgs]].invoke_TResult() at OmniSharp.MSBuild.ProjectManager.LoadOrReloadProject (System.String projectFilePath, System.Func
1[TResult] loader) [0x0001b] in <7a72b8fb00e24de4bdc8f05dbf760119>:0
Attempted to update project that is not loaded: /Users/vstester/test9/test9.csproj
Miscellaneous file: /Users/vstester/test9/Views/Shared/_Layout.cshtml__virtual.cs added to workspace
Issue Analytics
- State:
- Created 3 years ago
- Comments:13 (8 by maintainers)
Top GitHub Comments
I finally worked out why the SDK was not being located. The minimumMSBuildVersion for the 3.1.401 SDK is 16.7.0. The OmniSharp and the C# extension just recently started shipping the Mono 6.10.0 with MSBuild 16.6.0. So you will need to install the Preview build of Mono 6.12.0 which comes with MSBuild 16.7.0.
You can find the download here - https://www.mono-project.com/download/preview/
Also, be sure that “omnisharp.useGlobalMono” is set to “auto” so that it will use the system install of Mono.
@Yuyue960724 Pre-release version https://github.com/OmniSharp/omnisharp-vscode/releases/tag/v1.23.0 should resolve issues using newer SDKs. You will need to use the included Mono by setting “useGlobalMono” to “never”.