问题
I'm using Visual Studio Online and working through building a continuous integration setup. The scenario I have requires that multiple web projects are built out to a single Azure App Service deployment. The catch is that "out of the box" when you create a new build, the Visual Studio Build task appears to create a separate zip file for each project in the solution, and then the Azure App Service Deploy task throws an error saying there is more than one file matching the pattern, which is *.zip.
What I'd like to do is build all of these projects out to a single location, merging the various projects together, and then Azure App Service Deploy only has a single zip file to push, which I know it can do just fine. My MSBuild arguments for the Visual Studio Build task are /p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactstagingdirectory)\\"
. I tried removing the PackageAsSingleFile
attribute but it still created the zip files.
Is the scenario I want to do possible in VSO, perhaps with a different set of command codes?
回答1:
Sounds like you need a PowerShell script or a few tasks, to manipulate the files and folders before publishing the artifact.
- Extract Files
$(build.artifactstagingdirectory)\*.zip
to$(build.artifactstagingdirectory)\Merged
- Archive Files
$(build.artifactstagingdirectory)\Merged
to$(build.artifactstagingdirectory)\Merged.zip
- Delete Files that we extracted using minimatch:
!/**/*.zip
- Change your Azure App service deploy to look for:
$(System.DefaultWorkingDirectory)/**/Merged.zip
https://docs.microsoft.com/en-us/azure/devops/pipelines/build/variables?view=vsts
来源:https://stackoverflow.com/questions/52377689/merge-multiple-web-projects-into-a-single-output-zip-package