use different web.config for different build configurations

HBK

New Member
I am not able to work out the solution provided by Sayed Ibrahim Hashimi to use different web.config for different build configurations.Use Visual Studio web.config transform for debugging.I get error underlined on PrepareForRunDependsOn, TransformXml and ExcludeFromPackageFiles nodes in the wpp.targets file.Can anyone tell me how to fix this? I just tried to use the transform files as web.transform..config instead of having it as web.dev..config.\[code\] <?xml version="1.0" encoding="utf-8"?><Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <!-- Make sure web.config will be there even for package/publish --> <Target Name="CopyWebTemplateConfig" BeforeTargets="Build"> <Copy SourceFiles="web.template.config" DestinationFiles="web.config"/> </Target> <PropertyGroup> <PrepareForRunDependsOn> $(PrepareForRunDependsOn); UpdateWebConfigBeforeRun; </PrepareForRunDependsOn> </PropertyGroup> <!-- This target will run right before you run your app in Visual Studio --> <Target Name="UpdateWebConfigBeforeRun"> <Message Text="Configuration: $(Configuration): web.template.$(Configuration).config"/> <TransformXml Source="web.template.config" Transform="web.template.$(Configuration).config" Destination="web.config" /> </Target> <!-- Exclude the config template files from the created package --> <Target Name="ExcludeCustomConfigTransformFiles" BeforeTargets="ExcludeFilesFromPackage"> <ItemGroup> <ExcludeFromPackageFiles Include="web.template.config;web.template.*.config"/> </ItemGroup> <Message Text="ExcludeFromPackageFiles: @(ExcludeFromPackageFiles)" Importance="high"/> </Target></Project>\[/code\]
 
Back
Top