You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Visual Studio 2022发布Blazor MAUI混合应用遇依赖目标缺失问题

.NET 9 Windows平台发布时类库依赖项异常问题
  • 应用程序与类库均以.NET 9为目标框架,在Release和Debug配置下可正常构建运行(对应构建成功、依赖正常截图)。
  • 使用VS 2022 v17.14.0 Preview 1.0尝试发布Windows平台时,类库依赖项出现黄色感叹号(对应依赖项异常截图),同时收到以下错误提示:

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.

project.assets.json文件开头内容如下:

{  
  "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": {  
        ...  
      }  
    }  
  },

发布配置文件内容如下:

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

所有文件均由工具自动生成,通过CLI可正常完成发布,但VS发布时出现上述异常。

内容的提问来源于stack exchange,提问作者ZorgoZ

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.14 05:44:53