gpt4 book ai didi

azure-devops - Azure DevOps : Assets file doesn't have a target for '.NETCoreApp,Version=v2.2/linux-x64'

转载 作者:行者123 更新时间:2023-12-04 12:17:12 25 4
gpt4 key购买 nike

我正在使用首先安装 .Net Core SDK (2.2) 的任务组为 Azure DevOps 中的 AspNet Core Web Api 创建构建管道,然后使用 dotnet restore 进行包还原(使用 VSTS 提要),然后构建项目。

在构建步骤,我提供以下参数:
--configuration Release --runtime $(Target Platform) --no-restore /p:Version=$(Major Version).$(Minor Version).$(Build.BuildNumber) .

build的所有步骤步骤成功。但是,我在构建步骤中收到以下错误:

[command]C:\windows\system32\chcp.com 65001
Active code page: 65001
[command]C:\hostedtoolcache\windows\dotnet\dotnet.exe build D:\a\1\s\WebApp\WebApp.csproj --configuration Release --runtime linux-x64 --no-restore /p:Version=1.0.40
Microsoft (R) Build Engine version 16.2.32702+c4012a063 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

C:\hostedtoolcache\windows\dotnet\sdk\2.2.401\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets(208,5): error NETSDK1047: Assets file 'D:\a\1\s\WebApp\obj\project.assets.json' doesn't have a target for '.NETCoreApp,Version=v2.2/linux-x64'. Ensure that restore has run and that you have included 'netcoreapp2.2' in the TargetFrameworks for your project. You may also need to include 'linux-x64' in your project's RuntimeIdentifiers. [D:\a\1\s\WebApp\WebApp.csproj]

Build FAILED.

C:\hostedtoolcache\windows\dotnet\sdk\2.2.401\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets(208,5): error NETSDK1047: Assets file 'D:\a\1\s\WebApp\obj\project.assets.json' doesn't have a target for '.NETCoreApp,Version=v2.2/linux-x64'. Ensure that restore has run and that you have included 'netcoreapp2.2' in the TargetFrameworks for your project. You may also need to include 'linux-x64' in your project's RuntimeIdentifiers. [D:\a\1\s\WebApp\WebApp.csproj]
0 Warning(s)
1 Error(s)

Time Elapsed 00:00:00.53
##[error]Error: The process 'C:\hostedtoolcache\windows\dotnet\dotnet.exe' failed with exit code 1
##[error]Dotnet command failed with non-zero exit code on the following projects : D:\a\1\s\WebApp\WebApp.csproj
##[section]Finishing: Build

但是,我查看了与 Visual Studio 相关的旧答案,但找不到与 Azure DevOps 管道相关的内容。

最佳答案

要解决此问题,请尝试删除 --no-restore .

要解释为什么在本地没有问题,那是因为当您在本地构建项目时,它使用的是以前版本的 物镜如果当前文件不满足编译条件,则缓存中存在的文件。您可以尝试删除 垃圾箱物镜本地文件,然后再次运行这些命令。您还将看到相同的错误。这是我在本地遇到的错误,通过删除 --no-restore 解决了.

默认情况下,如果您没有指定 --runtime linux-x64 ,它恢复的包的 RID 是 win-x64 .您只能通过运行 进行测试dotnet 恢复 使用自托管代理在 Azure Devops 中执行任务,并检查 project.assets.json 文件:

enter image description here

你会看到,如果没有指定,它恢复的包的默认 RID 是 win-x64 .同 dotnet 构建 任务,自 从 .NET Core 2.0 SDK 开始,dotnet restore 在您运行 dotnet build 时隐式运行 :

enter image description here

这时候,如果你指定了--no-restoredotnet build ,默认情况下,它将使用由任务“dotnet restore”恢复的包,其 RID 为 win-x64 . 但是在您的构建任务中,您指定了 runtime构建为 linux-x64 .这与包裹不符。这就是您收到消息的原因:error NETSDK1047: Assets file 'D:\a\1\s\WebApp\obj\project.assets.json' doesn't have a target for '.NETCoreApp,Version=v2.2/linux-x64'.
直接删除--no-restore然后再试一次

enter image description here

错误信息应该消失了。

关于azure-devops - Azure DevOps : Assets file doesn't have a target for '.NETCoreApp,Version=v2.2/linux-x64' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57754052/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com