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.38k stars 10k forks source link

Error NETSDK1047: Assets file 'project.assets.json' doesn't have a target for '.NETCoreApp,Version=v5.0/linux-x64'. #24521

Closed BrunoBlanes closed 4 years ago

BrunoBlanes commented 4 years ago

I have an automated build pipeline in Azure DevOps and since I updated my project to .NET Preview 7 it throws this error during the build phase. Before this step a restore is successfully completed. My project file already has framwork and runtime identifiers defined as shown:

<TargetFramework>net5.0</TargetFramework>
<RuntimeIdentifiers>win-x86;win-x64;win-arm;linux-x64;linux-arm</RuntimeIdentifiers>

The pipeline passed during Preview 6 with no other changes made to the project.

BrunoBlanes commented 4 years ago

It appears to have something to do with the following addition to .NET 5 Preview 7:

<RuntimeIdentifier>browser-wasm</RuntimeIdentifier>

This is a Blazor WebAssembly application that I am trying to build, though that tag is on the client, not the server project.

wli3 commented 4 years ago

This looks like the RuntimeIdentifier being global property issue.

BrunoBlanes commented 4 years ago

Do you mean this is on my end?

wli3 commented 4 years ago

@BrunoBlanes this might be a bug in the product. The above comment is to help us to investigate

BrunoBlanes commented 4 years ago

Ok cool, thanks for clarifying!

ghost commented 4 years ago

Thanks for contacting us. We're moving this issue to the Next sprint planning milestone for future evaluation / consideration. We will evaluate the request when we are planning the work for the next milestone. To learn more about what to expect next and how this issue will be handled you can read more about our triage process here.

mkArtakMSFT commented 4 years ago

What we plan to do here

We will consider thrown an error when a Blazor WebAssembly project is being build with a RID which is not browser-wasm.

BrunoBlanes commented 4 years ago

What should I do to get Azure DevOps to build the project?

mehalick commented 4 years ago

I receive the same error when publishing my server project that references a Blazor wasm client project.

- task: DotNetCoreCLI@2
  displayName: 'Publish App'
  inputs:
    command: 'publish'
    publishWebProjects: false
    projects: '**/Maki.Server.csproj'
    arguments: '--configuration $(BuildConfiguration) --runtime win-x64 --self-contained true --output $(Build.ArtifactStagingDirectory)'
    zipAfterPublish: true

In DevOps:

C:\hostedtoolcache\windows\dotnet\sdk\5.0.100-preview.7.20366.6\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets(241,5): error NETSDK1047: Assets file 'd:\a\1\s\src\Maki.Client\obj\project.assets.json' doesn't have a target for '.NETCoreApp,Version=v5.0/browser-wasm'. Ensure that restore has run and that you have included 'net5.0' in the TargetFrameworks for your project. You may also need to include 'browser-wasm' in your project's RuntimeIdentifiers. [d:\a\1\s\src\Maki.Client\Maki.Client.csproj]
svetovid commented 4 years ago

I encountered the same problem (.NET5 preview 7):

  1. Create Blazor WebAssembly App hosted in ASP.NET Core
    <TargetFramework>net5.0</TargetFramework>
    <RuntimeIdentifier>browser-wasm</RuntimeIdentifier>
    <UseBlazorWebAssembly>true</UseBlazorWebAssembly>
  2. Publish BlazorApp.Server dotnet publish -c Release -r win-x64

Result: ... project.assets.json doesn't have a target for '.NETCoreApp,Version=v5.0/browser-wasm'. Ensure that restore has run and that you have included 'net5.0' in the TargetFrameworks for your project. You may also need to include 'browser-wasm' in your project's RuntimeIdentifiers.

It works however in this case: dotnet publish -c Release

bmoteria commented 4 years ago

@wli3 Any update on this one? The issue seems to persist with .NET 5 RC1. Azure DevOps Server is unable to build successfully.

BrunoBlanes commented 4 years ago

@wli3 I haven't tested it yet on RC1, however, the docs for the new version did mention that both lines below should be removed:

<RuntimeIdentifier>browser-wasm</RuntimeIdentifier>
<UseBlazorWebAssembly>true</UseBlazorWebAssembly>

So I don't think the error message should still be present.

RugerSR9 commented 4 years ago

Bump. Am also having this issue even with non-Blazor projects.

mkArtakMSFT commented 4 years ago

@pranavkm can you please make sure this is addressed in 5.0, if not already? Thanks!

pranavkm commented 4 years ago

This has been addressed in 5.0-rc1. If you're still having trouble with Blazor WebAssembly projects, please share a minimal app that reproduces the issue.

@RugerSR9 your problem appears to be different from the one being discussed here (since it's not specific to Blazor Wasm). Could you file a separate issue with a minimal app that exhibits the problem? Thanks!

BrunoBlanes commented 4 years ago

Haven't updated to RC1 yet, will do it and let you know.

pranavkm commented 4 years ago

Thanks. Our migration notes covers changes to the project file when updating from a 3.1 project: https://docs.microsoft.com/en-us/aspnet/core/migration/31-to-50?view=aspnetcore-3.1&tabs=visual-studio#update-blazor-webassembly-projects

BrunoBlanes commented 4 years ago

So I've gone trough the process of migrating from .NET 5 Preview 8 to RC1 and now it doesn't even clean or build.

C:\Program Files\dotnet\sdk\5.0.100-rc.1.20452.10\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.FrameworkReferenceResolution.targets(379,5): error NETSDK1082: There was no runtime pack for Microsoft.AspNetCore.App available for the specified RuntimeIdentifier 'browser-wasm'.

Here is my Server project file:

<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">
    <PropertyGroup>
    <TargetFramework>net5.0</TargetFramework>
    <LangVersion>preview</LangVersion>
    <Nullable>enable</Nullable>
    <OutputType>Exe</OutputType>
    <Version>0.1.0.0</Version>
    <StartupObject>CRM.Server.Program</StartupObject>
    <PreserveCompilationContext>true</PreserveCompilationContext>
    <UserSecretsId>311b3395-91d4-422a-82a7-52ea76f9e066</UserSecretsId>
    <GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
    <!--<RuntimeIdentifiers>win-x86;win-x64;win-arm;linux-x64;linux-arm</RuntimeIdentifiers>-->
    </PropertyGroup>

    [...]
</Project>

Here is my Client project file:

<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">
    <PropertyGroup>
    <TargetFramework>net5.0</TargetFramework>
    <LangVersion>preview</LangVersion>
    <Nullable>enable</Nullable>
    </PropertyGroup>

    [...]
</Project>

I tried repairing my .NET 5 RC1 installation and got the following error:

[3230:290C][2020-10-12T17:21:10]i301: Applying execute package: AspNetCoreSharedFramework_x64, action: Repair, path: C:\ProgramData\Package Cache\{0E6BE3E7-2AA8-3522-B71B-FEF5F4BBF1AC}v5.0.0.0\AspNetCoreSharedFramework-x64.msi, arguments: ' ARPSYSTEMCOMPONENT="1" MSIFASTINSTALL="7" DOTNETHOME="C:\Program Files\dotnet"'
[3230:290C][2020-10-12T17:21:11]e000: Error 0x80070643: Failed to run maintanance mode for MSI package.
[3230:290C][2020-10-12T17:21:11]e000: Error 0x80070643: Failed to execute MSI package.
[2CD0:3454][2020-10-12T17:21:11]e000: Error 0x80070643: Failed to configure per-machine MSI package.
[2CD0:3454][2020-10-12T17:21:11]w348: Application requested retry of package: AspNetCoreSharedFramework_x64, encountered error: 0x80070643. Retrying...

I don't know if the above error is related, but I tried cleaning the cache folder and reinstalling .NET 5 and restarting my computer. None fixed it.

BrunoBlanes commented 4 years ago

My dotnet --info output by the way.

C:\Users\bruno>dotnet --info
.NET SDK (reflecting any global.json):
 Version:   5.0.100-rc.1.20452.10
 Commit:    473d1b592e

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.20185
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\5.0.100-rc.1.20452.10\

Host (useful for support):
  Version: 5.0.0-rc.1.20451.14
  Commit:  38017c3935

.NET SDKs installed:
  5.0.100-rc.1.20452.10 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 5.0.0-rc.1.20451.17 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 5.0.0-rc.1.20451.14 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 5.0.0-rc.1.20452.2 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

To install additional .NET runtimes or SDKs:
  https://aka.ms/dotnet-download
pranavkm commented 4 years ago

Here is my Server project file:

Your server project file shouldn't target the WebAssembly SDK:

<!-- Server.csproj -->
- <Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">
+ <Project Sdk="Microsoft.NET.Sdk.Web"> 
BrunoBlanes commented 4 years ago

Ok, so that returns it to how it was working before, I can compile it fine on Visual Studio, but Azure Devops throws this:

##[error]/opt/hostedtoolcache/dotnet/sdk/5.0.100-rc.1.20452.10/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(241,5): Error NETSDK1047: Assets file '/home/vsts/work/1/s/Client/obj/project.assets.json' doesn't have a target for 'net5.0/linux-x64'. Ensure that restore has run and that you have included 'net5.0' in the TargetFrameworks for your project. You may also need to include 'linux-x64' in your project's RuntimeIdentifiers.

BrunoBlanes commented 4 years ago

Oh, wait, never mind, I was looking at the wrong build. It passed.