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



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

- task: DotNetCoreCLI@2
displayName: Publish web API artifact
inputs:
command: publish
publishWebProjects: false
arguments: '$(Build.SourcesDirectory)XYZ.Research.APIXYZ.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:windowssystem32chcp.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:hostedtoolcachewindowsdotnetdotnet.exe publish d:a1sXYZ.Research.APIXYZ.Research.API.csproj --configuration Release --output testpath
.....
some warning message ignored
.....
2020-07-31T12:04:38.0843543Z   XYZ.Research.API -> d:a1sXYZ.Research.APIbinReleasenetcoreapp3.0XYZ.Research.API.dll
2020-07-31T12:04:38.9127845Z   XYZ.Research.API -> d:a1stestpath
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:a1stestpathXYZ.Reserch.API.zip
d:a1stestpathXYZ.Reserch.APIXYZ.Reserch.API.zip

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

以前有人看到这个问题吗?如有任何帮助,我们将不胜感激。

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

正如@源代码所建议的那样,我使用了task"PowerShell@2"并且发现工件文件实际上在";D: \a\s\testpath\testpath.zip";。这意味着"testpath"子文件夹是在$(Build.SourceDirectory(中创建的,工件文件也被重命名为"test.zip"。

我建议您在DotNetCoreCLI@2任务,并使用"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文件。有一个名为projects的参数应该用于此操作。您还可以考虑使用工件暂存目录作为输出目录。任务看起来是这样的:

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

需要注意的一点是,如果确实更改了输出目录,请确保更改PowerShell或Bash任务的工作目录,以便输出正确目录的内容。它默认为$(Build.SourcesDirectory(,因此如果需要,请确保对此进行更改。

相关内容

  • 没有找到相关文章

最新更新