Skip to content

Instantly share code, notes, and snippets.

@devops-school
Last active September 21, 2019 16:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save devops-school/9189a63a4fa0852c436fffac8733c9a8 to your computer and use it in GitHub Desktop.
Save devops-school/9189a63a4fa0852c436fffac8733c9a8 to your computer and use it in GitHub Desktop.
<!-- the step to copy the config file first avoids a 'File is being used by another process' error -->
<Target Name="BeforeBuild">
<Copy SourceFiles="Web.config" DestinationFiles="Web.temp.config" OverwriteReadOnlyFiles="True" />
<TransformXml Source="Web.temp.config" Transform="Web.$(Configuration).config" Destination="Web.config" />
</Target>
<Target Name="AfterBuild">
<Copy SourceFiles="Web.temp.config" DestinationFiles="Web.config" OverwriteReadOnlyFiles="True" />
<Delete Files="Web.temp.config" />
</Target>
- Command
MSBuild.exe PATH_TO_PROJ.csproj /p:DeployOnBuild=true /p:PublishProfile=PUBLISH_TARGET /p:Configuration=Release
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment