I want to build different assemblies for my Windows Forms applications but I found what Win Forms application does not contains App.Debug.conf etc.
For example in Web App I can click to "Add config transofm" and get new configuration file for current release configuration.
How can I build applications with different release configurations(Debug, Release, etc.)?
You can use this article by Oleg Sych.
But here are short instructions:
Add a config file for each configuration to the project.
You need to add App.Debug.config
and App.Release.config
but your solution may contain another
configurations. For it you can use this pattern: App.<ConfigName>.config
I think you know how you can do it :)
Add information about binding main App.config
Find the project file section that contains all App.config
and App.*.config
references. You'll notice their build actions are set to None:
<None Include="App.config" />
<None Include="App.Debug.config" />
<None Include="App.Release.config" />
<None Include="App.<ConfigName>.config" />
Find the Content
tags and add this strings:
<Content Include="App.config" />
<Content Include="App.Debug.config" >
<DependentUpon>App.config</DependentUpon>
</Content>
<Content Include="App.Release.config" >
<DependentUpon>App.config</DependentUpon>
</Content>
<Content Include="App.<ConfigName>.config" >
<DependentUpon>App.config</DependentUpon>
</Content>
Enable transformations in the *.csproj file
In the end of *.csproj file put this:
<UsingTask TaskName="TransformXml" AssemblyFile="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v10.0\Web\Microsoft.Web.Publishing.Tasks.dll" />
<Target Name="AfterCompile" Condition="exists('app.$(Configuration).config')">
<!-- Generate transformed app config in the intermediate directory -->
<TransformXml Source="app.config" Destination="$(IntermediateOutputPath)$(TargetFileName).config" Transform="app.$(Configuration).config" />
<!-- Force build process to use the transformed configuration file from now on. -->
<ItemGroup>
<AppConfigWithTargetPath Remove="app.config" />
<AppConfigWithTargetPath Include="$(IntermediateOutputPath)$(TargetFileName).config">
<TargetPath>$(TargetFileName).config</TargetPath>
</AppConfigWithTargetPath>
</ItemGroup>
</Target>
FavScripts.com is a free tool to save your favorite scripts and commands, then quickly find and copy-paste your commands with just few clicks.
Boost your productivity with FavScripts.com!