Exclude/Skip files in VSTS Build and release

假装没事ソ 提交于 2019-12-08 06:22:31

问题


We are in process of creating architecture for VSTS CI/CD to deploy our web app to our Azure App Services. We want to exclude the web.config while deploying it to the Azure server as we are directly modifying the web.config on the different environment. CI Tasks looks like this: CI Taks

CD Task: Deploy Azure App Service I am aware of other ways of updating the web.config https://docs.microsoft.com/en-us/vsts/build-release/tasks/transforms-variable-substitution, but in our case we want to skip the web.config file. I couldn’t find the option to skip file in during release in VSTS as mentioned in this thread How do I exclude the .cs files within an artifact from a vs-team-services CI build? Is there a way to exclude certain files while building and deploying the release?


回答1:


Added -skip:objectName=filePath,absolutePath=web.config in additional arguments. This skips updating the web.config file during deployment.




回答2:


You can exclude the web.config before publishing artifacts in your build definition: copy the web packages files to a directory (such as $(build.binariesdirectory)), then copy the files exclude web.config to another folder (such as $(Build.ArtifactStagingDirectory)/package), and zip the files under $(Build.ArtifactStagingDirectory)/package. And finally publish the zip file as build artifacts.

Details changes in the build definition as below:

  1. Change the MSbuild arguments as /p:OutDir="$(build.binariesdirectory)\\" in Visual Studio Build task.

  2. Add a Copy Files task after Visual Studio Build task. Settings for this task as below:

  3. Add Archive Files task after Copy Files task. And settings as below:

  4. Change the Publish Artifacts task as below:

Now the build artifacts are exclude web.config file.




回答3:


Additional arguments

-skip:objectName=filePath,absolutePath=\\Configuration\\AppSettings\\Base.config




回答4:


you can add

-skip:objectName=filePath,absolutePath='.*\PackageTmp\Web.config$'

in Additional Arguments in "Deploy IIS WebSite/App" deployment VSTS task, this will not deploy your root web.config file.



来源:https://stackoverflow.com/questions/46936246/exclude-skip-files-in-vsts-build-and-release

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!