2

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 

2 Answers 2

6

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for pointing me to the build events. It proved to be the solution I needed.
-1

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 } 

1 Comment

Thanks for the thought! However this approach seems to rely on sending both the staging and prod certs to production which is something I try to not to do. But was still a good reminder of the directives.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.