构建和发布工件任务问题

bit*_*ift 1 azure-pipelines

PublishBuildArtifacts@1
https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/utility/publish-build-artifacts?view=azure-devops
问题:
(1)指定artifactName的结果是什么?从文档中尚不清楚。我在大多数示例中都看到了这一点,它成为 $(Build.ArtifactStagingDirectory) 路径中的子文件夹。如果我有额外的任务来构建包含多个项目的解决方案的不同部分,我可以指定另一个例如。'drop2' 还是这个“drop”很特别?

(2) 如果使用私有 nuget feed,为什么还必须包含 nuget.config 文件来引用该包?私人源是通过 azure 项目设置中的服务连接设置的。看来你应该可以离开了

feedsToUse: 'config'
nugetConfigPath: 'Nuget.config'
Run Code Online (Sandbox Code Playgroud)

(3) 如果我在一个解决方案中有多个项目 - 例如。.net core Web 应用程序以及多个针对 .net standard 2.x 的类库以及 .net core 控制台应用程序,何时使用以下任一任务更好:
VSBuild@1 或 DotNetCoreCLI@2
最终结果构建的重点是我在输出
drop 和 Dropsrvc 中有两个子文件夹,这正是我所需要的。Dropsvc 将我的服务项目保存在 zip 文件中

我想将 .net core Web 应用程序发布为发布管道中的可复制文件夹。我已经完成了这项工作,主要是通过重新利用我在 .net 框架项目中所做的另一个构建来进行反复试验,但现在我想知道我是否应该使用 DotNetCoreCLI 任务?

这是我的 yaml 文件。如何替代VS

# .NET Desktop
# Build and run tests for .NET Desktop or Windows classic desktop solutions.
# Add steps that publish symbols, save build artifacts, and more:
# https://learn.microsoft.com/azure/devops/pipelines/apps/windows/dot-net

#trigger:
#- dev

pool:
  vmImage: 'windows-latest'

variables:
  solution: '**/*.sln'
  jobSrvProj: '**/myapp.sln.job/myapp.sln.JobSrv.csproj'
  reloWeb: '**/myapp.sln.Web/myapp.sln.Web.csproj'
  buildPlatform: 'Any CPU'
  buildConfiguration: 'Dev'

steps:
- task: NuGetToolInstaller@1

- task: NuGetCommand@2
  inputs:
    command: 'restore'
    restoreSolution: '$(solution)'
    feedsToUse: 'config'
    nugetConfigPath: 'Nuget.config'
    externalFeedCredentials: 'Telerik nuget feed'


# web
- task: VSBuild@1
  inputs:
    solution: '$(solution)'
    msbuildArgs: /p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactstagingdirectory)\\"  /p:UseWPP_CopyWebApplication=true  /p:OutDir="$(build.artifactstagingdirectory)" 
    platform: '$(buildPlatform)'
    configuration: '$(buildConfiguration)'

- task: PublishBuildArtifacts@1
  inputs:
    PathtoPublish: '$(Build.ArtifactStagingDirectory)'
    ArtifactName: 'drop'
    publishLocation: 'Container'


# jobSrv
- task: VSBuild@1
  inputs:
    solution: '$(jobSrvProj)'
    msbuildArgs: '/p:OutputPath="$(Build.BinariesDirectory)\jobSrv-$(Build.BuildId)"'
    platform: '$(buildPlatform)'
    configuration: '$(buildConfiguration)'

# jobSrv
- task: ArchiveFiles@2
  inputs:
    rootFolderOrFile: '$(Build.BinariesDirectory)\jobSrv-$(Build.BuildId)'
    includeRootFolder: false
    archiveType: 'zip'
    archiveFile: '$(Build.ArtifactStagingDirectory)/jobSrv-$(Build.BuildId)/jobSrv-$(Build.BuildId).zip'
    replaceExistingArchive: true

- task: PublishBuildArtifacts@1
  inputs:
    PathtoPublish: '$(Build.ArtifactStagingDirectory)\jobSrv-$(Build.BuildId)'
    ArtifactName: 'dropsrvc'
    publishLocation: 'Container'
Run Code Online (Sandbox Code Playgroud)

Cec*_*SFT 5

  1. 这是您自己指定的 Artifact 名称。通常,您将$(Build.ArtifactStagingDirectory)文件夹发布到 DevOps。如果您想要多个工件,您可以添加多个PublishBuildArtifacts任务。例如:

在此输入图像描述

在此输入图像描述

  1. 任务中不必包含 nuget.config 文件Nuget。您可以在此处从 Azure Artifacts 和/或 NuGet.org 选择源,也可以将 nuget.config 文件提交到源代码存储库并在此处设置其路径。

  2. VSBuild 任务使用 MSBuild 构建项目,而 DotNetCoreCLI 任务构建、测试、打包或发布 dotnet 应用程序,或运行自定义 dotnet 命令。您可以使用 VSBuild 任务来构建 .net Framework 项目,并在同一管道中使用 DotNetCoreCLI 任务构建 .net core 项目。