gpt4 book ai didi

Azure 管道任务 DotNetCoreCLI@2 - 工件的输出文件夹

转载 作者:行者123 更新时间:2023-12-05 03:51:06 25 4
gpt4 key购买 nike

在我们的 .NET Web API 项目中,我们尝试在 Azure DevOps 中构建 API 项目,并将工件发布到具有以下管道任务的文件夹:

- task: DotNetCoreCLI@2
displayName: Publish web API artifact
inputs:
command: publish
publishWebProjects: false
arguments: '$(Build.SourcesDirectory)\XYZ.Research.API\XYZ.Research.API.csproj --configuration $(BuildConfiguration) --output testpath'
zipAfterPublish: true
modifyOutputPath: true

但我不确定该工件保存在哪个文件夹中。以下是此步骤的日志:

2020-07-31T12:04:23.6282186Z ##[section]Starting: Publish web API artifact
2020-07-31T12:04:23.6590490Z ==============================================================================
2020-07-31T12:04:23.6591051Z Task : .NET Core
2020-07-31T12:04:23.6591393Z Description : Build, test, package, or publish a dotnet application, or run a custom dotnet command
2020-07-31T12:04:23.6591740Z Version : 2.172.2
2020-07-31T12:04:23.6591974Z Author : Microsoft Corporation
2020-07-31T12:04:23.6592357Z Help : https://learn.microsoft.com/azure/devops/pipelines/tasks/build/dotnet-core-cli
2020-07-31T12:04:23.6592942Z ==============================================================================
2020-07-31T12:04:25.5581194Z [command]C:\windows\system32\chcp.com 65001
2020-07-31T12:04:25.5581889Z Active code page: 65001
2020-07-31T12:04:25.5583746Z 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.
2020-07-31T12:04:25.5588792Z [command]C:\hostedtoolcache\windows\dotnet\dotnet.exe publish d:\a\1\s\XYZ.Research.API\XYZ.Research.API.csproj --configuration Release --output testpath
.....
some warning message ignored
.....
2020-07-31T12:04:38.0843543Z XYZ.Research.API -> d:\a\1\s\XYZ.Research.API\bin\Release\netcoreapp3.0\XYZ.Research.API.dll
2020-07-31T12:04:38.9127845Z XYZ.Research.API -> d:\a\1\s\testpath\
2020-07-31T12:04:46.0295716Z Info: Azure Pipelines hosted agents have been updated to contain .Net Core 3.x (3.1) SDK/Runtime along with 2.1. Unless you have locked down a SDK version for your project(s), 3.x SDK might be picked up which might have breaking behavior as compared to previous versions.
2020-07-31T12:04:46.0296632Z Some commonly encountered changes are:
2020-07-31T12:04:46.0297619Z If you're using `Publish` command with -o or --Output argument, you will see that the output folder is now being created at root directory rather than Project File's directory. To learn about more such changes and troubleshoot, refer here: https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/build/dotnet-core-cli?view=azure-devops#troubleshooting
2020-07-31T12:04:46.0442329Z ##[section]Finishing: Publish web API artifact

因为我们在下一步(部署)中需要文件位置,所以我尝试了

d:\a\1\s\testpath\XYZ.Reserch.API.zip
d:\a\1\s\testpath\XYZ.Reserch.API\XYZ.Reserch.API.zip

但这些位置都没有工件文件。

以前有人见过这个问题吗?任何帮助将不胜感激。

--------------------更新---------------------------------------- ----

正如@Source Code所建议的,我使用了任务“PowerShell@2”,发现工件文件实际上位于“D:\a\1\s\testpath\testpath.zip”中。这意味着“testpath”子文件夹将在 $(Build.SourceDirectory) 中创建,并且工件文件也将重命名为“test.zip”。

最佳答案

我建议您在 DotNetCoreCLI@2 任务之后添加 PowerShell/Bash/Cmd 任务,并使用“ls”命令运行内联脚本,该命令应为您列出结果中的所有项目。这将使您能够看到任务完成后实际存在的内容。

如果在 Windows 代理上:

- task: PowerShell@2
displayName: List Files Post Publish
inputs:
targetType: inline
script: Get-ChildItem

如果在 Linux 或 Mac 上

- task: Bash@3
displayName: List Files Post Publish
inputs:
targetType: inline
script: ls

此外,我注意到您正在通过arguments 参数提供您的csproj 文件。有一个名为项目的参数应该用于此目的。您也可以考虑使用工件暂存目录作为输出目录。该任务如下所示:

- task: DotNetCoreCLI@2
displayName: Publish web API artifact
inputs:
command: publish
projects: '$(Build.SourcesDirectory)\XYZ.Research.API\XYZ.Research.API.csproj'
publishWebProjects: false
arguments: '--configuration $(BuildConfiguration) --output $(Build.ArtifactStagingDirectory)'
zipAfterPublish: true
modifyOutputPath: true

需要注意的一件重要事情是,如果您确实更改了输出目录,请确保更改 PowerShell 或 Bash 任务的工作目录,以便输出正确目录的内容。它默认为 $(Build.SourcesDirectory),因此请确保在需要时更改它。

关于Azure 管道任务 DotNetCoreCLI@2 - 工件的输出文件夹,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63191765/

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