我有一个使用 MSIX 部署的 .NET 6 Windows 桌面应用程序。
我可以在自己的计算机上运行和调试它,但无法使用 Azure Pipelines YAML 进行构建。
我收到错误:
C:\Program Files\dotnet\sdk\6.0.101\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets(267,5):错误NETSDK1047:资产文件'D:\a\1\s\ MyApp\obj\project.assets.json' 没有“net6.0-windows10.0.19041.0/win-x64”的目标。确保恢复已运行并且您已将“net6.0-windows10.0.19041.0”包含在项目的 TargetFrameworks 中。您可能还需要在项目的运行时标识符中包含“win-x64”。
应用程序项目文件:
<TargetFramework>net6.0-windows10.0.19041.0</TargetFramework>
<RuntimeIdentifier>win10-x64</RuntimeIdentifier>
<Platforms>x64</Platforms>
Run Code Online (Sandbox Code Playgroud)
安装程序项目文件:
<TargetPlatformVersion>10.0.19041.0</TargetPlatformVersion>
<TargetPlatformMinVersion>10.0.19041.0</TargetPlatformMinVersion>
<TargetFramework>net6.0-windows10.0.19041.0</TargetFramework>
<RuntimeIdentifier>win10-x64</RuntimeIdentifier>
Run Code Online (Sandbox Code Playgroud)
管道任务是使用 Visual Studio 2022 (v. 17) 进行 VSBuild,Nuget 工具是使用 NugetToolInstaller 任务安装的 6.0 版。
Azure Windows 代理使用 vmImage:“windows-2022”
错误说:
确保您已在项目的 TargetFrameworks 中包含“net6.0-windows10.0.19041.0”。您可能还需要在项目的运行时标识符中包含“win-x64”。
我已在应用程序和安装程序项目的 TargetFramework 中添加了“net6.0-windows10.0.19041.0”。
如果我win10-x64用win-x64它替换可以构建,但我需要使用win10-x64,因为其中一个包需要它(Microsoft.PowerShell.SDK 和 System.Management.Automation)。
新:添加/p:RestoreLockedMode=trueVS Build 任务后,我现在收到错误:
MyApp.Installer.wapproj:错误 NU1004:项目 MyApp 没有兼容的目标框架。包锁定文件与项目依赖项不一致,因此无法在锁定模式下运行恢复。禁用 RestoreLockedMode MSBuild 属性或传递显式 --force-evaluate 选项来运行还原以更新锁定文件。
新新:我升级到.NET 7,但遇到了同样的错误。
我该如何修复该错误?
我已将 MSIX WPF 应用程序从 .NET 7 升级到 .NET 8,并且它在我自己的计算机上运行良好。但是当我尝试在 Azure DevOps 中构建它时,我收到错误:
C:\agent\_work\_tool\dotnet\sdk\8.0.100\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.FrameworkReferenceResolution.targets(491,5):
Error NETSDK1112: The runtime pack for Microsoft.NETCore.App.Runtime.win-x64 was not downloaded. Try running a NuGet restore with the RuntimeIdentifier 'win-x64'.
C:\agent\_work\_tool\dotnet\sdk\8.0.100\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.FrameworkReferenceResolution.targets(491,5): Error NETSDK1112: The runtime pack for Microsoft.WindowsDesktop.App.Runtime.win-x64 was not downloaded. Try running a NuGet restore with the RuntimeIdentifier 'win-x64'.
Run Code Online (Sandbox Code Playgroud)
我在本地构建服务器上和使用托管代理时都会遇到相同的错误。
我使用这些任务在计算机上安装和验证 .NET 8:
- task: UseDotNet@2
inputs:
version: '8.x'
- task: PowerShell@2
displayName: 'Check .NET Version and SDKs'
inputs:
targetType: 'inline'
script: |
dotnet --version
dotnet --list-sdks …Run Code Online (Sandbox Code Playgroud) 我有一个引用用户控件库的 .NET 5 WPF 应用程序 (x64)。当我直接引用库时,一切正常。
但是,当我创建 Nuget 包,然后在构建服务器上构建引用 Nuget 包的应用程序时,我得到:
NU1202:MyControls 包与 net50-windows (.NETFramework、Version=v5.0、Profile=windows)/win-x64 不兼容。
MyControls 包支持:
- net50-windows7.0(.NETFramework,版本=v5.0,配置文件=windows7.0)
- netcoreapp3.1(.NETCoreApp,版本=v3.1)
MyControls .csproj 文件包含以下内容:
<PropertyGroup>
<TargetFrameworks>netcoreapp3.1;net5.0-windows</TargetFrameworks>
<UseWPF>true</UseWPF>
<RuntimeIdentifiers>win;win-x64</RuntimeIdentifiers>
</PropertyGroup>
Run Code Online (Sandbox Code Playgroud)
应用程序 .csproj 文件包含以下内容:
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net5.0-windows</TargetFramework>
<UseWPF>true</UseWPF>
<RuntimeIdentifiers>win-x64</RuntimeIdentifiers>
</PropertyGroup>
Run Code Online (Sandbox Code Playgroud)
我不明白为什么它会输出 Windows 7 的包。我发现这个链接描述了它: https: //github.com/dotnet/sdk/issues/14553 那里的评论之一似乎与我的情况相符:
我也遇到了同样的现象,当我尝试在 .NET 5 应用程序中安装这些包时,它告诉我“net5.0”和“net.5.0-windows7.0”不兼容。不过,我所有的项目实际上都是“net5.0-windows”。
如果我手动将 net5.0-windows7.0 文件夹复制到 .nuget/packages 下的新文件夹 net5.0-windows,Nuget 错误就会消失。
但我得到了这个编译错误:
错误CS0103:名称“Windows”在当前上下文中不存在
我应该更改什么才能使 Nuget 恢复正常工作?
我收到了一个错误报告,似乎来自以下代码:
public class AnimationChannelCollection : ReadOnlyCollection<BoneKeyFrameCollection>
{
private Dictionary<string, BoneKeyFrameCollection> dict =
new Dictionary<string, BoneKeyFrameCollection>();
private ReadOnlyCollection<string> affectedBones;
// This immutable data structure should not be created by the library user
internal AnimationChannelCollection(IList<BoneKeyFrameCollection> channels)
: base(channels)
{
// Find the affected bones
List<string> affected = new List<string>();
foreach (BoneKeyFrameCollection frames in channels)
{
dict.Add(frames.BoneName, frames);
affected.Add(frames.BoneName);
}
affectedBones = new ReadOnlyCollection<string>(affected);
}
public BoneKeyFrameCollection this[string boneName]
{
get { return dict[boneName]; }
}
}
Run Code Online (Sandbox Code Playgroud)
这是读取字典的调用代码:
public override Matrix GetCurrentBoneTransform(BonePose pose) …Run Code Online (Sandbox Code Playgroud)