vscode-csharp icon indicating copy to clipboard operation
vscode-csharp copied to clipboard

The SDK 'Microsoft.NET.Sdk.Web' specified could not be found

Open arsmn opened this issue 7 years ago • 45 comments

Environment data

dotnet --info output:

.NET Core SDK (reflecting any global.json): Version: 3.0.100-preview-010184 Commit: c57bde4593

Runtime Environment: OS Name: Windows OS Version: 10.0.17134 OS Platform: Windows RID: win10-x64 Base Path: C:\Program Files\dotnet\sdk\3.0.100-preview-010184\

Host (useful for support): Version: 3.0.0-preview-27324-5 Commit: 63a01b08e5

.NET Core SDKs installed: 3.0.100-preview-010184 [C:\Program Files\dotnet\sdk]

.NET Core runtimes installed: Microsoft.AspNetCore.All 2.1.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.App 2.1.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 3.0.0-preview-19075-0444 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 2.1.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 3.0.0-preview-27324-5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.WindowsDesktop.App 3.0.0-preview-27325-3 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

VS Code version:

Version: 1.31.1 (user setup) Commit: 1b8e8302e405050205e69b59abb3559592bb9e60 Date: 2019-02-12T02:20:54.427Z Electron: 3.1.2 Chrome: 66.0.3359.181 Node.js: 10.2.0 V8: 6.6.346.32 OS: Windows_NT x64 10.0.17134

C# Extension version:

1.18.0-beta7

Steps to reproduce

  1. Install latest dotnet core version: 3.0.100-preview-010184
  2. Install latest C# extension release: 1.18.0-beta7
  3. Create new dotnet webapi project
  4. Launch VSCode

Output

Microsoft.Build.Exceptions.InvalidProjectFileException: The SDK 'Microsoft.NET.Sdk.Web' specified could not be found. c:\Users\Alireza\Documents\Test\core3\core3.csproj at Microsoft.Build.Shared.ProjectErrorUtilities.ThrowInvalidProject(String errorSubCategoryResourceName, IElementLocation elementLocation, String resourceName, Object[] args) at Microsoft.Build.Evaluation.Evaluator4.ExpandAndLoadImportsFromUnescapedImportExpressionConditioned(String directoryOfImportingFile, ProjectImportElement importElement, List1& projects, Boolean throwOnFileNotExistsError) at Microsoft.Build.Evaluation.Evaluator4.ExpandAndLoadImports(String directoryOfImportingFile, ProjectImportElement importElement) at Microsoft.Build.Evaluation.Evaluator4.EvaluateImportElement(String directoryOfImportingFile, ProjectImportElement importElement) at Microsoft.Build.Evaluation.Evaluator4.PerformDepthFirstPass(ProjectRootElement currentProjectOrImport) at Microsoft.Build.Evaluation.Evaluator4.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(IDictionary2 globalProperties, String toolsVersion, String subToolsetVersion, ProjectLoadSettings loadSettings) at Microsoft.Build.Evaluation.Project..ctor(String projectFile, IDictionary2 globalProperties, String toolsVersion, String subToolsetVersion, ProjectCollection projectCollection, ProjectLoadSettings loadSettings) at Microsoft.Build.Evaluation.ProjectCollection.LoadProject(String fileName, IDictionary2 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, Func1 loader)

arsmn avatar Feb 27 '19 07:02 arsmn

@Arsmn1996 Can you try installing .Net Core Build Tools as described here

akshita31 avatar Feb 28 '19 02:02 akshita31

This is happening to me as well with 3.0 preview2 .NET Core SDK for OSX...

Searching SDK directory in [/usr/local/share/dotnet]
--- Resolving SDK version from SDK dir [/usr/local/share/dotnet/sdk]
Considering version... [2.0.0-preview1-005685]
Considering version... [2.0.0-preview2-006497]
Considering version... [2.1.302]
Considering version... [3.0.100-preview-010184]
Considering version... [NuGetFallbackFolder]
Checking if resolved SDK dir [/usr/local/share/dotnet/sdk/3.0.100-preview-010184] exists
Resolved SDK dir is [/usr/local/share/dotnet/sdk/3.0.100-preview-010184]
Found CLI SDK in: /usr/local/share/dotnet/sdk/3.0.100-preview-010184
[warn]: OmniSharp.MSBuild.ProjectManager
        Failed to load project file '/Users/santifdezm/repos/ApplyNullableFromJetBrains/ApplyNullableFromJetBrains.csproj'.
/Users/santifdezm/repos/ApplyNullableFromJetBrains/ApplyNullableFromJetBrains.csproj(1,1)
Microsoft.Build.Exceptions.InvalidProjectFileException: The SDK 'Microsoft.NET.Sdk' specified could not be found.  /Users/santifdezm/repos/ApplyNullableFromJetBrains/ApplyNullableFromJetBrains.csproj
  at Microsoft.Build.Shared.ProjectErrorUtilities.ThrowInvalidProject (System.String errorSubCategoryResourceName, Microsoft.Build.Shared.IElementLocation elementLocation, System.String resourceName, System.Object[] args) [0x00040] in <2338fdb301034c1d9c6b95e564d514b0>: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 <2338fdb301034c1d9c6b95e564d514b0>:0 
  at Microsoft.Build.Shared.ProjectErrorUtilities.ThrowInvalidProject[T1] (Microsoft.Build.Shared.IElementLocation elementLocation, System.String resourceName, T1 arg0) [0x00000] in <2338fdb301034c1d9c6b95e564d514b0>:0 
  at Microsoft.Build.Evaluation.Evaluator`4[P,I,M,D].ExpandAndLoadImportsFromUnescapedImportExpressionConditioned (System.String directoryOfImportingFile, Microsoft.Build.Construction.ProjectImportElement importElement, System.Collections.Generic.List`1[Microsoft.Build.Construction.ProjectRootElement]& projects, System.Boolean throwOnFileNotExistsError) [0x00254] in <2338fdb301034c1d9c6b95e564d514b0>:0 
  at Microsoft.Build.Evaluation.Evaluator`4[P,I,M,D].ExpandAndLoadImports (System.String directoryOfImportingFile, Microsoft.Build.Construction.ProjectImportElement importElement) [0x00024] in <2338fdb301034c1d9c6b95e564d514b0>:0 
  at Microsoft.Build.Evaluation.Evaluator`4[P,I,M,D].EvaluateImportElement (System.String directoryOfImportingFile, Microsoft.Build.Construction.ProjectImportElement importElement) [0x0000d] in <2338fdb301034c1d9c6b95e564d514b0>:0 
  at Microsoft.Build.Evaluation.Evaluator`4[P,I,M,D].PerformDepthFirstPass (Microsoft.Build.Construction.ProjectRootElement currentProjectOrImport) [0x000e6] in <2338fdb301034c1d9c6b95e564d514b0>:0 
  at Microsoft.Build.Evaluation.Evaluator`4[P,I,M,D].Evaluate (Microsoft.Build.BackEnd.Logging.ILoggingService loggingService, Microsoft.Build.Framework.BuildEventContext buildEventContext) [0x00103] in <2338fdb301034c1d9c6b95e564d514b0>:0 
  at Microsoft.Build.Evaluation.Evaluator`4[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.PropertyDictionary`1[T] environmentProperties, Microsoft.Build.BackEnd.Logging.ILoggingService loggingService, Microsoft.Build.Evaluation.IItemFactory`2[S,T] itemFactory, Microsoft.Build.Evaluation.IToolsetProvider toolsetProvider, Microsoft.Build.Evaluation.ProjectRootElementCache projectRootElementCache, Microsoft.Build.Framework.BuildEventContext buildEventContext, Microsoft.Build.Execution.ProjectInstance projectInstanceIfAnyForDebuggerOnly, Microsoft.Build.BackEnd.SdkResolution.ISdkResolverService sdkResolverService, System.Int32 submissionId, Microsoft.Build.Evaluation.Context.EvaluationContext evaluationContext) [0x0001a] in <2338fdb301034c1d9c6b95e564d514b0>:0 
  at Microsoft.Build.Evaluation.Project.Reevaluate (Microsoft.Build.BackEnd.Logging.ILoggingService loggingServiceForEvaluation, Microsoft.Build.Evaluation.ProjectLoadSettings loadSettings) [0x0004c] in <2338fdb301034c1d9c6b95e564d514b0>:0 
  at Microsoft.Build.Evaluation.Project.ReevaluateIfNecessary (Microsoft.Build.BackEnd.Logging.ILoggingService loggingServiceForEvaluation, Microsoft.Build.Evaluation.ProjectLoadSettings loadSettings) [0x00034] in <2338fdb301034c1d9c6b95e564d514b0>:0 
  at Microsoft.Build.Evaluation.Project.ReevaluateIfNecessary (Microsoft.Build.BackEnd.Logging.ILoggingService loggingServiceForEvaluation) [0x00000] in <2338fdb301034c1d9c6b95e564d514b0>:0 
  at Microsoft.Build.Evaluation.Project.ReevaluateIfNecessary (Microsoft.Build.Evaluation.Context.EvaluationContext evaluationContext) [0x00023] in <2338fdb301034c1d9c6b95e564d514b0>:0 
  at Microsoft.Build.Evaluation.Project.Initialize (System.Collections.Generic.IDictionary`2[TKey,TValue] globalProperties, System.String toolsVersion, System.String subToolsetVersion, Microsoft.Build.Evaluation.ProjectLoadSettings loadSettings, Microsoft.Build.Evaluation.Context.EvaluationContext evaluationContext) [0x00126] in <2338fdb301034c1d9c6b95e564d514b0>: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) [0x0009e] in <2338fdb301034c1d9c6b95e564d514b0>: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) [0x00000] in <2338fdb301034c1d9c6b95e564d514b0>: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 <2338fdb301034c1d9c6b95e564d514b0>: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) [0x00000] in <2338fdb301034c1d9c6b95e564d514b0>:0 
  at Microsoft.Build.Evaluation.ProjectCollection.LoadProject (System.String fileName, System.Collections.Generic.IDictionary`2[TKey,TValue] globalProperties, System.String toolsVersion) [0x000f5] in <2338fdb301034c1d9c6b95e564d514b0>:0 
  at Microsoft.Build.Evaluation.ProjectCollection.LoadProject (System.String fileName, System.String toolsVersion) [0x00000] in <2338fdb301034c1d9c6b95e564d514b0>:0 
  at OmniSharp.MSBuild.ProjectLoader.EvaluateProjectFileCore (System.String filePath) [0x0003f] in <46c04c65986d41159ea03c6835eb767f>:0 
  at OmniSharp.MSBuild.ProjectLoader.BuildProject (System.String filePath) [0x0000d] in <46c04c65986d41159ea03c6835eb767f>:0 
  at OmniSharp.MSBuild.ProjectFile.ProjectFileInfo.Load (System.String filePath, OmniSharp.MSBuild.ProjectLoader loader) [0x00015] in <46c04c65986d41159ea03c6835eb767f>:0 
  at OmniSharp.MSBuild.ProjectManager+<>c__DisplayClass25_0.<LoadProject>b__0 () [0x00000] in <46c04c65986d41159ea03c6835eb767f>:0 
  at (wrapper delegate-invoke) System.Func`1[System.ValueTuple`3[OmniSharp.MSBuild.ProjectFile.ProjectFileInfo,System.Collections.Immutable.ImmutableArray`1[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 <46c04c65986d41159ea03c6835eb767f>:0 

dotnet info output:

NET Core SDK (reflecting any global.json):
 Version:   3.0.100-preview-010184
 Commit:    c57bde4593

Runtime Environment:
 OS Name:     Mac OS X
 OS Version:  10.12
 OS Platform: Darwin
 RID:         osx.10.12-x64
 Base Path:   /usr/local/share/dotnet/sdk/3.0.100-preview-010184/

Host (useful for support):
  Version: 3.0.0-preview-27324-5
  Commit:  63a01b08e5

.NET Core SDKs installed:
  2.0.0-preview1-005685 [/usr/local/share/dotnet/sdk]
  2.0.0-preview2-006497 [/usr/local/share/dotnet/sdk]
  2.1.302 [/usr/local/share/dotnet/sdk]
  3.0.100-preview-010184 [/usr/local/share/dotnet/sdk]

However if I uninstall it and use the 2.1 SDK that I have installed works fine.

cc: @rainersigwald @DustinCampbell @nguerrera is this a SDK/CLI issue?

safern avatar Mar 01 '19 23:03 safern

@safern Thank you for that log!

We can see hostfxr picking the 3.0 SDK and then the resolver rejects it.

This is what I think is happening:

  1. $(MSBuildVersion) is < 16.0
  2. The SDK resolver dll being used is older than the version in VS 15.9+ that can pick the "latest compatible"
  3. The older resolver is rejecting 3.0 SDK returned by hostfxr because it has a minimumMSBuildVersion of 16.0
  4. MSBuild throws InvalidProjectFileException without printing the resolver error that would have been something like "Can't use 3.0 SDK because it needs MSBuild 16 and this is

I don't know the exact details on what determines which MSBuild and resolver that is used by Omnisharp. I think it probes for mono but also includes its own as a fallback? @rchande @DustinCampbell can you confirm?

nguerrera avatar Mar 01 '19 23:03 nguerrera

To confirm a piece of your theory, indeed MSBuild version that comes with Omnisharp is 15.0: Located 1 MSBuild instance(s) 1: StandAlone 15.0 - "/Users/santifdezm/.vscode/extensions/ms-vscode.csharp-1.17.1/.omnisharp/1.32.8/omnisharp/msbuild/15.0/Bin"

safern avatar Mar 01 '19 23:03 safern

At a minimum we need to put a 15.9+ resolver there. This would make 2.1.302 be used in repro above as it is latest compatible.

But we also need a path to msbuild 16 in omnisharp so folks can actually use 3.0.

These should probably be tracked as separate issues.

nguerrera avatar Mar 01 '19 23:03 nguerrera

@nguerrera I am not very clear on the resolver you are talking about here. Can you please eleborate on what are the changes that are needed in omnisharp ?

akshita31 avatar Mar 02 '19 02:03 akshita31

@nguerrera Awesome, thanks for the analysis!

rchande avatar Mar 05 '19 23:03 rchande

@akshita31 Looks like @rchande is on top of it, but the resolver in question is Microsoft.DotNet.MSBuildSdkResolver.dll described here: https://github.com/OmniSharp/omnisharp-vscode/issues/2604#issuecomment-430330103 and implemented here: https://github.com/dotnet/cli/tree/master/src/Microsoft.DotNet.MSBuildSdkResolver

nguerrera avatar Mar 05 '19 23:03 nguerrera

I confirm that the SDK version 2.2.202 has conflict with OmniSharp, tried to install Mono, set the environment variables,.. but no result. Switch back to the 2.2.105 everything is fine. So far so good, linting and intellisense are back, I hope to wait for an update or at least a solution.

tungp99 avatar Apr 06 '19 17:04 tungp99

I had this same problem with dotnet 2.1.602 -- downgrading to 2.1.500 worked for me as well. Thanks @nhactung for the suggestion!

For those on linux mint or ubuntu: sudo apt-get install dotnet-sdk-2.1=2.1.500-1

digital-abyss avatar Apr 07 '19 00:04 digital-abyss

I can confirm on my ubuntu 18.04 that version 2.2.202 causes issues with OmniSharp a downgrade to 2.2.105 "fixed" it so far. Does anybody has more information what happened, did I miss an update somewhere ?

sudo apt-get install dotnet-sdk-2.2=2.2.105-1

Dev-Owl avatar Apr 07 '19 14:04 Dev-Owl

@rchande This would be the same issue that causes problems for 3.0. 2.2.2xx also requires msbuild 16.

nguerrera avatar Apr 07 '19 14:04 nguerrera

Ditto for 2.1.6xx

nguerrera avatar Apr 07 '19 14:04 nguerrera

confirm that pinning dotnet core version to 2.2.105 fixes the issue.

sudo apt-get install dotnet-sdk-2.2=2.2.105-1

sada-kubsad avatar Apr 08 '19 03:04 sada-kubsad

Same here, works with 2.2.105-1

matthijsbreemans avatar Apr 08 '19 13:04 matthijsbreemans

Same here, works fine with 2.2.105-1

Thank you @nhactung for the suggestion and @digital-abyss for the command to copy / paste

frederic-prusse avatar Apr 08 '19 13:04 frederic-prusse

Many thanks for the suggestion to downgrade.

sudo apt-get install dotnet-sdk-2.2=2.2.105-1

Worked me for as well on Linux Mint 19.1

sprudel79 avatar Apr 09 '19 06:04 sprudel79

Let me know when omnisharp supports these new version :grinning:

ambs avatar Apr 09 '19 20:04 ambs

Latest OmniSharp beta as of now is 3.5.0-beta.2204 which seem to work with the latest .NET Core SDK.

Did this by setting "omnisharp.path": "latest" in VS Code's setting.json.

anarsen avatar Apr 11 '19 14:04 anarsen

Confirmed that downgraded worked with suggestions above.

hashharvest avatar Apr 11 '19 14:04 hashharvest