The standard template for Blazor Web Hosted project does not build.
Steps to reproduce the behavior:
The project should build
ASP.NET Core Blazor Language Service extension 16.0.19104.4 is installed in VS 2019
@mrpmorris I'm not able to reproduce this issue. To help us figure out what's going on could you please try the following:
dotnet --version
?dotnet new -u Microsoft.AspNetCore.Blazor.Tempates
dotnet new -i Microsoft.AspNetCore.Blazor.Templates::0.8.0-preview-19104-04
dotnet new -o blazorhosted -o BlazorHostedApp1
cd BlazorHostedApp1/BlazorHostedApp1.Server
dotnet run
Hi, I was having this same issue. I didn't realize I was still running .net Core 3 Preview 1. Upon updating to .net Core 3 Preview 2, the issue went away.
@danroth27 You can close this.
It was resolved by uninstalling VS2019, and then re-installing VS2019 and Blazor.
I encountered the same problem with a fresh install of vs2019 RC2,
following Exploring Blazor with Visual Studio 2019
but building the server still reported the error "The current .NET SDK does not support targeting .NET Core 3.0. Either target .NET Core 2.1 or lower, or use a version of the .NET SDK that supports .NET Core 3.0".
I solved the compilation problem by installing dotnet-sdk-2.2.105.
IDK why the 2.2.201 installed with the current vs installer is not enough though.
I hope that this issue will be resolved soon, in the meantime, that solution might help.
@djack42 You really should be using the latest Blazor bits with .NET Core 3.0, not 2.2. A change was made in the new release channel for VS2019 to no longer pickup previews of .NET Core SDKs by default. To use use a preview of .NET Core 3.0 with the release channel of Visual Studio 2019, you will need to enable the option to use previews of the .NET Core SDK by going to Tools > Options > Projects and Solutions > .NET Core > Use previews of the .NET Core SDK. If you're using the preview channel for VS, then this option should already selected for you.
I'm experiencing the same thing. CLEAN build of the latest RC of VS2019, installed the .NET 3.0 SDK, Blazor extension, etc., etc., and getting the same errors as everyone else. This wasn't well planned, in my opinion. And I used to work at Microsoft.. :(
However, Dan's solution above ( going to Tools > Options > Projects and Solutions > .NET Core > Use previews of the .NET Core SDK) DOES work. I understand why that's in there, but for those of us just a little more than a week away, this should be (?) outlined on the Blazor.net site. I didn't see it anywhere, but I may have missed it.
@christopherdengler If you install VS2019 from the preview channel instead of the release channel then preview versions of the .NET Core SDK will get used by default without setting additional options. The instructions on blazor.net do say to install from the preview channel, but it sounds like quite a few folks are ending up with the release channel. We should probably add a note to the getting started instructions to let folks know that there is this extra step if you use the release channel.
I think you're right, Dan. Thanks for clarifying that. I also believe that in a little more than a week, this issue will be a dead one. I DID get it running. Having worked there, I do know how some of this stuff gets out of sync. I'm surprised to see that you guys were allowed separate releases, but again that point is about to become moot. Thank you so much for detailing what was wrong; I do think you're correct.
I am having the same problem with Blazor running the default project using the GA release of 2019 Community.
1>Startup.cs(14,30,14,33): error CS0246: The type or namespace name 'App' could not be found (are you missing a using directive or an assembly reference?)
To use Blazor please use the latest preview release of VS2019: https://visualstudio.com/preview
does this mean, it's not gonna work with latest stable release v 16.0.2?
@iamraviraj Correct, Blazor requires tooling updates to VS2019 that are only available in the Preview channel.
Lame question, but is there any estimate on release for Blazor?
@christopherdengler Not a lame question at all :smile:. The latest roadmap information we have shared for Blazor is in the recent Blazor preview blog post: https://devblogs.microsoft.com/aspnet/blazor-now-in-official-preview/.
With each preview release of .NET Core 3.0, we will continue to ship preview releases of both server and client-side Blazor.
Thanks! So, just to be clear - in order to keep developing with this, we'd not only have to keep up on the latest .NET Core 3 (currently Preview 4), but ALSO make sure we update VS 2019 to the preview version as well? I'm good with that; I just wanted to verify... I think that's what they're trying to say here (https://docs.microsoft.com/en-us/aspnet/core/blazor/get-started), however one never knows if these things are updated... just verifyin'.
in order to keep developing with this, we'd not only have to keep up on the latest .NET Core 3 (currently Preview 4), but ALSO make sure we update VS 2019 to the preview version as well?
Yup, you'll need to stay on the latest VS2019 preview release.
Thanks, that makes good sense.
Hi guys, I'm having the same issue :(
-I'm running the latest dotnet core preview (6)
-I'm running the latest vstudio preview
However, when I try to do dotnet run the following is displayed:
> obj\Debug\netstandard2.0\RazorDeclaration\Shared\MainLayout.cshtml.g.cs(16,31): error CS0246: The type or namespace name 'LayoutComponentBase' could not be found (are you missing a using directive or an assembly reference?) [C:\Users\igorfmachado\blazor\blazor.Client\blazor.Client.csproj]
> obj\Debug\netstandard2.0\RazorDeclaration\Shared\MainLayout.cshtml.g.cs(19,33): error CS0115: 'MainLayout.BuildRenderTree(RenderTreeBuilder)': no suitable method found to override [C:\Users\igorfmachado\blazor\blazor.Client\blazor.Client.csproj]
> obj\Debug\netstandard2.0\RazorDeclaration\Pages\FetchData.cshtml.g.cs(40,75): error CS0246: The type or namespace name 'HttpClient' could not be found (are you missing a using directive or an assembly reference?) [C:\Users\igorfmachado\blazor\blazor.Client\blazor.Client.csproj]
> obj\Debug\netstandard2.0\RazorDeclaration\Pages\_ViewImports.cshtml.g.cs(16,69): error CS0246: The type or namespace name 'MainLayout' could not be found (are you missing a using directive or an assembly reference?) [C:\Users\igorfmachado\blazor\blazor.Client\blazor.Client.csproj]
The build failed. Fix the build errors and run again.
I've tried to uninstall everything (.net core, blazor and vstudio and re-install)
@igorfmachado It looks like the NuGet restore failed for some reason. Please try opening a command-prompt in the solution directory and run dotnet restore
.
@igorfmachado It looks like the NuGet restore failed for some reason. Please try opening a command-prompt in the solution directory and run
dotnet restore
.
Hi Dan,
Thanks for trying but it stills the same :/
@igorfmachado Did you the restore succeed on the command line? Assuming it did, does dotnet build
succeed?
Hi Dan,
Yes, I did, that's the restore output:
Restore completed in 23.34 ms for C:\Projects\Test\Blazor\Blazor.WebApp\Blazor.WebApp.csproj.
When I run dotnet build
here is the output:
Microsoft (R) Build Engine version 16.2.0-preview-19278-01+d635043bd for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.
Restore completed in 14.13 ms for C:\Projects\Test\Blazor\Blazor.WebApp\Blazor.WebApp.csproj.
C:\Program Files\dotnet\sdk\3.0.100-preview6-012264\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.RuntimeIdentifierInference.targets(158,5): message NETSDK1057: You are using a preview version of .NET Core. See: https://aka.ms/dotnet-core-preview [C:\Projects\Test\Blazor\Blazor.WebApp\Blazor.WebApp.csproj]
C:\Users\igorfmachado\AppData\Local\Temp\.NETCoreApp,Version=v3.0.AssemblyAttributes.cs(4,20): error CS0400: The type or namespace name 'System' could not be found in the global namespace (are you missing an assembly reference?) [C:\Projects\Test\Blazor\Blazor.WebApp\Blazor.WebApp.csproj]
C:\Users\igorfmachado\AppData\Local\Temp\.NETCoreApp,Version=v3.0.AssemblyAttributes.cs(4,71): error CS0518: Predefined type 'System.String' is not defined or imported [C:\Projects\Test\Blazor\Blazor.WebApp\Blazor.WebApp.csproj]
C:\Users\igorfmachado\AppData\Local\Temp\.NETCoreApp,Version=v3.0.AssemblyAttributes.cs(4,99): error CS0246: The type or namespace name 'FrameworkDisplayName' could not be found (are you missing a using directive or an assembly reference?)
@igorfmachado Did you the restore succeed on the command line? Assuming it did, does
dotnet build
succeed?
@danroth27 Thanks for your help. I've managed to solve the issue with the following:
1. Uninstall all .NET Core SDK & Runtimes
2. Install .NET Core Preview 4
3. Update to .NET Core Preview 6
PS: After completing the steps above and restarted my machine, I was getting the error (rzc generate exited with code 1) while trying to build the solution ... the bypass for this was to press F5 to run debug instead of trying to build the solutions.
From then on everything seems to be working fine. Let's enjoy Blazor !!!
@igorfmachado I'm glad to hear that you got things working! If you have any insights into how your machine got into that broken state originally let us know and we'll see if we can do something to address it.
I don't know why but I am having exactly the same issue. I followed all the steps in intro and here it is. The same compilation problem.
Severity Code Description Project File Line Suppression State
Error CS0246 The type or namespace name 'App' could not be found (are you missing a using directive or an assembly reference?) Test C:\Users\raham\source\repos\Test\Test\Startup.cs 14 Active
@rahamohebbi What does the output of dotnet --info
say?
`dotnet --info .NET Core SDK (reflecting any global.json): Version: 2.2.301
Commit: 70d6be0814
Runtime Environment:
OS Name: Windows
OS Version: 10.0.18362
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\2.2.301\
Host (useful for support): Version: 3.0.0-preview6-27804-01 Commit: fdf81c6faf .NET Core SDKs installed: 2.1.602 [C:\Program Files\dotnet\sdk] 2.1.700 [C:\Program Files\dotnet\sdk] 2.1.701 [C:\Program Files\dotnet\sdk] 2.1.800-preview-009696 [C:\Program Files\dotnet\sdk] 2.2.202 [C:\Program Files\dotnet\sdk] 2.2.300 [C:\Program Files\dotnet\sdk] 2.2.301 [C:\Program Files\dotnet\sdk] .NET Core runtimes installed: Microsoft.AspNetCore.All 2.1.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.1.11 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.1.12 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.2.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.2.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.2.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.App 2.1.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.1.11 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.1.12 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.2.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.2.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.2.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 3.0.0-preview6.19307.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 2.1.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.1.11 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.1.12 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.2.3 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.2.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.2.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 3.0.0-preview6-27804-01 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] To install additional .NET Core runtimes or SDKs: https://aka.ms/dotnet-download`
@rahamohebbi It looks like your active .NET Core SDK version is 2.2. Blazor requires the .NET Core 3.0 SDK. You can get it from here: https://aka.ms/netcore3download.
Most helpful comment
@djack42 You really should be using the latest Blazor bits with .NET Core 3.0, not 2.2. A change was made in the new release channel for VS2019 to no longer pickup previews of .NET Core SDKs by default. To use use a preview of .NET Core 3.0 with the release channel of Visual Studio 2019, you will need to enable the option to use previews of the .NET Core SDK by going to Tools > Options > Projects and Solutions > .NET Core > Use previews of the .NET Core SDK. If you're using the preview channel for VS, then this option should already selected for you.