Justin Self
Justin Self

Reputation: 6265

Include different files per build configuration

We have two different build configurations: Debug and Production.

Part of the build includes a cert used to access a third party site. In debug, we use a staging cert and in production we use the live production cert.

How can I ensure when the solution is built in the debug configuration that the staging cert is included and when its built in production, the production cert is included?

EDIT

Here's my solution from Scotty's suggestion (this was put into the Post-Build event command-line section):

IF $(ConfigurationName) == Release copy $(ProjectDir)resources\prod.p12 $(TargetDir)resources

IF $(ConfigurationName) == Debug copy $(ProjectDir)resources\staging.p12 $(TargetDir)resources

Upvotes: 2

Views: 3402

Answers (2)

curiousity
curiousity

Reputation: 4741

I think you could use DEBUG directive for loading certificates:

using System;
using System.Diagnostics;

 public class CertLoader
{
#if DEBUG
 public bool LoadStartingCert()
{
//...load it
}
//in other case load prod cert
}

Upvotes: -1

Scotty
Scotty

Reputation: 2510

Depends how your 'cert' is included in your project.

If it's a C/C++ file, right-click the file in Solution Explorer, open Properties > General > Excluded from Build. Exclude one file for your Debug build and one for your Release build.

If it's an external file or command, you can use Build Events for each configuration. Open your project Properties > Configuration Properties > Build Events > Post-Build Event (or another event if you like). From there you can run whatever command line you want.

Upvotes: 6

Related Questions