Assets file project.assets.json doesn't have a target for 'net6.0-windows10.0.19041.0/win-x64'
Asked Answered
B

0

6

I have a .NET 6 Windows Desktop app that I deploy with MSIX.

I can run and debug it on my own computer, but it fails to build with Azure Pipelines YAML.

I get the error:

C:\Program Files\dotnet\sdk\6.0.101\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets(267,5): error NETSDK1047: Assets file 'D:\a\1\s\MyApp\obj\project.assets.json' doesn't have a target for 'net6.0-windows10.0.19041.0/win-x64'. Ensure that restore has run and that you have included 'net6.0-windows10.0.19041.0' in the TargetFrameworks for your project. You may also need to include 'win-x64' in your project's RuntimeIdentifiers.

App project file:

<TargetFramework>net6.0-windows10.0.19041.0</TargetFramework>
<RuntimeIdentifier>win10-x64</RuntimeIdentifier>
<Platforms>x64</Platforms>

Installer project file:

<TargetPlatformVersion>10.0.19041.0</TargetPlatformVersion>
<TargetPlatformMinVersion>10.0.19041.0</TargetPlatformMinVersion>
<TargetFramework>net6.0-windows10.0.19041.0</TargetFramework>
<RuntimeIdentifier>win10-x64</RuntimeIdentifier>

The pipeline task is VSBuild with Visual Studio 2022 (v. 17) Nuget tool is version 6.0 installed with NugetToolInstaller task.

Azure Windows agent uses vmImage: 'windows-2022'

The error says:

Ensure that you have included 'net6.0-windows10.0.19041.0' in the TargetFrameworks for your project. You may also need to include 'win-x64' in your project's RuntimeIdentifiers.

I have added 'net6.0-windows10.0.19041.0' in the TargetFramework for both the app and the installer projects.

If I replace win10-x64 with win-x64 it can build, but I need to use win10-x64 because one of the packages requires it (Microsoft.PowerShell.SDK with System.Management.Automation).

NEW: After adding /p:RestoreLockedMode=true in the VS Build task, I now get the error:

MyApp.Installer.wapproj : error NU1004: The project MyApp has no compatible target framework. The packages lock file is inconsistent with the project dependencies so restore can't be run in locked mode. Disable the RestoreLockedMode MSBuild property or pass an explicit --force-evaluate option to run restore to update the lock file.

NEW NEW: I upgraded to .NET 7 but get the same error.

How do I fix the error?

Bireme answered 14/1, 2022 at 13:17 Comment(8)
You ever find a solution to this?Necrology
Sadly no.......Bireme
Did you find a solution to this?Mitziemitzl
No..............Bireme
Waiting for solution too, someone help us :(Broek
Same issue hereMcbrayer
Maybe create an issue at the Nuget github, they are experts... then link it here...Bireme
issue happened to me when I cross compiled (target linux-x64) from windows and set Framework-dependent, gone away by making the app Self-ContainedAndrogynous

© 2022 - 2025 — McMap. All rights reserved.