dotnet / vscode-csharp

Official C# support for Visual Studio Code
MIT License
2.86k stars 672 forks source link

Fails to load Blazor SDK with useModernNet set to true #5043

Closed AmdJaniga closed 2 years ago

AmdJaniga commented 2 years ago

Environment data

.NET SDK (reflecting any global.json): Version: 6.0.101 Commit: ef49f6213a

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

Host (useful for support): Version: 6.0.1 Commit: 3a25a7f1cc

.NET SDKs installed: 3.1.300 [C:\Program Files\dotnet\sdk] 6.0.101 [C:\Program Files\dotnet\sdk]

.NET runtimes installed: Microsoft.AspNetCore.All 2.1.18 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.18 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.1.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 6.0.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.1.18 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 3.1.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 6.0.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.WindowsDesktop.App 3.1.4 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 6.0.1 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

To install additional .NET runtimes or SDKs: https://aka.ms/dotnet-download PS C:\Users\User\source\repos\proto-apex-ui>

VS Code version: 1.64.0

C# Extension version:

1.24.0

OmniSharp log

Starting OmniSharp server at 2/7/2022, 5:33:41 PM Target: c:\Users\User\source\repos\proto-apex-ui

OmniSharp server started with .NET 6.0.101 (C:\Program Files\dotnet\sdk\6.0.101). Path: c:\Users\User.vscode\extensions\ms-dotnettools.csharp-1.24.0.omnisharp\1.38.1-beta.65-net6.0\OmniSharp.dll PID: 50036

    Assembly loaded: OmniSharp.DotNetTest
    Loaded OmniSharp.DotNetTest, Version=1.38.0.0, Culture=neutral, PublicKeyToken=7e5bf7b3b470b509
    Assembly loaded: OmniSharp.Host
    Loaded OmniSharp.Host, Version=1.38.0.0, Culture=neutral, PublicKeyToken=7e5bf7b3b470b509
    Assembly loaded: OmniSharp.MSBuild
    Loaded OmniSharp.MSBuild, Version=1.38.0.0, Culture=neutral, PublicKeyToken=7e5bf7b3b470b509
    Assembly loaded: OmniSharp.Roslyn
    Loaded OmniSharp.Roslyn, Version=1.38.0.0, Culture=neutral, PublicKeyToken=7e5bf7b3b470b509
    Assembly loaded: OmniSharp.Roslyn.CSharp
    Loaded OmniSharp.Roslyn.CSharp, Version=1.38.0.0, Culture=neutral, PublicKeyToken=7e5bf7b3b470b509
    Assembly loaded: OmniSharp.Script
    Loaded OmniSharp.Script, Version=1.38.0.0, Culture=neutral, PublicKeyToken=7e5bf7b3b470b509
    Assembly loaded: OmniSharp.Shared
    Loaded OmniSharp.Shared, Version=1.38.0.0, Culture=neutral, PublicKeyToken=7e5bf7b3b470b509
    Assembly loaded from path: c:\Users\User\.vscode\extensions\ms-dotnettools.csharp-1.24.0\.razor\OmniSharpPlugin\Microsoft.AspNetCore.Razor.OmniSharpPlugin.dll
    Starting OmniSharp on Windows 10.0.19042.0 (x64)
    Checking the 'DOTNET_ROOT' environment variable to find a .NET SDK
    Using the 'dotnet' on the PATH.
    DotNetPath set to dotnet
    .NET SDK requires MSBuild instances version 16.3 or higher
    Located 1 MSBuild instance(s)
        1: .NET Core SDK 6.0.101 17.0.0 - "C:\Program Files\dotnet\sdk\6.0.101\"
    MSBuild instance .NET Core SDK 6.0.101 17.0.0 scored at -2147483648
    Registered MSBuild instance: .NET Core SDK 6.0.101 17.0.0 - "C:\Program Files\dotnet\sdk\6.0.101\"
    Assembly loaded: Microsoft.CodeAnalysis.Features, Version=4.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
    Assembly loaded: Microsoft.CodeAnalysis.CSharp.Features, Version=4.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
    Assembly loaded: Microsoft.CodeAnalysis.ExternalAccess.OmniSharp, Version=4.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
    Assembly loaded: Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.CSharp, Version=4.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
    Successfully added Microsoft.CodeAnalysis.Features, Version=4.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 to host service assemblies.
    Successfully added Microsoft.CodeAnalysis.CSharp.Features, Version=4.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 to host service assemblies.
    Successfully added Microsoft.CodeAnalysis.ExternalAccess.OmniSharp, Version=4.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 to host service assemblies.
    Successfully added Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.CSharp, Version=4.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 to host service assemblies.
    Successfully added Microsoft.AspNetCore.Razor.OmniSharpPlugin.StrongNamed, Version=6.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60 to host service assemblies.
    Starting with OmniSharp options: {"RoslynExtensionsOptions":{"EnableDecompilationSupport":false,"EnableAnalyzersSupport":false,"EnableImportCompletion":false,"EnableAsyncCompletion":false,"DocumentAnalysisTimeoutMs":30000,"DiagnosticWorkersThreadCount":48,"LocationPaths":null},"FormattingOptions":{"OrganizeImports":false,"EnableEditorConfigSupport":true,"NewLine":"\n","UseTabs":false,"TabSize":4,"IndentationSize":4,"SpacingAfterMethodDeclarationName":false,"SpaceWithinMethodDeclarationParenthesis":false,"SpaceBetweenEmptyMethodDeclarationParentheses":false,"SpaceAfterMethodCallName":false,"SpaceWithinMethodCallParentheses":false,"SpaceBetweenEmptyMethodCallParentheses":false,"SpaceAfterControlFlowStatementKeyword":true,"SpaceWithinExpressionParentheses":false,"SpaceWithinCastParentheses":false,"SpaceWithinOtherParentheses":false,"SpaceAfterCast":false,"SpacesIgnoreAroundVariableDeclaration":false,"SpaceBeforeOpenSquareBracket":false,"SpaceBetweenEmptySquareBrackets":false,"SpaceWithinSquareBrackets":false,"SpaceAfterColonInBaseTypeDeclaration":true,"SpaceAfterComma":true,"SpaceAfterDot":false,"SpaceAfterSemicolonsInForStatement":true,"SpaceBeforeColonInBaseTypeDeclaration":true,"SpaceBeforeComma":false,"SpaceBeforeDot":false,"SpaceBeforeSemicolonsInForStatement":false,"SpacingAroundBinaryOperator":"single","IndentBraces":false,"IndentBlock":true,"IndentSwitchSection":true,"IndentSwitchCaseSection":true,"IndentSwitchCaseSectionWhenBlock":true,"LabelPositioning":"oneLess","WrappingPreserveSingleLine":true,"WrappingKeepStatementsOnSingleLine":true,"NewLinesForBracesInTypes":true,"NewLinesForBracesInMethods":true,"NewLinesForBracesInProperties":true,"NewLinesForBracesInAccessors":true,"NewLinesForBracesInAnonymousMethods":true,"NewLinesForBracesInControlBlocks":true,"NewLinesForBracesInAnonymousTypes":true,"NewLinesForBracesInObjectCollectionArrayInitializers":true,"NewLinesForBracesInLambdaExpressionBody":true,"NewLineForElse":true,"NewLineForCatch":true,"NewLineForFinally":true,"NewLineForMembersInObjectInit":true,"NewLineForMembersInAnonymousTypes":true,"NewLineForClausesInQuery":true},"FileOptions":{"SystemExcludeSearchPatterns":["**/node_modules/**/*","**/bin/**/*","**/obj/**/*","**/.git/**/*","**/.git","**/.svn","**/.hg","**/CVS","**/.DS_Store","**/Thumbs.db"],"ExcludeSearchPatterns":[]},"RenameOptions":{"RenameOverloads":false,"RenameInStrings":false,"RenameInComments":false},"ImplementTypeOptions":{"InsertionBehavior":null,"PropertyGenerationBehavior":null},"DotNetCliOptions":{"LocationPaths":null},"Plugins":{"LocationPaths":null}}
    Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.CSharpFormattingWorkspaceOptionsProvider, Order: 0
    Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.ImplementTypeWorkspaceOptionsProvider, Order: 110
    MSBuild environment: 

Mode: Standalone RunningTests: False RunningInVisualStudio: False MSBuildToolsDirectory32: C:\Program Files\dotnet\sdk\6.0.101 MSBuildToolsDirectory64: C:\Program Files\dotnet\sdk\6.0.101 MSBuildSDKsPath: C:\Program Files\dotnet\sdk\6.0.101\ CurrentMSBuildConfigurationFile: C:\Program Files\dotnet\sdk\6.0.101\MSBuild.dll.config CurrentMSBuildExePath: C:\Program Files\dotnet\sdk\6.0.101\MSBuild.dll CurrentMSBuildToolsDirectory: C:\Program Files\dotnet\sdk\6.0.101 VisualStudioInstallRootDirectory: MSBuildExtensionsPath: C:\Program Files\dotnet\sdk\6.0.101

    No solution files found in 'c:\Users\User\source\repos\proto-apex-ui'
    Queue project update for 'c:\Users\User\source\repos\proto-apex-ui\src\proto-apex-ui.csproj'
    Detecting CSX files in 'c:\Users\User\source\repos\proto-apex-ui'.
    Did not find any CSX files
    Configuration finished.
    Omnisharp server running using Stdio at location 'c:\Users\User\source\repos\proto-apex-ui' on host 47032.
    ************ Request ************

{ "Type": "request", "Seq": 1, "Command": "/projects" }

    ************ Request ************

{ "Type": "request", "Seq": 2, "Command": "/projects" }

    Loading project: c:\Users\User\source\repos\proto-apex-ui\src\proto-apex-ui.csproj
    The SDK 'Microsoft.NET.Sdk.BlazorWebAssembly' specified could not be found.
    Failed to load project file 'c:\Users\User\source\repos\proto-apex-ui\src\proto-apex-ui.csproj'.

Microsoft.Build.Exceptions.InvalidProjectFileException: The SDK 'Microsoft.NET.Sdk.BlazorWebAssembly' specified could not be found. c:\Users\User\source\repos\proto-apex-ui\src\proto-apex-ui.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, SdkResult& sdkResult, Boolean throwOnFileNotExistsError) at Microsoft.Build.Evaluation.Evaluator4.ExpandAndLoadImports(String directoryOfImportingFile, ProjectImportElement importElement, SdkResult& sdkResult) at Microsoft.Build.Evaluation.Evaluator4.EvaluateImportElement(String directoryOfImportingFile, ProjectImportElement importElement) at Microsoft.Build.Evaluation.Evaluator4.PerformDepthFirstPass(ProjectRootElement currentProjectOrImport) at Microsoft.Build.Evaluation.Evaluator4.Evaluate() at Microsoft.Build.Evaluation.Evaluator4.Evaluate(IEvaluatorData4 data, ProjectRootElement root, ProjectLoadSettings loadSettings, Int32 maxNodeCount, PropertyDictionary1 environmentProperties, ILoggingService loggingService, IItemFactory2 itemFactory, IToolsetProvider toolsetProvider, ProjectRootElementCacheBase projectRootElementCache, BuildEventContext buildEventContext, ISdkResolverService sdkResolverService, Int32 submissionId, EvaluationContext evaluationContext, Boolean interactive) at Microsoft.Build.Evaluation.Project.ProjectImpl.Reevaluate(ILoggingService loggingServiceForEvaluation, ProjectLoadSettings loadSettings, EvaluationContext evaluationContext) at Microsoft.Build.Evaluation.Project.ProjectImpl.ReevaluateIfNecessary(ILoggingService loggingServiceForEvaluation, ProjectLoadSettings loadSettings, EvaluationContext evaluationContext) at Microsoft.Build.Evaluation.Project.ProjectImpl.ReevaluateIfNecessary(EvaluationContext evaluationContext) at Microsoft.Build.Evaluation.Project.ProjectImpl.Initialize(IDictionary2 globalProperties, String toolsVersion, String subToolsetVersion, ProjectLoadSettings loadSettings, EvaluationContext evaluationContext) at Microsoft.Build.Evaluation.Project..ctor(String projectFile, IDictionary2 globalProperties, String toolsVersion, String subToolsetVersion, ProjectCollection projectCollection, ProjectLoadSettings loadSettings, EvaluationContext evaluationContext) at Microsoft.Build.Evaluation.ProjectCollection.LoadProject(String fileName, IDictionary2 globalProperties, String toolsVersion) at Microsoft.Build.Evaluation.ProjectCollection.LoadProject(String fileName, String toolsVersion) at OmniSharp.MSBuild.ProjectLoader.EvaluateProjectFileCore(String filePath, IReadOnlyDictionary2 projectConfigurationsInSolution, IList1 loggers) in D:\a\1\s\src\OmniSharp.MSBuild\ProjectLoader.cs:line 162 at OmniSharp.MSBuild.ProjectLoader.BuildProject(String filePath, IReadOnlyDictionary2 configurationsInSolution) in D:\a\1\s\src\OmniSharp.MSBuild\ProjectLoader.cs:line 84 at OmniSharp.MSBuild.ProjectFile.ProjectFileInfo.Load(String filePath, ProjectIdInfo projectIdInfo, ProjectLoader loader, Guid sessionId, DotNetInfo dotNetInfo) in D:\a\1\s\src\OmniSharp.MSBuild\ProjectFile\ProjectFileInfo.cs:line 117 at OmniSharp.MSBuild.ProjectManager.<>cDisplayClass32_0.b0() in D:\a\1\s\src\OmniSharp.MSBuild\ProjectManager.cs:line 305 at OmniSharp.MSBuild.ProjectManager.LoadOrReloadProject(String projectFilePath, Func1 loader) in D:\a\1\s\src\OmniSharp.MSBuild\ProjectManager.cs:line 316 c:\Users\User\source\repos\proto-apex-ui\src\proto-apex-ui.csproj(0,0) Microsoft.Build.Exceptions.InvalidProjectFileException: The SDK 'Microsoft.NET.Sdk.BlazorWebAssembly' specified could not be found. c:\Users\User\source\repos\proto-apex-ui\src\proto-apex-ui.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, SdkResult& sdkResult, Boolean throwOnFileNotExistsError) at Microsoft.Build.Evaluation.Evaluator4.ExpandAndLoadImports(String directoryOfImportingFile, ProjectImportElement importElement, SdkResult& sdkResult) at Microsoft.Build.Evaluation.Evaluator4.EvaluateImportElement(String directoryOfImportingFile, ProjectImportElement importElement) at Microsoft.Build.Evaluation.Evaluator4.PerformDepthFirstPass(ProjectRootElement currentProjectOrImport) at Microsoft.Build.Evaluation.Evaluator4.Evaluate() at Microsoft.Build.Evaluation.Evaluator4.Evaluate(IEvaluatorData4 data, ProjectRootElement root, ProjectLoadSettings loadSettings, Int32 maxNodeCount, PropertyDictionary1 environmentProperties, ILoggingService loggingService, IItemFactory2 itemFactory, IToolsetProvider toolsetProvider, ProjectRootElementCacheBase projectRootElementCache, BuildEventContext buildEventContext, ISdkResolverService sdkResolverService, Int32 submissionId, EvaluationContext evaluationContext, Boolean interactive) at Microsoft.Build.Evaluation.Project.ProjectImpl.Reevaluate(ILoggingService loggingServiceForEvaluation, ProjectLoadSettings loadSettings, EvaluationContext evaluationContext) at Microsoft.Build.Evaluation.Project.ProjectImpl.ReevaluateIfNecessary(ILoggingService loggingServiceForEvaluation, ProjectLoadSettings loadSettings, EvaluationContext evaluationContext) at Microsoft.Build.Evaluation.Project.ProjectImpl.ReevaluateIfNecessary(EvaluationContext evaluationContext) at Microsoft.Build.Evaluation.Project.ProjectImpl.Initialize(IDictionary2 globalProperties, String toolsVersion, String subToolsetVersion, ProjectLoadSettings loadSettings, EvaluationContext evaluationContext) at Microsoft.Build.Evaluation.Project..ctor(String projectFile, IDictionary2 globalProperties, String toolsVersion, String subToolsetVersion, ProjectCollection projectCollection, ProjectLoadSettings loadSettings, EvaluationContext evaluationContext) at Microsoft.Build.Evaluation.ProjectCollection.LoadProject(String fileName, IDictionary2 globalProperties, String toolsVersion) at Microsoft.Build.Evaluation.ProjectCollection.LoadProject(String fileName, String toolsVersion) at OmniSharp.MSBuild.ProjectLoader.EvaluateProjectFileCore(String filePath, IReadOnlyDictionary2 projectConfigurationsInSolution, IList1 loggers) in D:\a\1\s\src\OmniSharp.MSBuild\ProjectLoader.cs:line 162 at OmniSharp.MSBuild.ProjectLoader.BuildProject(String filePath, IReadOnlyDictionary`2 configurationsInSolution) in D:\a\1\s\src\OmniSharp.MSBuild\ProjectLoader.cs:line 84 at OmniSharp.MSBuild.ProjectFile.ProjectFileInfo.Load(String filePath, ProjectIdInfo projectIdInfo, ProjectLoader loader, Guid sessionId, DotNetInfo dotNetInfo) in D:\a\1\s\src\OmniSharp.MSBuild\ProjectFile\ProjectFileInfo.cs:line 117 at OmniSharp.MSBuild.ProjectManager.<>cDisplayClass32_0.b0() in D:\a\1\s\src\OmniSharp.MSBuild\ProjectManager.cs:line 305 at OmniSharp.MSBuild.ProjectManager.LoadOrReloadProject(String projectFilePath, Func`1 loader) in D:\a\1\s\src\OmniSharp.MSBuild\ProjectManager.cs:line 316

    Attempted to update project that is not loaded: c:\Users\User\source\repos\proto-apex-ui\src\proto-apex-ui.csproj
    ************  Response (222.9960ms) ************ 

{ "Request_seq": 1, "Command": "/projects", "Running": true, "Success": true, "Message": null, "Body": { "MsBuild": { "SolutionPath": "c:\Users\User\source\repos\proto-apex-ui", "Projects": [] }, "Script": { "Projects": [] } }, "Seq": 46, "Type": "response" }

Steps to reproduce

Omnisharp settings: "omnisharp.useModernNet": true, "omnisharp.dotnetPath": "C:\Program Files\dotnet\sdk\6.0.101", "omnisharp.path": "latest", "omnisharp.loggingLevel": "trace"

Expected behavior

No error messages; successful load

Actual behavior

Doesn't seem to be able to find the Blazor SDK. However, the dotnet path seems alright...

JoeRobich commented 2 years ago

@AmdJaniga There should be no reason to set the "omnisharp.dotnetPath" unless your dotnet folder hasn't been added to the PATH environment variable. Try editing your PATH environment variable. Remove C:\Program Files (x86)\dotnet\ if preset and ensure C:\Program Files\dotnet\ is included.

AmdJaniga commented 2 years ago

Thanks Joe.

Removed it, however, same result so far.

Updated FIle: image

Log:

   The SDK 'Microsoft.NET.Sdk.BlazorWebAssembly' specified could not be found.
   Failed to load project file 'c:\Users\User\source\repos\proto-apex-ui\src\proto-apex-ui.csproj'.

Microsoft.Build.Exceptions.InvalidProjectFileException: The SDK 'Microsoft.NET.Sdk.BlazorWebAssembly' specified could not be found.

Frankly, I'm not sure if this is an omnisharp issue or not. As a shot in the dark I tried to run dotnet watch --project src/proto-apex-ui.csproj in the powershell terminal in VSCode. I got the same error.

image

What I'm confused with is that it builds just find in a PowerShell terminal outside of VSCode.

image

I'm obviously not the most .net experienced person and I appreciate the help.

How do I go about dumping the build env in each location to determine what is different?

JoeRobich commented 2 years ago

The first thing to try is going into Add / Remove programs and performing a repair on your .NET 6 SDK install. If there are still issues you can dump the environment path variable with powershell by invoking echo $env:PATH. It might also be interesting to see the output of dotnet --info from the different environments.

AmdJaniga commented 2 years ago

Okay... still having the issue and my PATH and dotnet --info are identical despite they behave differently.

image

JoeRobich commented 2 years ago

@AmdJaniga I see the Windows PowerShell is running as Administrator. Does dotnet watch find the SDK when not running an admin shell?

AmdJaniga commented 2 years ago

Great catch!

That's it, fails when not running as an administrator.

AmdJaniga commented 2 years ago

Any idea where I should take this observation? Doesn't seem to be an issue with omnisharp...

JoeRobich commented 2 years ago

@AmdJaniga It might be simplest to uninstall and reinstall the .NET 6 sdk. Ensuring your user isn't elevated prior to running the installer.

AmdJaniga commented 2 years ago

Thanks, makes sense. I'll close this issue.

AmdJaniga commented 2 years ago

And thanks for your help!