How to: Transform Web.config When Deploying a Web Site Project
How to: Transform Web.config When Deploying a Web Site Project
Publishing a Web Site project with Visual Studio does not support Web.config transform files. In the following, I will show you how to use the same functionality from a Web Application project (see: How to: Transform Web.config When Deploying a Web Application Project) in a Web site project.
You have to create a publish profile for the Web Site project and add an MSBuild step in the "website.publishproj" file:
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
...
<Import Project="$(_WebPublishTargetsPath)\Web\Microsoft.WebSite.Publishing.targets" />
<UsingTask TaskName="TransformXml" AssemblyFile="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\Web\Microsoft.Web.Publishing.Tasks.dll"/>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Target Name="BeforeBuild">
<TransformXml Source="$(WebFolderName)Web.config"
Transform="$(WebFolderName)Web.$(Configuration).config"
Destination="$(WebFolderName)Web.config" />
</Target>
...
</Project>
Enjoy (ง°ل͜°)ง
Enjoy (ง°ل͜°)ง
Nice! I dug everywhere.
ReplyDelete