Adding Slow Cheetah transformed config file as a reference in another project

2.4k Views Asked by At

I have a class library project with a Slow Cheetah'ed config file.

In the past, it was easy to use 'Add As Link' to add the config file to other projects. How could this be achieved with Slow Cheetah because config files are dynamic?

I need some kind of add reference for config files or if there is no way of doing this, I have to copy the config file and Slow Cheetah it again.

2

There are 2 best solutions below

3
On BEST ANSWER

I found out that you can 'Add As Link' as normal, but link the main config file only, not the Slow Cheetah created files. Right click the link in the solution explorer and select "Add Transform" from the menu. Slow Cheetah creates links back to the Debug.config and Release.config files.

0
On

Adding to Mark's excellent answer...Custom Slow Cheetah transforms (ie. other than Debug.config and Release.config) can be added to your "other" project with a couple extra steps.

  1. Add as link the main app.config file.
  2. Right click app.config and select "Add Transform". Debug.config and Release.config will show in your solution explorer.
  3. Right click the project and select Unload Project.
  4. Once unloaded, right click again and select Edit .csproj

With the .csproj open, scroll down to where you see something like this:

<None Include="..\AppName\bin\Dev\App.config">
  <Link>App.config</Link>
  <TransformOnBuild>true</TransformOnBuild>
</None>
  1. Simply duplicate this code and modify the path and config name for each existing transform to be shared.

  2. Reload the project and the transforms should show beneath App.config

This approach works for using dynamic Linked configs between the application and a test project or library.

Side note: After implementing the transform, go to Build --> Configuration Manager. Confirm your build environments reference the desired configs.