2

I have a VS2013 C# MVC project where I need to run a post build process that takes 2 parameters where the values already exist within the web.config.

Within the post-build event command line I would like something like this: MyBatchFile.bat "WebConfigParam1" "WebConfigParam2" where both WebConfigParam1 and WebConfigParam2 exist in the app settings of the web.config. This would allow me to have dynamic properties based on environment, and would automate the process.

Does something like this exist?

Thanks!

RichieMN
  • 905
  • 1
  • 12
  • 33

1 Answers1

1

Since you are delegating the post build step to a batch file, the solution could look like this:

  1. Pass in the output folder of the project into the batch file as a parameter. This value is available under the "Macros >>" in the post-build command line editor.
  2. Use your batch file to extract the required two values from the project's web.config file, e.g. like this: Extracting text from XML file via batch file
Community
  • 1
  • 1
Christoph
  • 2,211
  • 1
  • 16
  • 28
  • Cool, I'll give that a go and report back. Thanks for the help. – RichieMN Aug 18 '15 at 02:31
  • Thinking about a small console app to determine the solution configuration (debug, release, etc.). I know there's a macro $(Configuration), but how can I access something like this from outside the build? – RichieMN Aug 18 '15 at 13:32
  • When you say "outside the build", you mean after the post build step ran? Well, one distinguishing factor is that Debug and Release builds are usually put into different folders. Another way is to pass the $(Configuration) macro into your batch file and have the batch file write that value into a text file in the output folder so that any logic you might execute afterwards can read this value and execute configuration-specific steps. – Christoph Aug 18 '15 at 21:39