Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save oscarandreu/5129ee2e5f13cb8e7fa7b08a75cc36e1 to your computer and use it in GitHub Desktop.

Select an option

Save oscarandreu/5129ee2e5f13cb8e7fa7b08a75cc36e1 to your computer and use it in GitHub Desktop.
Visual Studio -- project file modifications to apply transformations in config file during compile
<PropertyGroup>
<PostBuildEvent>$(MSBUILDBINPATH)\msbuild "$(ProjectPath)" /t:Transform /p:Configuration=$(ConfigurationName);Platform=AnyCPU
xcopy "$(ProjectDir)obj\$(ConfigurationName)\Web.Config" $(ProjectDir)\. /F /R /Y
</PostBuildEvent>
</PropertyGroup>
<Target Name="Transform">
<MakeDir Directories="obj\$(Configuration)" Condition="!Exists('obj\$(Configuration)')" />
<TransformXml Source="Web.Config" Transform="Web.$(Configuration).config" Destination="obj\$(Configuration)\Web.config" StackTrace="true" />
</Target>
<Target Name="AfterBuild">
</Target>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment