Last active
August 29, 2015 14:07
-
-
Save jonezy/904b72a3c34bb01b6463 to your computer and use it in GitHub Desktop.
Web Config Transform Snippets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
---- | |
This portion goes closer to the top, again valid for web.config based projects | |
---- | |
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Trunk-Release|AnyCPU'"> | |
<OutputPath>bin\</OutputPath> | |
</PropertyGroup> | |
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Test-Release|AnyCPU'"> | |
<OutputPath>bin\</OutputPath> | |
</PropertyGroup> | |
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Dev-Debug|AnyCPU'"> | |
<OutputPath>bin\</OutputPath> | |
</PropertyGroup> | |
---- | |
This portion goes about half way down in the project definitely, valid for web.config based projects | |
---- | |
<Content Include="Web.Base.config"> | |
<SubType>Designer</SubType> | |
</Content> | |
<Content Include="Web.Dev.config"> | |
<SubType>Designer</SubType> | |
<DependentUpon>Web.Base.config</DependentUpon> | |
<IsTransformFile>True</IsTransformFile> | |
</Content> | |
<Content Include="Web.Trunk.config"> | |
<SubType>Designer</SubType> | |
<DependentUpon>Web.Base.config</DependentUpon> | |
<IsTransformFile>True</IsTransformFile> | |
</Content> | |
<Content Include="Web.Test.config"> | |
<SubType>Designer</SubType> | |
<DependentUpon>Web.Base.config</DependentUpon> | |
<IsTransformFile>True</IsTransformFile> | |
</Content> | |
----- | |
This block goes at the end of the .csproj file, it's valid for web projects with web.configs | |
----- | |
<UsingTask TaskName="TransformXml" AssemblyFile="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v11.0\Web\Microsoft.Web.Publishing.Tasks.dll" /> | |
<PropertyGroup> | |
<ConfigFileName>Web.$(Configuration.Replace('-Release','').Replace('-Debug','')).config</ConfigFileName> | |
</PropertyGroup> | |
<Target Name="AfterCompile" Condition="$(Configuration.Contains('-')) And exists($(ConfigFileName))"> | |
<!-- Generate transformed web config in the intermediate directory --> | |
<TransformXml Source="Web.Base.config" Destination="Web.config" Transform="$(ConfigFileName)" /> | |
</Target> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment