I have an app and a library, both target .NET 9. I can build and run without issues both in release and debug configuration.
When I try to publish for Windows, the dependency in the library gets a yellow exclamation mark:
And a message:
Assets file 'C:\repos...\Model\obj\project.assets.json' doesn't have a target for 'net9.0'. Ensure that restore has run and that you have included 'net9.0' in the TargetFrameworks for your project.
The file starts like this:
{
"version": 3,
"targets": {
"net9.0-windows10.0.19041": {
"System.Security.Cryptography.Pkcs/9.0.2": {
... },
"System.Security.Cryptography.Xml/9.0.2": {
...
}
},
"net9.0-windows10.0.19041/win-x64": {
"System.Security.Cryptography.Pkcs/9.0.2": {
...
},
"System.Security.Cryptography.Xml/9.0.2": {
...
}
}
},
The publish profile is as follows:
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<PublishDir>bin\Release\net9.0-windows10.0.19041.0\win10-x64\publish\</PublishDir>
<PublishProtocol>FileSystem</PublishProtocol>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<Platform>Any CPU</Platform>
<Configuration>Release</Configuration>
<TargetFramework>net9.0-windows10.0.19041.0</TargetFramework>
<PublishSingleFile>false</PublishSingleFile>
<PublishReadyToRun>false</PublishReadyToRun>
<SelfContained>True</SelfContained>
<PublishAppxPackage>true</PublishAppxPackage>
<AppxPackageDir>bin\Release\net9.0-windows10.0.19041.0\win10-x64\AppPackages\</AppxPackageDir>
</PropertyGroup>
</Project>
Both are generated by the tooling, so they should be ok... but seems to be something.
Note: I am using VS 2022 v17.14.0 Preview 1.0
I can publish from CLI though...



dotnet restore. This command will restore the necessary packages and generate the project.assets.json file.