Tim Van Wassenhove home

A couple of days ago i wrote about Easily switching between App.Config files with MSBuild. Christophe Gijbels, a fellow compuwarrior, pointed out that developers usually need to copy more than a single App.Config fileā€¦ I would propose to add a Folder for each Customer that contains all the specific configuration files. Eg

screenshot of solution explorer with proposed folder structures

Now i have to configure MSBuild so that the right files are copied into the OutDir:

<!-- Define the CustomerPath depending on the choosen Configuration -->
<propertyGroup Condition=" $(Configuration) == 'Customer1 Debug' "> 
<propertyGroup Condition=" $(Configuration) == 'Customer2 Debug' "> 

<!-- Define AppConfig in the CustomerPath  -->

<!-- Find all files in CustomerPath, excluding AppConfig -->
	<customerFiles Include="$(CustomerPath)\*.*" Exclude="$(CustomerPath)\App.config" />

<target Name="AfterBuild">
	<copy SourceFiles="@(CustomerFiles)" DestinationFolder="$(OutDir)" SkipUnchangedFiles="true"/>