我的解决方案包含 Framework 4.8 项目、.Net Standard 2.1 项目和 .net6 项目。它已经运行了几周,没有出现任何问题。
今天构建管道开始失败并出现错误
##[错误]nuget 命令失败,退出代码(1) 和错误(错误 NU5049:不支持 SDK 样式项目的 pack 命令,请使用
dotnet pack 或 msbuild -t:pack 来打包此项目。你可以
通过设置覆盖此行为
“NUGET_ENABLE_LEGACY_CSPROJ_PACK”环境变量设置为“true”。
错误 NU5000:无法构建包。
我尝试编辑 YAML 将命令从 pack 更改为 dotnet pack,但出现值不接受错误。
[Update]
I am trying to see exactly how I correct the syntax.
I tried typing dotnet into the tasks bar and get the following
我尝试了 .Net Core 但它插入的命令有 -task:DotNetCoreCLI@2
这也不起作用。
dotnet pack 的 YAML 是什么?
我的 YAML 如下
trigger:
- master
pool:
vmImage: 'windows-2022'
variables:
solution: '**/*.sln'
buildPlatform: 'Any CPU'
buildConfiguration: 'Release'
Major: '2'
Minor: '0'
Patch: '0'
steps:
- task: NuGetToolInstaller@0
inputs:
versionSpec: '>=4.3.0'
checkLatest: true
- task: NuGetCommand@2
inputs:
command: 'restore'
restoreSolution: '**/*.sln'
feedsToUse: 'config'
nugetConfigPath: 'WinFormsCoreMain\nuget.config'
patchVersion: '$(Patch)'
- task: VSBuild@1
inputs:
solution: '$(solution)'
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
- task: DotNetCoreCLI@2
inputs:
command: 'pack'
packagesToPack: '**/*.csproj'
versioningScheme: byPrereleaseNumber
majorVersion: '$(Major)'
minorVersion: '$(Minor)'
我将恢复命令更改为
- task: DotNetCoreCLI@2
inputs:
command: 'restore'
feedsToUse: 'config'
nugetConfigPath: 'WinFormsCoreMain\nuget.config'
patchVersion: '$(Patch)'
现在出现错误
##[警告].NET 5 与较旧的 Nuget 版本(
##[错误]错误:进程“C:\Program Files\dotnet\dotnet.exe”失败,退出代码为 1
##[error]包恢复失败
信息:Azure Pipelines 托管代理已更新,现在包含 .Net 5.x SDK/运行时以及较旧的 .Net Core 版本
目前是 lts。除非您已锁定 SDK 版本
您的项目,5.x SDK 可能会被选中,这可能会破坏
与以前版本相比的行为。您可以了解更多有关
这里的重大变化:https://docs.microsoft.com/en-us/dotnet/core/tools/ https://docs.microsoft.com/en-us/dotnet/core/tools/ and
https://docs.microsoft.com/en-us/dotnet/core/compatibility/ https://docs.microsoft.com/en-us/dotnet/core/compatibility/。学习
有关更多此类更改和故障排除,请参阅此处:https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/build/dotnet-core-cli?view=azure-devops#troubleshooting https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/build/dotnet-core-cli?view=azure-devops#troubleshooting
我想我可以尝试单击“新建管道”来查看 DevOps 想要什么,但我收到了 503 错误。
但是,当我单击“查看我们的服务状态更新”时,没有报告任何问题。
[Update]
现在我可以创建一个新的管道
当我运行它时,错误是
##[warning]An image label with the label vs2017-win2016 does not exist.
,##[error]The remote provider was unable to process the request.
Pool: Azure Pipelines
Image: vs2017-win2016
我会尝试
vmImage: 'windows-2022'
[Update]
我已经回滚,现在我只想尝试将“NUGET_ENABLE_LEGACY_CSPROJ_PACK”环境变量设置为“true”
[更新]
根据 Zar Shardan 的建议,我更新为使用 DotNetCoreCLI@2 包。
然后我遇到了这个错误。
##[警告].NET 5 与较旧的 Nuget 版本(
所以我尝试将恢复命令更改为
- task: DotNetCoreCLI@2
inputs:
command: 'restore'
feedsToUse: 'config'
nugetConfigPath: 'WinFormsCoreMain\nuget.config'
patchVersion: '$(Patch)'
构建开始失败并显示类似消息
Task "Error" skipped, due to false condition; ('$(MSBuildToolsVersion)' == '2.0' and ('$(ProjectToolsVersion)' !=
'2.0' 和 '$(ProjectToolsVersion)' != '')) 被评估为 ('Current'
== '2.0' 和 ('' != '2.0' 和 '' != ''))。
and
Nuget.Config 不是有效的 XML
and
##[错误]错误:进程“C:\Program Files\dotnet\dotnet.exe”失败,退出代码为 1
##[error]包恢复失败
我注意到 DotNetCoreCLI@2 不支持
restoreSolution: '**/*.sln'
并想知道我的问题是否与此有关。
[Update]
我的构建 YAML 是
- task: VSBuild@1
inputs:
solution: '$(solution)'
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
我认为这不适用于更新的 dotnetcorecli
[更新]
尝试使用 DotNetCoreCLI@2 相反,我遇到了新问题 https://stackoverflow.com/questions/75632440/nuget-config-is-not-valid-xml-path-running-dotnetcorecli.