views:

19

answers:

2

I have a project which uses a system to authorise users. While I make some updates I want to to be able to set IsAdmin(username) to always return true. I wont forget to remove this, however it would be helpful if there was functionality in visual studio, like the //TODO, which created a warning or on build or publishing. Does anyone know of any functionality like this?

Thanks

A: 

I'm not sure I grasp what you want to do, but you'll probably have to use preprocessor directives (such as #warning), and maybe combine them? Something like

#if DEBUG
#warning This is debug!
#endif
Philippe
That's idea thanks. I didn't know #warning existed, but I just wanted some ability to cause a prompt upon build.
Kennifer
+1  A: 

Your C# and VB (and C++ in VS 2010) project files are MsBuild files and are built using the MsBuild engine. You could edit your project file in a text editor and add a warning that is conditional on a property being set.

<!-- These two targets exist at the bottom of all .csproj/.vbproj files, 
     but are usually empty. -->
<Target Name="BeforeBuild">
  <Warning
    Text="This is a debug build!."
    Condition="'$(Configuration)' == 'Debug'" />
</Target>
<Target Name="AfterBuild">
</Target>

You could also make it an error which stops the build using the Error task.

heavyd