0

In my .net application, I have added new build modes for the configurations.

I currently have: Debug, Release, BetaDebug & BetaRelease. Each having a specific purpose for software engineering purposes.

I wish to know if I can get a C# string containing this text. So I can then do:

string configurationBuild = GetConfigurationBuild();

if(configurationBuild.Contains("Beta") {
    //do something
}
else {
    //do something else
}
1
  • You considered preprocessor commands testing for the build modes and setting a constant? Commented Jul 12, 2013 at 9:27

2 Answers 2

1

You can configure that each configuration will define Conditional Compilation symbols use preprocessor instructions like #if to find out which build configurationis being used. Here is a link on msdn forum http://social.msdn.microsoft.com/Forums/vstudio/en-US/7d574468-c890-49d2-984e-16ad068a006e/build-configuration-in-preprocessor

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

2 Comments

Is there a way to get this dynamically, i.e. if I added later a new mode (like Release Candidate), I will be able to get it without modification.
I'm afraid you need to change the proprocessor instructions as you add new configurations, as preprocessor instructions are not the .net code, they are statically interpeted at compile time
1

You can use conditional compilation symbols ( http://msdn.microsoft.com/query/dev10.query?appId=Dev10IDEF1&l=EN-US&k=k(CS.PROJECTPROPERTIESBUILD);k(TargetFrameworkMoniker-%22.NETFRAMEWORK%2cVERSION%3dV4.0%22)&rd=true ) for your build modes.

In your code you can then use the #if directive http://msdn.microsoft.com/de-de/library/4y6tbswk(v=vs.100).aspx

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.