Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default Blazor Client App fails throwing the build error[Blazor][Appbuilding] #12712

Open
Anipik opened this issue Jul 29, 2019 · 18 comments

Comments

@Anipik
Copy link

commented Jul 29, 2019

I am trying to create an ClientSide Blazor app but I am not even able to build the default blazor app present in the VS

C:\Users\anagniho\source\repos\BlazorApp8>dotnet build
Microsoft (R) Build Engine version 16.3.0-preview-19375-05+42c4c1370 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

  Restore completed in 30.65 ms for C:\Users\anagniho\source\repos\BlazorApp8\BlazorApp8.csproj.
  You are using a preview version of .NET Core. See: https://aka.ms/dotnet-core-preview
obj\Debug\netstandard2.0\RazorDeclaration\Pages\_Imports.razor.g.cs(51,38): error CS0234: The type or namespace name 'LayoutAttributeAttribute' does not exist in the namespace 'Microsoft.AspNetCore.Components' (are you missing an assembly reference?) [C:\Users\anagniho\source\repos\BlazorApp8\BlazorApp8.csproj]
obj\Debug\netstandard2.0\RazorDeclaration\Pages\_Imports.razor.g.cs(51,38): error CS0234: The type or namespace name 'LayoutAttribute' does not exist in the namespace 'Microsoft.AspNetCore.Components' (are you missing an assembly reference?) [C:\Users\anagniho\source\repos\BlazorApp8\BlazorApp8.csproj]
obj\Debug\netstandard2.0\RazorDeclaration\Pages\FetchData.razor.g.cs(51,38): error CS0234: The type or namespace name 'LayoutAttributeAttribute' does not exist in the namespace 'Microsoft.AspNetCore.Components' (are you missing an assembly reference?) [C:\Users\anagniho\source\repos\BlazorApp8\BlazorApp8.csproj]
obj\Debug\netstandard2.0\RazorDeclaration\Pages\FetchData.razor.g.cs(51,38): error CS0234: The type or namespace name 'LayoutAttribute' does not exist in the namespace 'Microsoft.AspNetCore.Components' (are you missing an assembly reference?) [C:\Users\anagniho\source\repos\BlazorApp8\BlazorApp8.csproj]
obj\Debug\netstandard2.0\RazorDeclaration\Pages\Index.razor.g.cs(51,38): error CS0234: The type or namespace name 'LayoutAttributeAttribute' does not exist in the namespace 'Microsoft.AspNetCore.Components' (are you missing an assembly reference?) [C:\Users\anagniho\source\repos\BlazorApp8\BlazorApp8.csproj]
obj\Debug\netstandard2.0\RazorDeclaration\Pages\Index.razor.g.cs(51,38): error CS0234: The type or namespace name 'LayoutAttribute' does not exist in the namespace 'Microsoft.AspNetCore.Components' (are you missing an assembly reference?) [C:\Users\anagniho\source\repos\BlazorApp8\BlazorApp8.csproj]
obj\Debug\netstandard2.0\RazorDeclaration\Pages\Counter.razor.g.cs(51,38): error CS0234: The type or namespace name 'LayoutAttributeAttribute' does not exist in the namespace 'Microsoft.AspNetCore.Components' (are you missing an assembly reference?) [C:\Users\anagniho\source\repos\BlazorApp8\BlazorApp8.csproj]
obj\Debug\netstandard2.0\RazorDeclaration\Pages\Counter.razor.g.cs(51,38): error CS0234: The type or namespace name 'LayoutAttribute' does not exist in the namespace 'Microsoft.AspNetCore.Components' (are you missing an assembly reference?) [C:\Users\anagniho\source\repos\BlazorApp8\BlazorApp8.csproj]

Build FAILED.

obj\Debug\netstandard2.0\RazorDeclaration\Pages\_Imports.razor.g.cs(51,38): error CS0234: The type or namespace name 'LayoutAttributeAttribute' does not exist in the namespace 'Microsoft.AspNetCore.Components' (are you missing an assembly reference?) [C:\Users\anagniho\source\repos\BlazorApp8\BlazorApp8.csproj]
obj\Debug\netstandard2.0\RazorDeclaration\Pages\_Imports.razor.g.cs(51,38): error CS0234: The type or namespace name 'LayoutAttribute' does not exist in the namespace 'Microsoft.AspNetCore.Components' (are you missing an assembly reference?) [C:\Users\anagniho\source\repos\BlazorApp8\BlazorApp8.csproj]
obj\Debug\netstandard2.0\RazorDeclaration\Pages\FetchData.razor.g.cs(51,38): error CS0234: The type or namespace name 'LayoutAttributeAttribute' does not exist in the namespace 'Microsoft.AspNetCore.Components' (are you missing an assembly reference?) [C:\Users\anagniho\source\repos\BlazorApp8\BlazorApp8.csproj]
obj\Debug\netstandard2.0\RazorDeclaration\Pages\FetchData.razor.g.cs(51,38): error CS0234: The type or namespace name 'LayoutAttribute' does not exist in the namespace 'Microsoft.AspNetCore.Components' (are you missing an assembly reference?) [C:\Users\anagniho\source\repos\BlazorApp8\BlazorApp8.csproj]
obj\Debug\netstandard2.0\RazorDeclaration\Pages\Index.razor.g.cs(51,38): error CS0234: The type or namespace name 'LayoutAttributeAttribute' does not exist in the namespace 'Microsoft.AspNetCore.Components' (are you missing an assembly reference?) [C:\Users\anagniho\source\repos\BlazorApp8\BlazorApp8.csproj]
obj\Debug\netstandard2.0\RazorDeclaration\Pages\Index.razor.g.cs(51,38): error CS0234: The type or namespace name 'LayoutAttribute' does not exist in the namespace 'Microsoft.AspNetCore.Components' (are you missing an assembly reference?) [C:\Users\anagniho\source\repos\BlazorApp8\BlazorApp8.csproj]
obj\Debug\netstandard2.0\RazorDeclaration\Pages\Counter.razor.g.cs(51,38): error CS0234: The type or namespace name 'LayoutAttributeAttribute' does not exist in the namespace 'Microsoft.AspNetCore.Components' (are you missing an assembly reference?) [C:\Users\anagniho\source\repos\BlazorApp8\BlazorApp8.csproj]
obj\Debug\netstandard2.0\RazorDeclaration\Pages\Counter.razor.g.cs(51,38): error CS0234: The type or namespace name 'LayoutAttribute' does not exist in the namespace 'Microsoft.AspNetCore.Components' (are you missing an assembly reference?) [C:\Users\anagniho\source\repos\BlazorApp8\BlazorApp8.csproj]
    0 Warning(s)
    8 Error(s)

Time Elapsed 00:00:01.21

Selecting the server app question resolves the issue though. is there anything else that needs to be installed for making it work ?

@mkArtakMSFT

This comment has been minimized.

Copy link
Member

commented Jul 30, 2019

Thanks for contacting us, @Anipik .
Looks like you have outdated client-side templates. Please reinstall the templates as specified at: https://docs.microsoft.com/en-us/aspnet/core/blazor/get-started?view=aspnetcore-3.0&tabs=visual-studio

@Anipik

This comment has been minimized.

Copy link
Author

commented Jul 31, 2019

@mkArtakMSFT I followed the instructions specified in the linked webpage but I get the same error.
When I create the clientside blazor app the Source shown by VS is CLI v5.0.100-alpha-01013627

@sukeshchand

This comment has been minimized.

Copy link

commented Aug 13, 2019

any update on this issue?

@PSharp93

This comment has been minimized.

Copy link

commented Aug 13, 2019

I am getting the same error using the latest Visual Studio Enterprise Preview with the latest templates preview 8 and latest .Net Core 3.0 preview 8.

@mkArtakMSFT mkArtakMSFT reopened this Aug 14, 2019

@mkArtakMSFT

This comment has been minimized.

Copy link
Member

commented Aug 14, 2019

@Anipik, seems like you've got some nighly builds where the build of the SDK was from master branch, which is for .Net Core 5 release. Have you tried uninstalling all the 3.0 SDKs you have and reinstall the official .Net Core 3.0 Preview 8 SDK?

@lifeisattrip

This comment has been minimized.

Copy link

commented Aug 14, 2019

@PSharp93
I remove all template folders except
v3.0.100-preview8-013656/
in
C:/Users/xx/.templateengine/dotnetcli/ and it works fine now

@erikbra

This comment has been minimized.

Copy link

commented Aug 14, 2019

Can't get it to work using any of the things mentioned here.
Running on preview 8, but the samples have dependencies on preview 6 of the nuget packages.

When trying to update the NuGet packages, I find that Microsoft.AspNetCore.Components.Browser is only in preview7 on Nuget.org. Did someone forget to release something?

https://www.nuget.org/packages/Microsoft.AspNetCore.Components.Browser/

Looks like the code generation misses the Layout part of this namespace:
Microsoft.AspNetCore.Components.Layouts.LayoutAttribute

@mkArtakMSFT

This comment has been minimized.

Copy link
Member

commented Aug 14, 2019

@erikbra the package Microsoft.AspNetCore.Components.Browser was renamed to ``Microsoft.AspNetCore.Components.Web`.

@PSharp93

This comment has been minimized.

Copy link

commented Aug 14, 2019

@PSharp93
I remove all template folders except
v3.0.100-preview8-013656/
in
C:/Users/xx/.templateengine/dotnetcli/ and it works fine now

Unfortunately did not work for me, still getting the errors using:

  • VS 2019 16.3.0 Preview 2.0
  • .NET Core SDK 3.0.100 - preview 8 (x64)
  • Blazor Templates v3.0.100-preview8-013656

Visual Studio shows updates for 4 Nuget packages but updating them causes new build errors.

@PSharp93

This comment has been minimized.

Copy link

commented Aug 14, 2019

@PSharp93
I remove all template folders except
v3.0.100-preview8-013656/
in
C:/Users/xx/.templateengine/dotnetcli/ and it works fine now

Unfortunately did not work for me, still getting the errors using:

  • VS 2019 16.3.0 Preview 2.0
  • .NET Core SDK 3.0.100 - preview 8 (x64)
  • Blazor Templates v3.0.100-preview8-013656

Visual Studio shows updates for 4 Nuget packages but updating them causes new build errors.

After deleting all templates and reinstalling the v3.0.100-preview8-013656 template, now only "Blazor Server App" and "Blazor WebAssembly App" is available as project type and those work. Was the mixed project type with client + server side removed?

@mkArtakMSFT

This comment has been minimized.

Copy link
Member

commented Aug 15, 2019

Yes, the templates have been renamed. You can read more about that change in the 'Blazor templates renamed and simplified' section in the Preview 8 Release Blog Post

After deleting all templates and reinstalling the v3.0.100-preview8-013656 template, now only "Blazor Server App" and "Blazor WebAssembly App" is available as project type and those work. Was the mixed project type with client + server side removed?

erikbra added a commit to erikbra/blazor-workshop that referenced this issue Aug 15, 2019
erikbra added a commit to erikbra/blazor-workshop that referenced this issue Aug 15, 2019
erikbra added a commit to erikbra/blazor-workshop that referenced this issue Aug 15, 2019
erikbra added a commit to erikbra/blazor-workshop that referenced this issue Aug 15, 2019
@erikbra

This comment has been minimized.

Copy link

commented Aug 15, 2019

Created a PR in the blazor-workshop repo to upgrade to 3.0.0-preview8 dotnet-presentations/blazor-workshop#133

@dazinator

This comment has been minimized.

Copy link

commented Aug 15, 2019

I hit this issue when using the latest VS 2019 preview 2 to build my solution. My solution was pinned via a global.json file to use sdk preview 7, but I didn't have sdk preview 7 installed, so the build rolled forward to use sdk preview 8. I have blazor preview 7 dependencies in my dependency graph, and it appears building under preview 8 with preview 7 dependencies, produced this error.

Rather than upgrade everything to preview 8 (some dependencies I use aren't compiled and released for preview 8 yet and are still on preview 7) I did this to resolve:

  1. Install preview 7 sdk
  2. Ensure all dependencies in my application that target blazor are referencing preview 7 (not 6 or less)
  3. Add a global.json to my solution to pin to preview 7.
  4. run a dotnet build - success.
  5. I had VS open throughout this, a rebuild doesn't seem to detect sdk 7 was installed and continues to use sdk 8 and fail - restarting VS, and reloading the solution, and then rebuilding - then correctly used sdk 7 and the build succeeded.

I assume this exact same thing can occur each time we go from preview x to preview y - lot of breaking changes at the moment - the build system seems to be very fragile - a bit like goldilocks porridge - everything has to be be "just right" :-)

@alialiyari

This comment has been minimized.

Copy link

commented Aug 20, 2019

replace it with

Microsoft.AspNetCore.Components.Layouts.LayoutAttribute

@GaryTuttle1

This comment has been minimized.

Copy link

commented Aug 22, 2019

Every time I replace Microsoft.AspNetCore.Components.LayoutAttribute in my classes with Microsoft.AspNetCore.Components.Layouts.LayoutAttribute, it reverts back to the original code. How do I stop that? What am I missing?

@dazinator

This comment has been minimized.

Copy link

commented Aug 22, 2019

@GaryTuttle1 Install dotnet sdk 3.0.0 preview 8 and make sure you build with that (check your global.json if you are using one, and do dotnet --list-sdks to make sure you have preview 8). I also uninstalled sdk preview 7. Restarted vs (update vs to 16.3.0 preview 2, and uninstall the blazor extension if you have it installed). Made sure all my blazor dependencies were targeted against preview 8. ..Once I did all of that my issue with layout attribute went away, but there are other breaking changes in .razor files to address, read the preview 8 announcement for what they are (things like @ref suppress field etc))

@scotthannen

This comment has been minimized.

Copy link

commented Aug 27, 2019

Is there a single, definitive guide that says how to do this? I'd like to work with some of the tutorials out there, but I have this same problem. I've tried with 2019 Preview and 2019 non-preview with the preview SDK option checked. There are lots of little pieces of "try this" and "I did that" sprinkled all over the internet, but trying to chase them down is a recipe for making all sorts of random, wild-guess, conflicting changes to my PC.

erikbra added a commit to erikbra/blazor-workshop that referenced this issue Aug 28, 2019
@DFPercush

This comment has been minimized.

Copy link

commented Sep 4, 2019

This will allow you to create a new project from the Blazor App (web assembly) template which compiles out the box. Any existing project will probably continue to have build errors. Projects may break between Visual Studio updates and you will have to do this again. You may need to create a new project from the fresh template and pull your existing source into it. Server side / SignalR does not seem to suffer from these build errors.

Credit to Tim Corey for the powershell method https://www.youtube.com/watch?v=CaxR4_fP-FA

I don't think this is necessary, but as part of my troubleshooting I'll include it: You may also need to get the latest .net 3.0 SDK from https://dotnet.microsoft.com/download/visual-studio-sdks
However, if you look in project properties in your Blazor app, Application > Target framework, you will see .NET standard 2.0. Other example projects I've seen on github also have this target framework in the .csproj file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
You can’t perform that action at this time.