views:

88

answers:

2

I don't know if the is even remotely possible, but just now I have some code in my application that when I come to build/publish I would like Visual Studio to say "Hey this is fine locally but I won't let you publish until you change this!"

I know about conditional compiling i.e.

#IF CONFIG="Debug" THen 
  'do debug stuff
#ELSE
  'do release stuff
#END IF

but what I would essentially like to do is essentially pick up the todo markup, so if I have

'todo remove this before publishing

Visual studio detects this and errors when building a release version.

Is this possible?

EDIT: I am using VB.NET

+1  A: 

From http://msdn.microsoft.com/en-us/library/x5hedts0.aspx

// CS1029 expected
#define DEBUG
class MainClass 
{
    static void Main() 
    {
       #if DEBUG
       #error DEBUG is defined
       #endif
    }
}

You'd obviously want to invert the logic here for your scenario...

Edit: In VB.NET I can't find a pre-processor directive similar to #error. However, I think you can accomplish what you're trying to do with the following

Public Class Class1
  #If DEBUG Then
    'your debug code here
  #Else
    just write a syntax error here, this will break the build in release mode.
  #End If
End Class

Not exactly a brilliant solution but it does meet your requirements!

tomfanning
Can you do this in VB.NET world??
Dean
Hmm, it appears not. Edited answer to propose a solution.
tomfanning
A: 

If the todo is in a comment, you can use the Comments view of the Task List to see your todos. Open the task list in View -> Task List.

By default, it shows comments containing HACK, TODO, UNDONE and UnresolvedMergeConflict. You can add more tokens in the options: Environment -> Task List. The tokens are case insensitive.

You can't use this to abort a build, but at least you can see the comments.

Zr40