Aspnetcore: blazor not start with vscode

Created on 17 Apr 2019  路  15Comments  路  Source: dotnet/aspnetcore

Hi
I have vscode 1.33.1 & C# extension 1.19.0 and dotnetcore 3.0.100-preview3-010431
I created a blazor project named Blazorr and build it.
But when I open project with vscode and start (F5) , it give us error :
A fatal error was encountered. The library 'hostpolicy.dll' required to execute the application was not found in 'E:\Projects\Blazorr\bin\Debug\netstandard2.0\'.
Failed to run as a self-contained app. If this should be a framework-dependent app, add the E:\Projects\Blazorr\bin\Debug\netstandard2.0\Blazorr.runtimeconfig.json file specifying the appropriate framework.
The target process exited without raising a CoreCLR started event. Ensure that the target process is configured to use .NET Core. This may be expected if the target process did not run on .NET Core.
The program '[9964] Blazorr.dll' has exited with code -2147450749 (0x80008083).

image

External area-blazor bug

Most helpful comment

@SteveSandersonMS this issue looks to be due to how VSCode boots a .NET Core app. It essentially does dotnet bin/path/to/debug/TheTFM/SomeBlazorApp.dll. I'm not sure what Blazor adds to the dotnet run pipeline but it looks like that's required in order to run the application. Is this something that's fixable on our side? If not, we'll need to make changes on the O# side to make F5 work in VSCode.

@mammadkoma if you want to semi-workaround your issue for now you can change your launch.json's program/args section to be:

            "program": "dotnet",
            "args": ["run", "${workspaceFolder}/bin/Debug/netstandard2.0/Preview4Blazor.dll", "--no-build" ],

All 15 comments

Thanks for contacting us, @mammadkoma.
@NTaylorMullen can you please look into this? Thanks!

@mammadkoma you would probably get a faster response on StackOverflow.

Where is buildOptions and emitEntryPoint in my project?
I can not find them.

New dotnetcore and blazor versions released but problems exists.

@mammadkoma are you able to run Blazor outside of VSCode? Aka dotnet run?

Yes _dotnet run_ command works successfully.

I tested in both my labtop and my work pc and blazor template project not create correct launch file and don't start and get errors:

**1. A fatal error was encountered. The library 'hostpolicy.dll' required to execute the application was not found in 'E:\Projects\Blazorr\bin\Debug\netstandard2.0'.Failed to run as a self-contained app. If this should be a framework-dependent app, add the E:\Projects\Blazorr\bin\Debug\netstandard2.0\Blazorr.runtimeconfig.json file specifying the appropriate framework.The target process exited without raising a CoreCLR started event. Ensure that the target process is configured to use .NET Core. This may be expected if the target process did not run on .NET Core.The program '[9964] Blazorr.dll' has exited with code -2147450749 (0x80008083).

  1. The type or namespace name 'App' could not be found (are you missing a using directive or an assembly reference?) (CS0246) [Blazor]**

I have flutter framework too. It creates launch file correctly in vs code and start (F5) very easy and fast and open my android emulator and show result.

Thanks @mammadkoma, I can reproduce your issue. I'll look into it more.

@SteveSandersonMS this issue looks to be due to how VSCode boots a .NET Core app. It essentially does dotnet bin/path/to/debug/TheTFM/SomeBlazorApp.dll. I'm not sure what Blazor adds to the dotnet run pipeline but it looks like that's required in order to run the application. Is this something that's fixable on our side? If not, we'll need to make changes on the O# side to make F5 work in VSCode.

@mammadkoma if you want to semi-workaround your issue for now you can change your launch.json's program/args section to be:

            "program": "dotnet",
            "args": ["run", "${workspaceFolder}/bin/Debug/netstandard2.0/Preview4Blazor.dll", "--no-build" ],

Would this need to use the blazor dev server?

@SteveSandersonMS this issue looks to be due to how VSCode boots a .NET Core app. It essentially does dotnet bin/path/to/debug/TheTFM/SomeBlazorApp.dll. I'm not sure what Blazor adds to the dotnet run pipeline but it looks like that's required in order to run the application. Is this something that's fixable on our side? If not, we'll need to make changes on the O# side to make F5 work in VSCode.

@mammadkoma if you want to semi-workaround your issue for now you can change your launch.json's program/args section to be:

            "program": "dotnet",
            "args": ["run", "${workspaceFolder}/bin/Debug/netstandard2.0/Preview4Blazor.dll", "--no-build" ],

Thank you
program & args options worked and F5 starts project in my browser.

              "program":"dotnet",
              "args": [
                    "run",
                    "${workspaceFolder}/bin/Debug/netstandard2.0/Blazorr.dll",
                    "--no-build"
              ]

@NTaylorMullen It's what @pranavkm said - to launch a Blazor standalone app, you have to use the Blazor dev server (because there's nothing else to act as the server - your app code is purely what runs in the browser, and is not the web server itself).

The Microsoft.AspNetCore.Blazor.DevServer package includes MSBuild props that modify the behavior of dotnet run so that it launches the dev server. I don't know why VS code doesn't launch .NET apps by running dotnet run (since that's the standard).

Gotcha, alright going to log an issue over on the omnisharp-vscode side of the world to properly detect Blazor apps and "do the right thing" when generating assets to run a .NET Core app that happens to be Blazor.

Given that this is external going to track the resolution of this work here: https://github.com/OmniSharp/omnisharp-vscode/issues/3024

Was this page helpful?
0 / 5 - 0 ratings