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 alwa开发者_开发百科ys 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
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.
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
精彩评论