开发者

How to use the final {project}.exe.config file when creating a setup project

I have created a console application (blah.exe) with specific app.config's for dev and prod. These are named dev_app.config and prod_app.config. I have hooked up an AfterBuild target in my csproj file* which copies the correct config file to the bin directory as blah.exe.config.

I have also created a setup project for this console app but I have run into a slight issue. It seems that the setup project uses the actual app.config from the project directory as opposed to the final blah.exe.config (located in 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 can I force the setup project to use the final config file generated in the bin folder and no开发者_运维知识库t the actual app.config file?

Additional Information:

My current solution involves adding another AfterBuild command which overwrites the actual app.config file. I don't like approach since it forces me to have an additional file that I don't need. Also, having this file has caused me some grief already since I made changes to the app.config file which got overwritten when building. The question is about how to get the setup project use the final config file in the bin folder and NOT how to manage the config or ways to create a config file.

* Adapted from Deploy an app.config based on build configuration


I have been using that exact same scenario but I use the BeforeBuild instead of AfterBuild, and it has always been fine. I have been doing this on both web and windows projects. Below is the code I am using.

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

Hope this helps.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜