eDosWeb/TextFile1.txt

15 lines
1.3 KiB
Text
Raw Permalink Normal View History

2020-05-05 13:15:17 +02:00
Here's what we do. It's not hard to set up but not intuitive or well documented.
Create web.config.template. No build action, do not copy. Copy-paste your web.config contents here. (This is an arbitrary name, no black magic.)
Right-click and select "Add Transform". This will get you files like Web.config.Debug.template and Web.config.Release.template. Add your transforms here.
Unload your project (right-click on project, select "Unload Project")
Open the .csproj file (right-click on closed project, select "Edit .csproj"
Add the XML below to the bottom of the file (just before )
Build the project. This should create a web.config file, but you still need to add it to the project.
Click "Show All Files"
Right-click the new web.config that was created and select "Include in Project"
Delete and transform files that were added automatically under web.config
<Target Name="BeforeBuild">
<TransformXml Source="Web.config.template" Destination="Web.config" Transform="Web.config.$(Configuration).template" />
</Target>
Now when you build, you'll get a shiny new web.config that is the result of the transformation.
Be sure to add the .template files to source control, and exclude the actual web.config. I also put a big warning at the top of Web.config.template to only edit the .template files, not the actual web.config, or your changes will be overwritten.