dotnet / aspnetcore

ASP.NET Core is a cross-platform .NET framework for building modern cloud-based web applications on Windows, Mac, or Linux.
https://asp.net
MIT License
35.39k stars 10k forks source link

MSB4096: "StaticWebAsset" does not define a value for metadata "AssetKind" #43134

Closed steamonimo closed 2 years ago

steamonimo commented 2 years ago

Description

This error at compilation time continues with: In order to use this metadata, either qualify it by specifying %(StaticWebAsset.AssetKind), or ensure that all items in this list define a value for this metadata.

I have no idea what I am supposed to do now.

Reproduction Steps

Project worked with Core 3.1

Expected behavior

Compilation of StaticWebAsset

Actual behavior

Compilation stopped

Regression?

I do not know.

Known Workarounds

None.

Configuration

VS 17.2.6 .NET 6.0 Windows 10 21H2 (19044.1826) x64

Other information

No response

dotnet-issue-labeler[bot] commented 2 years ago

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

javiercn commented 2 years ago

@steamonimo thanks for contacting us.

Are you customizing things via MSBuild?

ghost commented 2 years ago

Hi @steamonimo. We have added the "Needs: Author Feedback" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

steamonimo commented 2 years ago

Are you customizing things via MSBuild?

No customization via MSBuild. Just download this project https://github.com/iammukeshm/Blazor.Learner and you will see that it will not compile due to the mentioned bug after being switched to .NET 6.0...

javiercn commented 2 years ago

@steamonimo this seems to be something with your environment.

git clean -xdff after upgrading and build to make sure that you have a clean slate.

Here is what I did in Docker.

> docker run --rm --user 0 -it mcr.microsoft.com/dotnet/sdk:latest bash
root@a6ee0c77fede:/# mkdir app
root@a6ee0c77fede:/# cd app/
root@a6ee0c77fede:/app# git clone https://github.com/iammukeshm/Blazor.Learner.git
Cloning into 'Blazor.Learner'...
remote: Enumerating objects: 180, done.
remote: Counting objects: 100% (180/180), done.
remote: Compressing objects: 100% (123/123), done.
remote: Total 180 (delta 61), reused 169 (delta 50), pack-reused 0
Receiving objects: 100% (180/180), 240.70 KiB | 1.21 MiB/s, done.
Resolving deltas: 100% (61/61), done.
root@a6ee0c77fede:/app# cd Blazor.Learner/
root@a6ee0c77fede:/app/Blazor.Learner# ls
Blazor.Learner  Blazor.Learner.sln
root@a6ee0c77fede:/app/Blazor.Learner# dotnet build /bl Blazor.Learner.sln
Microsoft (R) Build Engine version 17.2.0+41abc5629 for .NET
Copyright (C) Microsoft Corporation. All rights reserved.

/usr/share/dotnet/sdk/6.0.301/MSBuild.dll -consoleloggerparameters:Summary -distributedlogger:Microsoft.DotNet.Tools.MSBuild.MSBuildLogger,/usr/share/dotnet/sdk/6.0.301/dotnet.dll*Microsoft.DotNet.Tools.MSBuild.MSBuildForwardingLogger,/usr/share/dotnet/sdk/6.0.301/dotnet.dll -maxcpucount -restore -verbosity:m /bl Blazor.Learner.sln
  Determining projects to restore...
  Restored /app/Blazor.Learner/Blazor.Learner/Shared/Blazor.Learner.Shared.csproj (in 1.67 sec).
  Restored /app/Blazor.Learner/Blazor.Learner/Client/Blazor.Learner.Client.csproj (in 3.85 sec).
  Restored /app/Blazor.Learner/Blazor.Learner/Server/Blazor.Learner.Server.csproj (in 10.7 sec).
  Blazor.Learner.Shared -> /app/Blazor.Learner/Blazor.Learner/Shared/bin/Debug/netstandard2.1/Blazor.Learner.Shared.dll
  Blazor.Learner.Client -> /app/Blazor.Learner/Blazor.Learner/Client/bin/Debug/netstandard2.1/Blazor.Learner.Client.dll
  Blazor.Learner.Client (Blazor output) -> /app/Blazor.Learner/Blazor.Learner/Client/bin/Debug/netstandard2.1/wwwroot
/usr/share/dotnet/sdk/6.0.301/Microsoft.Common.CurrentVersion.targets(2302,5): warning MSB3277: Found conflicts between different versions of "System.Text.Json" that could not be resolved. [/app/Blazor.Learner/Blazor.Learner/Server/Blazor.Learner.Server.csproj]
/usr/share/dotnet/sdk/6.0.301/Microsoft.Common.CurrentVersion.targets(2302,5): warning MSB3277: There was a conflict between "System.Text.Json, Version=4.0.1.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51" and "System.Text.Json, Version=4.0.1.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51". [/app/Blazor.Learner/Blazor.Learner/Server/Blazor.Learner.Server.csproj]
/usr/share/dotnet/sdk/6.0.301/Microsoft.Common.CurrentVersion.targets(2302,5): warning MSB3277:     "System.Text.Json, Version=4.0.1.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51" was chosen because it was primary and "System.Text.Json, Version=4.0.1.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51" was not. [/app/Blazor.Learner/Blazor.Learner/Server/Blazor.Learner.Server.csproj]
/usr/share/dotnet/sdk/6.0.301/Microsoft.Common.CurrentVersion.targets(2302,5): warning MSB3277:     References which depend on "System.Text.Json, Version=4.0.1.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51" [/root/.nuget/packages/system.text.json/4.7.1/lib/netcoreapp3.0/System.Text.Json.dll]. [/app/Blazor.Learner/Blazor.Learner/Server/Blazor.Learner.Server.csproj]
/usr/share/dotnet/sdk/6.0.301/Microsoft.Common.CurrentVersion.targets(2302,5): warning MSB3277:         /root/.nuget/packages/system.text.json/4.7.1/lib/netcoreapp3.0/System.Text.Json.dll [/app/Blazor.Learner/Blazor.Learner/Server/Blazor.Learner.Server.csproj]
/usr/share/dotnet/sdk/6.0.301/Microsoft.Common.CurrentVersion.targets(2302,5): warning MSB3277:           Project file item includes which caused reference "/root/.nuget/packages/system.text.json/4.7.1/lib/netcoreapp3.0/System.Text.Json.dll". [/app/Blazor.Learner/Blazor.Learner/Server/Blazor.Learner.Server.csproj]
/usr/share/dotnet/sdk/6.0.301/Microsoft.Common.CurrentVersion.targets(2302,5): warning MSB3277:             /root/.nuget/packages/system.text.json/4.7.1/lib/netcoreapp3.0/System.Text.Json.dll [/app/Blazor.Learner/Blazor.Learner/Server/Blazor.Learner.Server.csproj]
/usr/share/dotnet/sdk/6.0.301/Microsoft.Common.CurrentVersion.targets(2302,5): warning MSB3277:     References which depend on "System.Text.Json, Version=4.0.1.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51" []. [/app/Blazor.Learner/Blazor.Learner/Server/Blazor.Learner.Server.csproj]
/usr/share/dotnet/sdk/6.0.301/Microsoft.Common.CurrentVersion.targets(2302,5): warning MSB3277:         /app/Blazor.Learner/Blazor.Learner/Client/bin/Debug/netstandard2.1/Blazor.Learner.Client.dll [/app/Blazor.Learner/Blazor.Learner/Server/Blazor.Learner.Server.csproj]
/usr/share/dotnet/sdk/6.0.301/Microsoft.Common.CurrentVersion.targets(2302,5): warning MSB3277:           Project file item includes which caused reference "/app/Blazor.Learner/Blazor.Learner/Client/bin/Debug/netstandard2.1/Blazor.Learner.Client.dll". [/app/Blazor.Learner/Blazor.Learner/Server/Blazor.Learner.Server.csproj]
/usr/share/dotnet/sdk/6.0.301/Microsoft.Common.CurrentVersion.targets(2302,5): warning MSB3277:             /app/Blazor.Learner/Blazor.Learner/Client/bin/Debug/netstandard2.1/Blazor.Learner.Client.dll [/app/Blazor.Learner/Blazor.Learner/Server/Blazor.Learner.Server.csproj]
  Blazor.Learner.Server -> /app/Blazor.Learner/Blazor.Learner/Server/bin/Debug/netcoreapp3.1/Blazor.Learner.Server.dll
  Blazor.Learner.Server -> /app/Blazor.Learner/Blazor.Learner/Server/bin/Debug/netcoreapp3.1/Blazor.Learner.Server.Views.dll

Build succeeded.

/usr/share/dotnet/sdk/6.0.301/Microsoft.Common.CurrentVersion.targets(2302,5): warning MSB3277: Found conflicts between different versions of "System.Text.Json" that could not be resolved. [/app/Blazor.Learner/Blazor.Learner/Server/Blazor.Learner.Server.csproj]
/usr/share/dotnet/sdk/6.0.301/Microsoft.Common.CurrentVersion.targets(2302,5): warning MSB3277: There was a conflict between "System.Text.Json, Version=4.0.1.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51" and "System.Text.Json, Version=4.0.1.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51". [/app/Blazor.Learner/Blazor.Learner/Server/Blazor.Learner.Server.csproj]
/usr/share/dotnet/sdk/6.0.301/Microsoft.Common.CurrentVersion.targets(2302,5): warning MSB3277:     "System.Text.Json, Version=4.0.1.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51" was chosen because it was primary and "System.Text.Json, Version=4.0.1.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51" was not. [/app/Blazor.Learner/Blazor.Learner/Server/Blazor.Learner.Server.csproj]
/usr/share/dotnet/sdk/6.0.301/Microsoft.Common.CurrentVersion.targets(2302,5): warning MSB3277:     References which depend on "System.Text.Json, Version=4.0.1.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51" [/root/.nuget/packages/system.text.json/4.7.1/lib/netcoreapp3.0/System.Text.Json.dll]. [/app/Blazor.Learner/Blazor.Learner/Server/Blazor.Learner.Server.csproj]
/usr/share/dotnet/sdk/6.0.301/Microsoft.Common.CurrentVersion.targets(2302,5): warning MSB3277:         /root/.nuget/packages/system.text.json/4.7.1/lib/netcoreapp3.0/System.Text.Json.dll [/app/Blazor.Learner/Blazor.Learner/Server/Blazor.Learner.Server.csproj]
/usr/share/dotnet/sdk/6.0.301/Microsoft.Common.CurrentVersion.targets(2302,5): warning MSB3277:           Project file item includes which caused reference "/root/.nuget/packages/system.text.json/4.7.1/lib/netcoreapp3.0/System.Text.Json.dll". [/app/Blazor.Learner/Blazor.Learner/Server/Blazor.Learner.Server.csproj]
/usr/share/dotnet/sdk/6.0.301/Microsoft.Common.CurrentVersion.targets(2302,5): warning MSB3277:             /root/.nuget/packages/system.text.json/4.7.1/lib/netcoreapp3.0/System.Text.Json.dll [/app/Blazor.Learner/Blazor.Learner/Server/Blazor.Learner.Server.csproj]
/usr/share/dotnet/sdk/6.0.301/Microsoft.Common.CurrentVersion.targets(2302,5): warning MSB3277:     References which depend on "System.Text.Json, Version=4.0.1.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51" []. [/app/Blazor.Learner/Blazor.Learner/Server/Blazor.Learner.Server.csproj]
/usr/share/dotnet/sdk/6.0.301/Microsoft.Common.CurrentVersion.targets(2302,5): warning MSB3277:         /app/Blazor.Learner/Blazor.Learner/Client/bin/Debug/netstandard2.1/Blazor.Learner.Client.dll [/app/Blazor.Learner/Blazor.Learner/Server/Blazor.Learner.Server.csproj]
/usr/share/dotnet/sdk/6.0.301/Microsoft.Common.CurrentVersion.targets(2302,5): warning MSB3277:           Project file item includes which caused reference "/app/Blazor.Learner/Blazor.Learner/Client/bin/Debug/netstandard2.1/Blazor.Learner.Client.dll". [/app/Blazor.Learner/Blazor.Learner/Server/Blazor.Learner.Server.csproj]
/usr/share/dotnet/sdk/6.0.301/Microsoft.Common.CurrentVersion.targets(2302,5): warning MSB3277:             /app/Blazor.Learner/Blazor.Learner/Client/bin/Debug/netstandard2.1/Blazor.Learner.Client.dll [/app/Blazor.Learner/Blazor.Learner/Server/Blazor.Learner.Server.csproj]
    1 Warning(s)
    0 Error(s)

Time Elapsed 00:00:21.04
root@a6ee0c77fede:/app/Blazor.Learner#
javiercn commented 2 years ago

@steamonimo also, on second look.

Seems that there are a bunch of additional steps that you need to take to upgrade the project, like updating the dependencies as well as updating the csproj files (at least the client needs to reference the wasm SDK)

steamonimo commented 2 years ago

reference the wasm SDK

Setting Sdk="Microsoft.NET.Sdk.BlazorWebAssembly" in the project and removing the outdated reference to package "Microsoft.AspNetCore.Components.WebAssembly.Build" did the trick

Thanks for your help! Will close this ticket.