How to use the final {project} .exe.config file when creating an installation project

I created a console application (blah.exe) with a specific app.config for dev and prod. They are called dev_app.config and prod_app.config . I linked the AfterBuild target in my csproj * file which copies the correct configuration file to the bin directory as blah.exe.config .

I also created an installation project for this console application, but I had a little problem. It seems that the installation project is using the actual app.config from the project directory, and not the final blah.exe.config (located in the bin directory).

 |--Bin | |--Debug | |--Blah.exe.config <--- I want the setup project to use this file |--app.config <--- Setup project uses this file at the moment |--dev_app.config |--prod_app.config 

How to make the installation project use the final configuration file generated in the bin folder, and not the actual app.config file?

Additional Information:

My current solution includes adding another AfterBuild command that overwrites the actual app.config file. I do not like the approach because it makes me have an additional file that I do not need. In addition, the presence of this file caused me some grief already since I made changes to the app.config file, which was overwritten at creation. The question is how to make the installation project use the final configuration file in the bin folder and NOT , how to manage the configuration or how to create the configuration file.

* Adapted from deploying app.config based on build configuration

+7
source share
1 answer

I use the same script, but I use BeforeBuild instead of AfterBuild, and that was always good. I do this in both web projects and windows projects. Below is the code I'm using.

  <Target Name="BeforeBuild"> <ItemGroup> <ConfigSourceFiles Include="Web.$(Configuration).config" /> <ConfigDestinationFiles Include="Web.config" /> </ItemGroup> <Copy SourceFiles="@(ConfigSourceFiles)" DestinationFiles="@(ConfigDestinationFiles)" /> </Target> 

Hope this helps.

+2
source

All Articles