0
votes

I have a wpf clickonce application that uses multiple app.configs based on configuration. When I build it outputs the correct app.config, but when I publish it uses the wrong app.config.

Here is my setup:

  • App.config - dummy empty config file.
  • App.Debug.config - debugging config
  • App.Test.config - test config
  • App.UAT.config - UAT
  • App.Prod.config - production

I have an "AfterCompile" task in my project settings that applies the correct config file based on the environment configuration and this works great. But when I use VS2012 publish wizard it uses the dummy config file regardless of the configuration setting.

1
I am trying to find a solution that does not involve manually copy/pasting/modifying any of the files after build or after publish as this is part of an automation process. - user3018599
I had the same issue and already answered here: stackoverflow.com/q/58811775/196526 - Bastien Vandamme

1 Answers

0
votes

Try using a BeforeCompile script instead. I've experienced the same thing and the App.config file needs to be updated prior to compilation.

Something like the following in a Pre-build event command line should do it for you.

  IF "$(ConfigurationName)" == "Development" (
  COPY "$(ProjectDir)App.Development.config" "$(ProjectDir)App.config"
  )