0

I have an app and a library, both target .NET 9. I can build and run without issues both in release and debug configuration.

build success

dependency ok

When I try to publish for Windows, the dependency in the library gets a yellow exclamation mark:

dependency problem

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...

3
  • You can run a NuGet package restore. Opening a command prompt in your project directory and run: dotnet restore. This command will restore the necessary packages and generate the project.assets.json file. Commented Feb 24 at 6:20
  • You think I haven't done that? The publish from VS thinks otherwise. As I wrote: CLI (a.k.a) dotnet publish has no issues. Commented Feb 25 at 6:39
  • You can clean and rebuild the project. This can help clear out any cached data that might be causing issues. Besides, you are using the latest version of Visual Studio 2022 Preview. Did you meet this issue in the official version? Commented Feb 26 at 7:59

1 Answer 1

-1

You're using the preview version but on Microsoft website https://visualstudio.microsoft.com/vs/preview/#download-preview

it states that the preview is not licensed to build your applications.

Sign up to request clarification or add additional context in comments.

1 Comment

What??? Not licensed to build an app? Read again, please. It has no official support for PRODUCTION, because it is a preview. All right. But what else do you use it for aside building applications...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.