question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[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 issue

Original issue: https://github.com/aspnet/AspNetCore-ManualTests/issues/134

Azure DevOps work item: https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1162694

Repro Steps

  1. Open a normal Terminal Emulator
  2. Create mvc project and open it using VS code mkdir test9
    cd test9 dotnet new mvc code .
  3. Install latest C# from: https://github.com/OmniSharp/omnisharp-vscode/releases
  4. Click “Reload Now”.
  5. Quite VS Code after the C# extension download and install completely
  6. Run ‘code .’ to open the project again

Actual

  1. Failed to load the project, output (omnisharp log) has exception. image
  2. 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)” image
  3. Open _layout.cshtml file, intellisense for “asp” does not display image

Expected

  1. Project load succeed.
  2. F5 succeed to run the project.
  3. 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.List1[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.Evaluator4[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.Evaluator4[P,I,M,D].Evaluate () [0x0013c] in <bdd74047e372417e917de44285101d65>:0 at Microsoft.Build.Evaluation.Evaluator4[P,I,M,D].Evaluate (Microsoft.Build.Evaluation.IEvaluatorData4[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.IItemFactory2[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.IDictionary2[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.IDictionary2[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.IDictionary2[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.ValueTuple3[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.Func1[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:closed
  • Created 3 years ago
  • Comments:13 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
JoeRobichcommented, Aug 3, 2020

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.

0reactions
JoeRobichcommented, Aug 13, 2020

@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”.

Read more comments on GitHub >

github_iconTop Results From Across the Web

The SDK 'Microsoft.NET.Sdk.Web' specified could not be ...
Try the workaround solution bellow: Add a file called omnisharp.json to your project folder with following content { "MsBuild": ...
Read more >
MSB4236: The SDK 'name' specified could not be found.
This error occurs when an MSBuild SDK couldn't be loaded. ... NET SDK (Microsoft.NET.Sdk.Web). MSBuild project SDKs can be delivered NuGet ...
Read more >
Run and Debug Java in Visual Studio Code
Another way to start debugging is to select Run Java or Debug Java menu from the top editor title bar. EditorMenu. Run from...
Read more >
Cannot get code completion to work in Visual Studio Code ...
l:\repositories\newtestproject\newtestproject\Assembly-CSharp.csproj(1,1). Microsoft.Build.Exceptions.InvalidProjectFileException: The ...
Read more >
Creating and editing solution files with the .NET CLI
Microsoft Visual Studio Solution File, Format Version 12.00 # Visual ... InvalidProjectFileException: The project file could not be loaded.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found