Srini
Srini

Reputation: 728

Conditional compilation in ASP.Net MVC3 or MVC4 with C#

C# Preprocessor http://msdn.microsoft.com/en-us/library/4y6tbswk(v=vs.100).aspx

Is there any way we can control MVC Views, Controllers, Models with conditional compilation? This is for different versions of software releases.

Ex: release 1.1 release 1.2 etc...

I mean some features will not be available in 1 version based on conditional compilation. This is for not maintaining different branches and merging them together at end.

FYI... I do not find option conditional compilation option in vs 2010, i used to do this with visual basic 6.0.

Upvotes: 0

Views: 680

Answers (2)

D Stanley
D Stanley

Reputation: 152501

Well, you can:

Models/Controllers:

  #if DEBUG
     // your content
  #else
     // your content
  #endif

Views (Razor):

@{
  #if DEBUG
     // your content
  #else
     // your content
  #endif
}

But it doesn't sound like a great way to support versioning... (JMO)

Upvotes: 1

Diego
Diego

Reputation: 18349

You need two project files, one for each version, and define the symbols yourself. See this answer.

Upvotes: 0

Related Questions