这是我的 .yml 文件的一部分:
pool:
vmImage: 'ubuntu-latest'
- task: DotNetCoreCLI@2
inputs:
commands: publish
publishWebProjects: true
arguments: '-c Release -r linux-x64 --no-self-contained --output $(Build.ArtifactStagingDirectory) .\src\BasicDemoApi\BasicDemoApi.csproj'
zipAfterPublish: true
- task: PublishBuildArtifacts@1
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
ArtifactName: 'drop'
我正在尝试发布 .NET6 API 项目。我可以看到已发布的工件,但它不是 .zip 格式。
我尝试将 publishWebProjects
更改为 true 和 false,但没有效果。
这是日志:
Starting: DotNetCoreCLI
==============================================================================
Task : .NET Core
Description : Build, test, package, or publish a dotnet application, or run a custom dotnet command
Version : 2.210.0
Author : Microsoft Corporation
Help : https://docs.microsoft.com/azure/devops/pipelines/tasks/build/dotnet-core-cli
==============================================================================
Info: .NET Core SDK/runtime 2.2 and 3.0 are now End of Life(EOL) and have been removed from all hosted agents. If you're using these SDK/runtimes on hosted agents, kindly upgrade to newer versions which are not EOL, or else use UseDotNet task to install the required version.
/usr/bin/dotnet build -dl:CentralLogger,"/home/vsts/work/_tasks/DotNetCoreCLI_5541a522-603c-47ad-91fc-a4b1d163081b/2.210.0/dotnet-build-helpers/Microsoft.TeamFoundation.DistributedTask.MSBuild.Logger.dll"*ForwardingLogger,"/home/vsts/work/_tasks/DotNetCoreCLI_5541a522-603c-47ad-91fc-a4b1d163081b/2.210.0/dotnet-build-helpers/Microsoft.TeamFoundation.DistributedTask.MSBuild.Logger.dll" -c Release -r linux-x64 --no-self-contained --output /home/vsts/work/1/a .\src\BasicDemoApi\BasicDemoApi.csproj
MSBuild version 17.4.0+18d5aef85 for .NET
Determining projects to restore...
Restored /home/vsts/work/1/s/src/BasicDemoApi/BasicDemoApi.csproj (in 336 ms).
##[warning]src/BasicDemoApi/Data/CommandContext.cs(8,12): Warning CS8618: Non-nullable property 'CommandItems' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.
/home/vsts/work/1/s/src/BasicDemoApi/Data/CommandContext.cs(8,12): warning CS8618: Non-nullable property 'CommandItems' must contain a non-null value when exiting constructor. Consider declaring the property as nullable. [/home/vsts/work/1/s/src/BasicDemoApi/BasicDemoApi.csproj]
##[warning]src/BasicDemoApi/Data/SqlCommandApiRepo.cs(33,16): Warning CS8603: Possible null reference return.
/home/vsts/work/1/s/src/BasicDemoApi/Data/SqlCommandApiRepo.cs(33,16): warning CS8603: Possible null reference return. [/home/vsts/work/1/s/src/BasicDemoApi/BasicDemoApi.csproj]
BasicDemoApi -> /home/vsts/work/1/a/BasicDemoApi.dll
Build succeeded.
/home/vsts/work/1/s/src/BasicDemoApi/Data/CommandContext.cs(8,12): warning CS8618: Non-nullable property 'CommandItems' must contain a non-null value when exiting constructor. Consider declaring the property as nullable. [/home/vsts/work/1/s/src/BasicDemoApi/BasicDemoApi.csproj]
/home/vsts/work/1/s/src/BasicDemoApi/Data/SqlCommandApiRepo.cs(33,16): warning CS8603: Possible null reference return. [/home/vsts/work/1/s/src/BasicDemoApi/BasicDemoApi.csproj]
2 Warning(s)
0 Error(s)
Time Elapsed 00:00:03.71
Info: Azure Pipelines hosted agents have been updated and now contain .Net 5.x SDK/Runtime along with the older .Net Core version which are currently lts. Unless you have locked down a SDK version for your project(s), 5.x SDK might be picked up which might have breaking behavior as compared to previous versions. You can learn more about the breaking changes here: https://docs.microsoft.com/en-us/dotnet/core/tools/ and https://docs.microsoft.com/en-us/dotnet/core/compatibility/ . To learn about more such changes and troubleshoot, refer here: https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/build/dotnet-core-cli?view=azure-devops#troubleshooting
Finishing: DotNetCoreCLI
我在这里做错了什么?
最佳答案
任务“DotNetCoreCLI@2”的正确输入是:
command: publish
代替命令s:发布
关于Azure DevOps 任务 DotNetCoreCLI@2 未将我的 Web API 项目发布为 .zip,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/75033020/