[英]How do you build individual project artifacts in azure deveops pipeline
I have multiple projects contained in my repo that I would like to build individual zip artifact to deploy them each separately.我的存储库中包含多个项目,我想构建单独的 zip 工件以分别部署它们。 Currently, the pipeline builds one zip artifact that contains all the projects.
目前,管道构建了一个包含所有项目的 zip 工件。 How do I configure my azure-pipelines.yml file to accomplish this task?
如何配置我的 azure-pipelines.yml 文件来完成此任务? Below is my current file.
下面是我当前的文件。
trigger:
- master
pool:
vmImage: 'windows-latest'
variables:
solution: '**/*.sln'
buildPlatform: 'Any CPU'
buildConfiguration: 'Release'
steps:
- task: NuGetToolInstaller@1
- task: NuGetCommand@2
inputs:
restoreSolution: '$(solution)'
- task: VSBuild@1
inputs:
solution: '$(solution)'
msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package
/p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true
/p:DesktopBuildPackageLocation="$(build.artifactStagingDirectory)\WebApp.zip"
/p:DeployIisAppPath="Default Web Site"'
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
- task: VSTest@2
inputs:
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
- task: PublishBuildArtifacts@1
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
ArtifactName: 'drop'
publishLocation: 'Container'
You can change the build parameter /p:PackageAsSingleFile=false
which will prevent all the projects from being zipped together.您可以更改构建参数
/p:PackageAsSingleFile=false
这将阻止所有项目被压缩在一起。 If you want to move the built files after the build, before the Publish Artifacts step, you can create a Copy files task that will copy the project's build folder to another location within the '$(Build.ArtifactStagingDirectory)'如果您想在构建后移动构建的文件,在发布工件步骤之前,您可以创建一个复制文件任务,将项目的构建文件夹复制到“$(Build.ArtifactStagingDirectory)”中的另一个位置
steps:脚步:
Though these will all still be placed within the 'drop' folder or whatever the $(build.artifactstagingdirectory) is called.尽管这些仍然会被放置在 'drop' 文件夹或任何 $(build.artifactstagingdirectory) 被调用的地方。 The only way to separate artifacts is to create separate pipelines for each project.
分离工件的唯一方法是为每个项目创建单独的管道。
It depends on how you define the MSBuild arguments.这取决于您如何定义 MSBuild 参数。 The
/p:DesktopBuildPackageLocation="$(build.artifactStagingDirectory)\\WebApp.zip" /p:DeployIisAppPath="Default Web Site"
is the direct cause of the issue, it calls msbuild to package all projects into one WebApp.zip
file. /p:DesktopBuildPackageLocation="$(build.artifactStagingDirectory)\\WebApp.zip" /p:DeployIisAppPath="Default Web Site"
是导致该问题的直接原因,它调用 msbuild 将所有项目打包到一个WebApp.zip
文件中。
With msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactStagingDirectory)"'
you can have separate ProjectName.zip
files under $(build.artifactStagingDirectory)
path.使用
msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactStagingDirectory)"'
您可以拥有单独的ProjectName.zip
文件在$(build.artifactStagingDirectory)
路径下。
And then you can use one Publish Build Artifact task
to publish whole $(build.artifactStagingDirectory)
directory which contains ProjectA.zip
, ProjectB.zip
...然后您可以使用一个
Publish Build Artifact task
来发布包含ProjectA.zip
、 ProjectB.zip
... 的整个$(build.artifactStagingDirectory)
目录。
Also you can use several Publish Build Artifact tasks
in one pipeline for your several output xx.zip
files.您还可以在一个管道中为多个输出
xx.zip
文件使用多个Publish Build Artifact tasks
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.