Visual Studio Deployment Project: Conditional Files Depending on Build Configuration
Asked Answered
F

1

6

I wonder if it is possible to build different installers which include different files for one deployment projects purely depending on the build configuration (Debug/Release)?

I want to do this because:

  1. During debug stage, we'd like to install some additional debug files (*.pdb) along with the binaries on the test machine so that if anything goes wrong, we can know what's going on
  2. During release stage, we do not want the users to have these debug files. And we do not want to make it an option for users to install *pdb - most of them do not know what these files are for and an option for them will only cause confusion

The difficulties I'm currently facing:

  1. I tried to open up the deployment project file (*.vdproj) and it is very different from other types of projects such as CSharp. Deployment project files are not XML, and I can't seem to write something like: .
  2. I've checked Microsoft's site: http://msdn.microsoft.com/en-us/library/cz6k1z02%28v=vs.80%29.aspx There's no deployment conditions related to build configuration.
  3. Since I want to set the condition according to build configurations, I suppose the project file should at least be able to tell what the current selected configuration is. However, the configuration manager for deployment is very simple - I can only change output, packaging, compression and installation URL. I can't seem to define any additional macros like I could for other type of projects (e.g. CSharp)
Fan answered 17/9, 2012 at 5:52 Comment(3)
Did you end up finding out how to do this?Denning
No, I don't think so... I don't think this was possible by the Visual studio I was using at that time. If I remember correctly, the closest thing you could get is to add a new environment (namely 'InstallPDB' or something). Then instead of compiling anything you can also run arbitrary DOS commands. Not sure about the new Visual studios since I'm no longer programming in Windows.Fan
Sounds good. I ended up writing a node script that runs as a post build event for my project and passes the config to, and that conditionally copies files to where the installer gets them. Works great. Thanks for the update though!Denning
M
0

Just to add my two cents, I had a similar need in my WPF project. I have different .config files for different build configurations (Debug, QA and Release) that are correctly generated in the output folder /bin/

I noticed that the output files for Primary output lists my .exe file from the correct configuration folder (i.e /bin/Release) however the .config file comes from the project's root directory (App.config) and then is renamed to my project's name.

So, to work around this, I:

  1. Created a post-build event to copy my generator .config file to a folder named ConfigDeploy.

    COPY /Y $(TargetDir)$(TargetFileName).config $(SolutionDir)ConfigDeploy\$(TargetFileName).config

  2. Ignored my .config files from Primary output by right-clicking my Primary output item, going to Properties and setting a "*.config" filter in "ExcludeFilter"

enter image description here

  1. Created a file entry to my .config file at "Program Files Folder/MyApplication" that points to the file at ConfigDeploy folder

As for .pdb files, it's more straightforward. You just need to add a project output and choose Debug Symbols and then point to the configuration you need

enter image description here

Marci answered 22/2, 2018 at 18:18 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.