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.

.Net.sdk.web not found

See original GitHub issue

Environment data

dotnet --info output:

.NET Core SDK (reflecting any global.json):
 Version:   2.2.202
 Commit:    8a7ff6789d

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.10586
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\2.2.202\

Host (useful for support):
  Version: 2.2.3
  Commit:  6b8ad509b6

.NET Core SDKs installed:
  2.2.202 [C:\Program Files\dotnet\sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.All 2.2.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.2.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.2.3 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]

To install additional .NET Core runtimes or SDKs:
  https://aka.ms/dotnet-download
PS C:\Dotnet Core\NgWebApi>

VS Code version:1.33.0 C# Extension version:1.18.0

Steps to reproduce

Build or run from VS Code

Expected behavior

no errors

Actual behavior

Starting OmniSharp server at 4/5/2019, 3:37:16 PM
    Target: c:\Dotnet Core\NgWebApi

OmniSharp server started.
    Path: C:\Users\Acer\.vscode\extensions\ms-vscode.csharp-1.18.0\.omnisharp\1.32.11\OmniSharp.exe
    PID: 13684

[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 1 MSBuild instance(s)
            1: StandAlone 15.0 - "C:\Users\Acer\.vscode\extensions\ms-vscode.csharp-1.18.0\.omnisharp\1.32.11\msbuild\15.0\Bin"
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        MSBUILD_EXE_PATH environment variable set to 'C:\Users\Acer\.vscode\extensions\ms-vscode.csharp-1.18.0\.omnisharp\1.32.11\msbuild\15.0\Bin\MSBuild.exe'
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Registered MSBuild instance: StandAlone 15.0 - "C:\Users\Acer\.vscode\extensions\ms-vscode.csharp-1.18.0\.omnisharp\1.32.11\msbuild\15.0\Bin"
            CscToolExe = csc.exe
            CscToolPath = C:\Users\Acer\.vscode\extensions\ms-vscode.csharp-1.18.0\.omnisharp\1.32.11\msbuild\15.0\Bin\Roslyn
            MSBuildExtensionsPath = C:\Users\Acer\.vscode\extensions\ms-vscode.csharp-1.18.0\.omnisharp\1.32.11\msbuild
            MSBuildToolsPath = C:\Users\Acer\.vscode\extensions\ms-vscode.csharp-1.18.0\.omnisharp\1.32.11\msbuild\15.0\Bin
[info]: OmniSharp.Cake.CakeProjectSystem
        Detecting Cake files in 'c:\Dotnet Core\NgWebApi'.
[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:\Dotnet Core\NgWebApi'
[info]: OmniSharp.MSBuild.ProjectManager
        Queue project update for 'c:\Dotnet Core\NgWebApi\NgWebApi.csproj'
[info]: OmniSharp.Script.ScriptProjectSystem
        Detecting CSX files in 'c:\Dotnet Core\NgWebApi'.
[info]: OmniSharp.Script.ScriptProjectSystem
        Could not find any CSX files
[info]: OmniSharp.WorkspaceInitializer
        Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.CSharpWorkspaceOptionsProvider
[info]: OmniSharp.MSBuild.ProjectManager
        Loading project: c:\Dotnet Core\NgWebApi\NgWebApi.csproj
[info]: OmniSharp.WorkspaceInitializer
        Configuration finished.
[info]: OmniSharp.Stdio.Host
        Omnisharp server running using Stdio at location 'c:\Dotnet Core\NgWebApi' on host 17188.
[warn]: OmniSharp.MSBuild.ProjectManager
        Failed to load project file 'c:\Dotnet Core\NgWebApi\NgWebApi.csproj'.
c:\Dotnet Core\NgWebApi\NgWebApi.csproj(1,1)
Microsoft.Build.Exceptions.InvalidProjectFileException: The SDK 'Microsoft.NET.Sdk.Web' specified could not be found.  c:\Dotnet Core\NgWebApi\NgWebApi.csproj
   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, Boolean throwOnFileNotExistsError)
   at Microsoft.Build.Evaluation.Evaluator`4.ExpandAndLoadImports(String directoryOfImportingFile, ProjectImportElement importElement)
   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)
   at Microsoft.Build.Evaluation.Project.ReevaluateIfNecessary(ILoggingService loggingServiceForEvaluation, ProjectLoadSettings loadSettings)
   at Microsoft.Build.Evaluation.Project.Initialize(IDictionary`2 globalProperties, String toolsVersion, String subToolsetVersion, ProjectLoadSettings loadSettings)
   at Microsoft.Build.Evaluation.Project..ctor(String projectFile, IDictionary`2 globalProperties, String toolsVersion, String subToolsetVersion, ProjectCollection projectCollection, ProjectLoadSettings loadSettings)
   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
        Attempted to update project that is not loaded: c:\Dotnet Core\NgWebApi\NgWebApi.csproj


Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:23

github_iconTop GitHub Comments

24reactions
PaoloLaurenticommented, Oct 14, 2019

I use this workaraound (thanks to @gpad tips) setting MSBuildSDKsPath, DOTNET_ROOT and PATH environment variables before opening VSCode.
I use asdf to manage dotnet installation, I run this script (I put inside a function in my .zshrc) before running VSCode:

function set-dotnet-vars {
  DOTNET_BASE=$(dotnet --info | grep "Base Path" | awk '{print $3}')
  echo "DOTNET_BASE: ${DOTNET_BASE}"
  
  DOTNET_ROOT=$(echo $DOTNET_BASE | sed -E "s/^(.*)(\/sdk\/[^\/]+\/)$/\1/")
  echo "DOTNET_ROOT: ${DOTNET_ROOT}"
  
  export MSBuildSDKsPath=${DOTNET_BASE}Sdks/ 
  export DOTNET_ROOT=$DOTNET_ROOT
  export PATH=$DOTNET_ROOT:$PATH
}
9reactions
gloveboxescommented, Apr 9, 2019

As a quick workaround, you can also set the MSBuildSDKsPath environment variable and point to Sdks location.

On Linux (Ubuntu 18.04 in my case) I added following to my .bashrc

export MSBuildSDKsPath =“/usr/share/dotnet/sdk/2.2.202/Sdks”

On Windows Edit System Environment Variables and add a system variable MSBuildSDKsPath and set to C:\Program Files\dotnet\sdk\2.2.202\Sdks

Read more comments on GitHub >

github_iconTop Results From Across the Web

The SDK 'Microsoft.NET.Sdk.Web' specified could not be found
1 Answer · 1.Clean-up obsolete .NET Core versions: Go to Control Panel and uninstall previous . · 2.Create a Global.json file: Add a...
Read more >
.net core - Visual studio 2017 Update 3 - The SDK 'Microsoft ...
Net.Sdk.Web' specified could not be found, and leaving me unable to open the project in Visual Studio. The problem was the project was...
Read more >
The SDK 'Microsoft.Net.Sdk.Web' specified could not be found
This article describes how to fix "The SDK 'Microsoft.Net.Sdk.Web' specified could not be found" when creating ASP.NET Core 2.0 projects in ...
Read more >
The SDK 'Microsoft.NET.Sdk.Web' specified could not be found
Opening solution with couple of exe -projects (netcoreapp1.1). None of exe projects will load, getting error "The SDK 'Microsoft.NET.Sdk.Web' specified could ...
Read more >
Weird error MSB4236: The SDK 'Microsoft.NET.Sdk.Web ...
error MSB4236 : The SDK 'Microsoft.NET.Sdk.Web' specified could not be found. ... Though I was able to build and run these projects with...
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