Skip to content
This repository has been archived by the owner on Feb 8, 2022. It is now read-only.

Multiple Configuration Transforms Not Working #2

Closed
MSWCRB opened this issue Jan 11, 2018 · 3 comments
Closed

Multiple Configuration Transforms Not Working #2

MSWCRB opened this issue Jan 11, 2018 · 3 comments
Assignees
Labels
Milestone

Comments

@MSWCRB
Copy link

MSWCRB commented Jan 11, 2018

There is a bug with the current implementation that was identified by Dan Bullock on 9/19/2017 wherein the extensions is created a new AfterBuild section in the project file for each config transform in a project, which causes only the first transform to be applied in a scenario where a project has more than one config file that needs to be transformed. Dan also presents the solution there. Please fix it if you have time.

"The sample project is not correct. The sample defines multiple <AfterBuild> but when it actually can only be defined once. Each definition replaces the previous.

In .csproj it should be a single AfterBuild with each TransformXml having a condition:

<Target Name="AfterBuild">
<!--Generate transformed config in the output directory-->
<TransformXml Condition="Exists('data.$(Configuration).config')" Source="data.config" Destination="$(OutputPath)data.config" Transform="data.$(Configuration).config" />
<TransformXml Condition="Exists('plainxml.$(Configuration).config')" Source="plainxml.config" Destination="$(OutputPath)plainxml.config" Transform="plainxml.$(Configuration).config" />
</Target>
By Dan Bullock 9/19/2017"
@golavr golavr self-assigned this Jan 12, 2018
@golavr golavr added the bug label Jan 12, 2018
@golavr golavr added this to the v3.2 milestone Jan 12, 2018
@golavr
Copy link
Owner

golavr commented Jan 12, 2018

@MSWCRB I checked it and you are right
thanks for the input

Steps to reproduce:

  1. Open ConfigTest sample solution
  2. Navigate to ConfigTest project
  3. Transform App.config
  4. Transform data.config
  5. Transform plainxml.config
  6. Open ConfigTest.csproj file

File contains 2 AfterBuild tasks, only the last one will be executed

<Target Name="AfterBuild" Condition="Exists('data.$(Configuration).config')"> <!--Generate transformed config in the output directory--> <TransformXml Source="data.config" Destination="$(OutputPath)data.config" Transform="data.$(Configuration).config" /> </Target>

<Target Name="AfterBuild" Condition="Exists('plainxml.$(Configuration).config')"> <!--Generate transformed config in the output directory--> <TransformXml Source="plainxml.config" Destination="$(OutputPath)plainxml.config" Transform="plainxml.$(Configuration).config" /> </Target>

@MSWCRB
Copy link
Author

MSWCRB commented Jan 14, 2018

The solution is to generate this (then both get executed):
<Target Name="AfterBuild"> <!--Generate transformed config in the output directory--> <TransformXml Condition="Exists('data.$(Configuration).config')" Source="data.config" Destination="$(OutputPath)data.config" Transform="data.$(Configuration).config" /> <TransformXml Condition="Exists('plainxml.$(Configuration).config')" Source="plainxml.config" Destination="$(OutputPath)plainxml.config" Transform="plainxml.$(Configuration).config" /> </Target>

golavr added a commit that referenced this issue Feb 17, 2018
Fix encoding message in visual studio of added transform files .
Add messages to output window.
Move transformation to new class.
Update csproj file - run experimental instance for debug.
@golavr
Copy link
Owner

golavr commented Mar 16, 2018

Fixed in v3.2

@golavr golavr closed this as completed Mar 16, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants