Reputation: 3231
In my VS 2010 solution, I have four web projects.
The first project is the development project. The other three serve only for publishing different subset of the first project's pages. Almost all files in the other three projects are links to files of the first project.
All projects share the same web.config (linked from the first project).
What I want to achieve is having different xml transformations of the web.config according to the project that is being published. The "Add Config Transforms" option works well only in the first project where the file actually is. It seems you can't add config transforms for a linked web.config. The transforms are added but they don't seem to reference the linked web.config and they don't seem to get executed.
I tried to mess with the *.csproj file manually, so that I can make these transformations reference the linked file, but I couldn't make it to work.
Is there a way to have xml config transforms for a linked web.config?
WORKAROUND
I just used the workaround below:
I created normal web.config files for each project (no link to the first project's web.config). I added the transformations I wanted on each project's web.config. Then, in each project, I added a Before Build event that would copy and overwrite the first project's web.config unto the current project's web.config. That way the transformations are executed on the new overwritten config file and the right config is published.
My question is still valid though.
Upvotes: 1
Views: 779
Reputation: 102
Yo can write/rewrite any transformation sources/patterns inside project file to any pathes.
There is my real example for standalone app. Solution for you problem on the bottom of the answer post.
I have solution with 2 projects:
1. The source project "NetrikaLabManager" with real App.config and two transformation configs (App.Debug.config and App.Release.config)
2. The target project "NetrikaLabManagerGui" and I want same config with same transformation rules as the first project.
My next steps are:
<Target Name="AfterCompile" Condition="Exists('app.$(Configuration).config')">
<Target Name="AfterCompile" Condition="Exists('..\NetrikaLabManager\App.$(Configuration).config')">
<TransformXml Source="app.config" Destination="$(IntermediateOutputPath)$(TargetFileName).config" Transform="app.$(Configuration).config" />
<TransformXml Source="..\NetrikaLabManager\App.config" Destination="$(IntermediateOutputPath)$(TargetFileName).config" Transform="..\NetrikaLabManager\App.$(Configuration).config" />
Summary for your Question - In the every proj file you must manually add any "real" config transformation file(s) to your satellite projects and leave "Transform" and "Condition" attributes as unchanged, but change the "Source" path attribute to Your Dev config file. That will be applying individual satellite transformations for Dev config.
Upvotes: 1