dotnet / vscode-csharp

Official C# support for Visual Studio Code
MIT License
2.88k stars 676 forks source link

Errors when running .net generate assets to build .vscode folder #4542

Open guardrex opened 3 years ago

guardrex commented 3 years ago

Issue Description

For a hosted Blazor WebAssembly solution folder or Server project folder of the solution:

Other issues:

cc: @captainsafia

Cross-reference ASP.NET Core docs issue that I'm working that pertains to this process: https://github.com/dotnet/AspNetCore.Docs/issues/22234

Steps to Reproduce

  1. Create a hosted Blazor WebAssembly solution (dotnet new blazorwasm -ho).
  2. Open the solution's folder (or the Server project folder). The extension doesn't offer to add the build and debug assets.
  3. Attempt manual add of the assets with: View > Command Palette followed by .NET: Generate Assets for Build and Debug.
  4. Notification appears:

    Could not locate .NET Core project. Assets were not generated.

The notification appears either trying to add the assets to the solution's folder or the Server project's folder.

Expected Behavior

.vscode folder with launch.json and tasks.json, possibly with a prompt to add for the Server project if the solution's folder is opened in VSC.

Actual Behavior

Error when attempting manual add:

Could not locate .NET Core project. Assets were not generated.

Logs

OmniSharp log

Starting OmniSharp server at 5/7/2021, 7:54:50 PM Target: c:\Users\XXXXX\Desktop\BlazorWebAssemblySignalRApp\Server

OmniSharp server started. Path: c:\Users\XXXXX.vscode\extensions\ms-dotnettools.csharp-1.23.11.omnisharp\1.37.8\OmniSharp.exe PID: 6856

    Loaded OmniSharp.Cake, Version=1.37.0.0, Culture=neutral, PublicKeyToken=null
    Loaded OmniSharp.DotNetTest, Version=1.37.0.0, Culture=neutral, PublicKeyToken=null
    Loaded OmniSharp.Host, Version=1.37.0.0, Culture=neutral, PublicKeyToken=null
    Loaded OmniSharp.MSBuild, Version=1.37.0.0, Culture=neutral, PublicKeyToken=null
    Loaded OmniSharp.Roslyn, Version=1.37.0.0, Culture=neutral, PublicKeyToken=null
    Loaded OmniSharp.Roslyn.CSharp, Version=1.37.0.0, Culture=neutral, PublicKeyToken=null
    Loaded OmniSharp.Script, Version=1.37.0.0, Culture=neutral, PublicKeyToken=null
    Loaded OmniSharp.Shared, Version=1.37.0.0, Culture=neutral, PublicKeyToken=null
    Starting OmniSharp on Windows 6.2.9200.0 (x64)
    DotNetPath set to dotnet
    .NET SDK requires MSBuild instances version 16.3 or higher
    Located 2 MSBuild instance(s)
        1: Visual Studio Enterprise 2019 16.9.31205.134 - "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin"
        2: StandAlone 16.9.0 - "c:\Users\XXXXX\.vscode\extensions\ms-dotnettools.csharp-1.23.11\.omnisharp\1.37.8\.msbuild\Current\Bin"
    MSBuild instance Visual Studio Enterprise 2019 16.9.31205.134 scored at 2
    MSBuild instance StandAlone 16.9.0 scored at 1
    SUCCESS: Resolved to 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\Microsoft.Build.Utilities.Core.dll' (name-only).
    SUCCESS: Resolved to 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\Microsoft.Build.Tasks.Core.dll' (name-only).
    SUCCESS: Resolved to 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\Microsoft.Build.dll' (name-only).
    SUCCESS: Resolved to 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\Microsoft.Build.Framework.dll' (name-only).
    Registered MSBuild instance: Visual Studio Enterprise 2019 16.9.31205.134 - "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin"
    Attempting to resolve 'Microsoft.Build.Utilities.Core, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
    SUCCESS: Resolved to 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\Microsoft.Build.Utilities.Core.dll' (name-only).
    Attempting to resolve 'Microsoft.Build.Framework, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
    SUCCESS: Resolved to 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\Microsoft.Build.Framework.dll' (name-only).
    Attempting to resolve 'Microsoft.Build, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
    SUCCESS: Resolved to 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\Microsoft.Build.dll' (name-only).
    Attempting to resolve 'Microsoft.CodeAnalysis.VisualBasic.Workspaces, Version=3.10.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
    FAILURE: Could not locate 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\Microsoft.CodeAnalysis.VisualBasic.Workspaces.dll'.
    Attempting to resolve 'Microsoft.CodeAnalysis.VisualBasic.Features, Version=3.10.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
    FAILURE: Could not locate 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\Microsoft.CodeAnalysis.VisualBasic.Features.dll'.
    Starting with OmniSharp options: {"RoslynExtensionsOptions":{"EnableDecompilationSupport":false,"EnableAnalyzersSupport":false,"EnableImportCompletion":false,"DocumentAnalysisTimeoutMs":10000,"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"],"ExcludeSearchPatterns":[]},"RenameOptions":{"RenameOverloads":false,"RenameInStrings":false,"RenameInComments":false},"ImplementTypeOptions":{"InsertionBehavior":null,"PropertyGenerationBehavior":null},"Plugins":{"LocationPaths":null}}
    Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.CSharpFormattingWorkspaceOptionsProvider, Order: 0
    Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.Completion.CompletionOptionsProvider, Order: 0
    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
    Detecting Cake files in 'c:\Users\XXXXX\Desktop\BlazorWebAssemblySignalRApp\Server'.
    Could not find any Cake files
    Attempting to resolve 'Microsoft.Build'
    SUCCESS: Resolved to 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\Microsoft.Build.dll' (name-only).
    MSBuild environment: 

Mode: VisualStudio RunningTests: False RunningInVisualStudio: False MSBuildToolsDirectory32: C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin MSBuildToolsDirectory64: C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\amd64 MSBuildSDKsPath: C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Sdks CurrentMSBuildConfigurationFile: C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\MSBuild.exe.config CurrentMSBuildExePath: C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\MSBuild.exe CurrentMSBuildToolsDirectory: C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin VisualStudioInstallRootDirectory: C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise MSBuildExtensionsPath: C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild

    Skip loading projects listed in solution file or under target directory because MsBuild:LoadProjectsOnDemand is true.
    Detecting CSX files in 'c:\Users\XXXXX\Desktop\BlazorWebAssemblySignalRApp\Server'.
    Could not find any CSX files
    Configuration finished.
    Omnisharp server running using Stdio at location 'c:\Users\XXXXX\Desktop\BlazorWebAssemblySignalRApp\Server' on host 14288.
    ************ Request ************

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

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

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

    ************  Response ************ 

{ "Request_seq": 6, "Command": "/projects", "Running": true, "Success": true, "Message": null, "Body": { "MsBuild": { "SolutionPath": null, "Projects": [] }, "Script": { "Projects": [] } }, "Seq": 49, "Type": "response" }

    ************  Response ************ 

{ "Request_seq": 5, "Command": "/projects", "Running": true, "Success": true, "Message": null, "Body": { "MsBuild": { "SolutionPath": null, "Projects": [] }, "Script": { "Projects": [] } }, "Seq": 50, "Type": "response" }

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

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

    ************  Response ************ 

{ "Request_seq": 7, "Command": "/projects", "Running": true, "Success": true, "Message": null, "Body": { "MsBuild": { "SolutionPath": null, "Projects": [] }, "Script": { "Projects": [] } }, "Seq": 54, "Type": "response" }

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

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

    ************  Response ************ 

{ "Request_seq": 8, "Command": "/projects", "Running": true, "Success": true, "Message": null, "Body": { "MsBuild": { "SolutionPath": null, "Projects": [] }, "Script": { "Projects": [] } }, "Seq": 57, "Type": "response" }

C# log

Post the output from Output-->C# here

Environment information

VSCode version: 1.56.0 C# Extension: 1.23.11

Dotnet Information .NET SDK (reflecting any global.json): Version: 5.0.202 Commit: db7cc87d51 Runtime Environment: OS Name: Windows OS Version: 10.0.19041 OS Platform: Windows RID: win10-x64 Base Path: C:\Program Files\dotnet\sdk\5.0.202\ Host (useful for support): Version: 5.0.5 Commit: 2f740adc14 .NET SDKs installed: 3.1.302 [C:\Program Files\dotnet\sdk] 5.0.202 [C:\Program Files\dotnet\sdk] .NET runtimes installed: Microsoft.AspNetCore.All 2.1.27 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.2.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.App 2.1.27 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.2.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 3.1.14 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 5.0.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 2.1.27 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.2.8 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 3.1.14 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 5.0.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.WindowsDesktop.App 3.1.14 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 5.0.5 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] To install additional .NET runtimes or SDKs: https://aka.ms/dotnet-download
Visual Studio Code Extensions |Extension|Author|Version| |---|---|---| |code-spell-checker|streetsidesoftware|1.10.2| |csharp|ms-dotnettools|1.23.11| |DocFX|ms-docfx|0.1.3| |docs-article-templates|docsmsft|0.2.11| |docs-authoring-pack|docsmsft|0.1.13| |docs-build|ceapex|0.1.24| |docs-build|docsmsft|0.3.4| |docs-images|docsmsft|0.0.9| |docs-linting|docsmsft|0.0.7| |docs-markdown|docsmsft|0.2.90| |docs-metadata|docsmsft|1.0.6| |docs-preview|docsmsft|0.3.57| |docs-scaffolding|docsmsft|0.0.7| |docs-yaml|docsmsft|0.2.6| |js-debug-nightly|ms-vscode|2021.5.617| |LinkCheckMD|blackmist|0.3.1| |powershell|ms-vscode|2021.2.2| |status-bar-tasks|GuardRex|0.3.0| |vscode-markdownlint|DavidAnson|0.40.4| |vscode-yaml|redhat|0.18.0|;
guardrex commented 3 years ago

UPDATE: We're going to cover it in docs by saying to the effect that if VSC doesn't create the .vscode folder assets automatically (i.e., launch.json and tasks.json) use the following default files and then show the files. We can go with that. I just don't want to have these files permanently present because they're going to churn over time and go stale.

I checked again this morning (6/1), and my VSC/Omnisharp still isn't creating these assets for a hosted Blazor WebAssembly app (opened either from the solution folder or from the Server project folder). Also, the Command Palette approach is failing to add them ... I still get ...

Could not locate .NET Core project. Assets were not generated.

I can drop the files into position into a manually-created .vscode folder in the solution's folder and then everything works fine.

guardrex commented 3 years ago

Hello ... I just want to provide an update (9/22/2021) that I'm still seeing this problem with ...

VSC: 1.60.1 C# Extension: 1.23.15

Could not locate .NET Core project. Assets were not generated.

Capture

... when in the command palette and I try to execute .NET: Generate Assets for Build and Debug for a Blazor hosted WebAssembly project generated using the .NET CLI with dotnet new blazorwasm -ho.