+2  A: 

In the project properties of Visual Studio, you will have the option "Pre-Build Event" and "Post-Build Event".

At these configurations you can input programs that should be executed before and after your build. You can use project variables to identify your solution folder, project folder, binary, etc. If you are using a recent version of Visual Studio, there is a button below the text box that give you access to those variables.

Make sure that whatever you call at this configuration would be executed from the shell environment (cmd), otherwise you will receive a build error. Scripts will probably required that you input a call to the interpreter and pass the file as a parameter.

For example, let's say I need to run a Python script before I build my code. I would configure the Pre-Build Event as:

c:\python\python myscript.py

One good advice is to use DOS Batch files (.bat) to wrap around whatever you need to run and add those to your build events. There are plenty of tutorials over the net on how to create bat files, and they are fairly simple.

Bruno Brant
@Bruno Brant_for such pre-build event does the intended code to be scanned have to first be saved as a file, or scanning and modification of the code can be done even in ram in case the code has not been saved as a file already.
Pooria
@Pooria: The code has to be modified on the disk. I don't think VC will allow you to modify the file in-memory before build, but I may be wrong. Is that what you need? Besides, VC will save your files before building.
Bruno Brant