1
votes

Task

I am attempting to allow multiple configuration-based (debug and release) app.config files to propagate to the client via ClickOnce. I am using VB.Net and Visual Studio 2008.

Issue

Based on my current setup, the individual app config files (App.debug.config and App.release.config) get copied to the bin folder correctly during build. However, during publish the resulting App.config file does not appear in the ClickOnce publish directory.

Below is an outline of the current setup I am using. Please assist in determining a best solution.

Steps

The individual configuration files exist within the project as:

  • Project
    • Configuration (Folder)
      • App.debug.config
      • App.release.config

I have edited the .vbproj file to include the following. This copies and renames the config file into the bin directory.

  <Target Name="AfterBuild">
    <Delete Files="$(TargetDir)$(TargetFileName).config" />
    <Copy SourceFiles="$(ProjectDir)\Configuration\App.$(Configuration).config" DestinationFiles="$(TargetDir)$(TargetFileName).config" />
  </Target>

Building succeeds, but when I go to publish there does not exist an instance of the App.config file in the ClickOnce remote directory. My understanding is that ClickOnce is checking the solution folders for content files rather than pulling them from the bin folder.

Is there any way I can either force the publish operation to include a file in the bin folder or pull and rename from the Configuration folder in the same manner as the post build step?

1

1 Answers

0
votes

Just got it in a stroke of luck and hackery. Assume the application name is "Program1" for below.

I edited the vbproj file with the following:

  <Target Name="AfterBuild">
    <Delete Files="$(ProjectDir)$(TargetFileName).config" />
    <Delete Files="$(TargetDir)$(TargetFileName).config" />
    <Copy SourceFiles="$(ProjectDir)\Configuration\App.$(Configuration).config" DestinationFiles="$(ProjectDir)$(TargetFileName).config" />
    <Copy SourceFiles="$(ProjectDir)\Configuration\App.$(Configuration).config" DestinationFiles="$(TargetDir)$(TargetFileName).config" />
  </Target>

Then I added a file named Program1.exe.config to the project in the project directory. This file can be anything, since the above script is going to overwrite it at build time. Once the file is in the project, I changed the Build Action to "Content". This forces the file to reach the publish directory as content.

Had to answer this for the edification of the S.O. community. Will close asap.