Exclude/Skip files in VSTS Build and release

15,157

Solution 1

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

Solution 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.

    enter image description here

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

    enter image description here

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

    enter image description here

  4. Change the Publish Artifacts task as below:

    enter image description here

Now the build artifacts are exclude web.config file.

Solution 3

Additional arguments

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

enter image description here

Solution 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.

Share:
15,157
bluemoon522
Author by

bluemoon522

Updated on June 28, 2022

Comments