Kir*_*eed 10 azure-devops azure-pipelines-yaml
我的解决方案包含 Framework 4.8 项目、.Net Standard 2.1 项目和 .net6 项目。它已经运行了几周,没有出现任何问题。
\n今天构建管道开始失败并出现错误
\n\n\n##[错误]nuget 命令失败,退出代码(1) 和错误(错误 NU5049:不支持 SDK 样式项目的 pack 命令,请使用\ndotnet pack 或 msbuild -t:pack 来打包此项目。您可以通过将\n\xe2\x80\x98NUGET_ENABLE_LEGACY_CSPROJ_PACK\xe2\x80\x99 环境变量设置为 \xe2\x80\x98true\xe2\x80\x99 来覆盖此行为。\n错误 NU5000: 无法构建包。
\n
我尝试编辑 YAML 将命令从 pack 更改为 dotnet pack,但出现值不接受错误。
\n\n[更新]
\n我试图确切地了解如何更正语法。\n我尝试在任务栏中输入 dotnet 并得到以下内容\n
我尝试了 .Net Core 但它插入的命令有 -task:DotNetCoreCLI@2\n 这也不起作用。
\ndotnet pack 的 YAML 是什么?
\n我的 YAML 如下
\ntrigger:\n- master\n\npool:\n vmImage: \'windows-2022\'\n\nvariables:\n solution: \'**/*.sln\'\n buildPlatform: \'Any CPU\'\n buildConfiguration: \'Release\'\n Major: \'2\'\n Minor: \'0\'\n Patch: \'0\'\n\nsteps:\n- task: NuGetToolInstaller@0\n inputs:\n versionSpec: \'>=4.3.0\'\n checkLatest: true\n\n- task: NuGetCommand@2\n inputs:\n command: \'restore\'\n restoreSolution: \'**/*.sln\'\n feedsToUse: \'config\'\n nugetConfigPath: \'WinFormsCoreMain\\nuget.config\'\n patchVersion: \'$(Patch)\'\n\n- task: VSBuild@1\n inputs:\n solution: \'$(solution)\'\n platform: \'$(buildPlatform)\'\n configuration: \'$(buildConfiguration)\'\n\n- task: DotNetCoreCLI@2\n inputs:\n command: \'pack\'\n packagesToPack: \'**/*.csproj\'\n versioningScheme: byPrereleaseNumber\n majorVersion: \'$(Major)\'\n minorVersion: \'$(Minor)\'\n \nRun Code Online (Sandbox Code Playgroud)\n我将恢复命令更改为
\n- task: DotNetCoreCLI@2\n inputs:\n command: \'restore\'\n feedsToUse: \'config\'\n nugetConfigPath: \'WinFormsCoreMain\\nuget.config\'\n patchVersion: \'$(Patch)\'\nRun Code Online (Sandbox Code Playgroud)\n现在出现错误
\n\n\n##[警告].NET 5 与较旧的 Nuget 版本 (<=5.7) 存在一些兼容性问题,因此如果您使用较旧的 Nuget 版本(而不是\ndotnet cli)进行恢复,则使用 dotnet cli 命令(例如 dotnet\ nbuild)依赖于此类恢复的软件包可能会失败。要缓解\n此类错误,您可以:(1) - 使用 dotnet cli 进行恢复,(2) - 使用\nNuget 版本 5.8 进行恢复,(3) - 使用较旧 sdk\n版本的 global.json(<=3 ) 构建\n##[错误]错误:进程 \'C:\\Program Files\\dotnet\\dotnet.exe\' 失败,退出代码为 1\n##[错误]尝试执行时发生错误打包文件。
\n
\n\n##[错误]错误:进程 \'C:\\Program Files\\dotnet\\dotnet.exe\' 失败,退出代码为 1\n##[错误]包无法还原\n信息:Azure Pipelines 托管代理已更新,现在包含 .Net 5.x SDK/运行时以及较旧的 .Net Core 版本\n目前已发布。除非您已锁定项目的 SDK 版本,否则可能会选择 5.x SDK,与以前的版本相比,它可能会出现破坏行为。您可以在此处详细了解\n重大更改:\n https://docs.microsoft.com/en-us/dotnet/core/tools/和\n https://docs.microsoft.com/en-us/ dotnet/核心/兼容性/ . 要了解\n更多此类更改和故障排除,请参阅此处:\n https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/build/dotnet-core-cli?view=azure-devops #故障排除
\n
我想我可以尝试单击“新建管道”来查看 DevOps 想要什么,但我收到了 503 错误。
\n\n但是,当我单击“查看我们的服务状态更新”时,没有报告任何问题。
\n[更新]
\n现在我可以创建一个新管道\n当我运行它时,错误是
\n##[warning]An image label with the label vs2017-win2016 does not exist.\n,##[error]The remote provider was unable to process the request.\nPool: Azure Pipelines\nImage: vs2017-win2016\nRun Code Online (Sandbox Code Playgroud)\n我会尝试
\nvmImage: \'windows-2022\'\nRun Code Online (Sandbox Code Playgroud)\n[更新]
\n我已经回滚了,现在我只想尝试将“NUGET_ENABLE_LEGACY_CSPROJ_PACK”环境变量设置为“true”
\n[更新]\n根据 Zar Shardan\ 的建议,我更新为对包使用 DotNetCoreCLI@2。\n然后我遇到了此错误。
\n\n\n##[警告].NET 5 与较旧的 Nuget 版本 (<=5.7) 存在一些兼容性问题,因此如果您使用较旧的 Nuget 版本(而不是\ndotnet cli)进行恢复,则使用 dotnet cli 命令(例如 dotnet\ nbuild)依赖于此类恢复的软件包可能会失败。要缓解\n此类错误,您可以:(1) - 使用 dotnet cli 进行恢复,(2) - 使用\nNuget 版本 5.8 进行恢复,(3) - 使用较旧 sdk\n版本的 global.json(<=3 ) 构建\n##[错误]错误:进程 \'C:\\Program Files\\dotnet\\dotnet.exe\' 失败,退出代码为 1\n##[错误]尝试执行时发生错误打包文件。
\n
所以我尝试将恢复命令更改为
\n- task: DotNetCoreCLI@2\n inputs:\n command: \'restore\'\n feedsToUse: \'config\'\n nugetConfigPath: \'WinFormsCoreMain\\nuget.config\'\n patchVersion: \'$(Patch)\'\n \nRun Code Online (Sandbox Code Playgroud)\n构建开始失败并显示类似消息
\n\n\nRun Code Online (Sandbox Code Playgroud)\nTask "Error" skipped, due to false condition; (\'$(MSBuildToolsVersion)\' == \'2.0\' and (\'$(ProjectToolsVersion)\' !=\n\'2.0\' 和 \'$(ProjectToolsVersion)\' != \'\')) 被评估为 (\'Current\'\n== \'2.0\' and (\'\' != \' 2.0\' 和 \'\' != \'\'))。
\n
和
\n\n\nNuget.Config 不是有效的 XML
\n
和
\n\n\n##[错误]错误:进程 \'C:\\Program Files\\dotnet\\dotnet.exe\' 失败,退出代码为 1\n##[错误]程序包无法还原
\n
我注意到DotNetCoreCLI@2不支持
\nrestoreSolution: \'**/*.sln\'\nRun Code Online (Sandbox Code Playgroud)\n并想知道我的问题是否与此有关。
\n[更新]
\n我的构建 YAML 是
\n- task: VSBuild@1\n inputs:\n solution: \'$(solution)\'\n platform: \'$(buildPlatform)\'\n configuration: \'$(buildConfiguration)\'\nRun Code Online (Sandbox Code Playgroud)\n我认为这不适用于更新的 dotnetcorecli
\n[更新]\n尝试使用 DotNetCoreCLI@2 代替我遇到了新问题。
\n只需将 NuGetCommand@2 替换为 DotNetCoreCLI@2 即可解决原始 OP 的问题:
-task: DotNetCoreCLI@2
inputs:
command: 'pack'
packagesToPack: '**/*.csproj'
...etc...
Run Code Online (Sandbox Code Playgroud)
我通过添加让它工作
NUGET_ENABLE_LEGACY_CSPROJ_PACK: true
Run Code Online (Sandbox Code Playgroud)
到
variables:
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3806 次 |
| 最近记录: |