Using SlowCheetah Config Transforms in Web.config in 3.5 Web Forms Application

I loaded SlowCheetah into an old .Net 3.5 web form application to add conversions to web.config.

I have used SlowCheetah with Windows and console applications to successfully convert app.config in the past. In these cases, the config is converted and placed in the trash as ApplicationName.exe.config.

However, in this web form application, the configuration file never ends up in the trash because web form sites are created using only the DLL that fell in the bunker, and IIS points to the root directory to start the site. Therefore, instead of having web.config included in the build process and packaged in a trash, it simply remained alone in the root directory.

No conversions apply to web.config in the root, which is good, since web.config in the root directory is in the source control and is the file that we are doing the conversion.

I would be happy if web.config were included in the assembly, so slowCheetah converts it and then throws it into the trash. Then we would have to manually remove it from the basket and return it to the root level on our servers, but it would be advisable to have conversions.

Does anyone know how to make transforms work against my web.config or include it in the build process so slowCheetah can work with its magic?

Thanks!

Update

I changed the properties of web.config and is now included in the assembly, however, the transformations still do not apply to it.

Build Action: Embedded Resource

Copy to output directory: always copy Strike>

+7
source share
2 answers

Decision

I renamed Web.config in our original control to Web.template.config and added the transformations Web.template.Debug.config and Web.template.Release.config

Then upload the project file and edit the .csproj XML file by adding the following elements

This creates a new Web.config file in the root directory. Woot!

<PropertyGroup> <PrepareForRunDependsOn> $(PrepareForRunDependsOn); WebConfigTransform; </PrepareForRunDependsOn> </PropertyGroup> <Target Name="WebConfigTransform"> <Message Text="Configuration: $(Configuration): Web.template.$(Configuration).config" /> <TransformXml Source="Web.template.config" Transform="Web.template.$(Configuration).config" Destination="Web.config" /> </Target> 
+5
source

Found the best solution - without renaming files in .template.config.

Paste the following into a .csproj file in a web form.

  <Target Name="BeforeBuild"> <Delete Files="$(TEMP)\Web.TEMP.config" /> <Copy SourceFiles="Web.config" DestinationFiles="$(TEMP)\Web.TEMP.config" /> <TransformXml Source="$(TEMP)\Web.TEMP.config" Transform="Web.$(Configuration).config" Destination="Web.config" /> </Target> 
+1
source

All Articles