Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I'd prefer not to use entire an Web Application Project solution out of box. My solution is to use the XmlTransform task defined in Microsoft.Web.Publishing.Tasks.dll directly (this task is the core of WebConfigTransformation) This way it is flexible enough and does exactly what you expect it to do. For example here is the WebSiteTransformator.csproj I'm using for transforming web.config.</p> <p>Here also is an example of flexibility that is impossible to reach with original WebConfigTransformation: it takes web.Template.config, applies web.$(Configuration).config over it and writes web.config. This allows us to add web.config itself into ignore list in source control. It is still valid csproj to be referenced by website:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"&gt; &lt;PropertyGroup&gt; &lt;Platform Condition=" '$(Platform)' == '' "&gt;AnyCPU&lt;/Platform&gt; &lt;SchemaVersion&gt;2.0&lt;/SchemaVersion&gt; &lt;OutputType&gt;Library&lt;/OutputType&gt; &lt;TargetFrameworkVersion&gt;v4.0&lt;/TargetFrameworkVersion&gt; &lt;OutputPath&gt;$(TEMP)\TransformWebConfig\bin&lt;/OutputPath&gt; &lt;BaseIntermediateOutputPath&gt;$(TEMP)\TransformWebConfig\obj\&lt;/BaseIntermediateOutputPath&gt; &lt;IntermediateOutputPath&gt;$(BaseIntermediateOutputPath)$(Configuration)\&lt;/IntermediateOutputPath&gt; &lt;WebFolderName&gt;$(SolutionDir)\MyWebSite\&lt;/WebFolderName&gt; &lt;/PropertyGroup&gt; &lt;ItemGroup&gt; &lt;Compile Include="Dummy.cs" /&gt; &lt;/ItemGroup&gt; &lt;UsingTask TaskName="TransformXml" AssemblyFile="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\Web\Microsoft.Web.Publishing.Tasks.dll"/&gt; &lt;Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /&gt; &lt;Target Name="BeforeBuild"&gt; &lt;TransformXml Source="$(WebFolderName)Web.Template.config" Transform="$(WebFolderName)Web.$(Configuration).config" Destination="$(WebFolderName)Web.config" /&gt; &lt;/Target&gt; &lt;/Project&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload