We help IT Professionals succeed at work.

Custombuild in Visual Studio addin.

DanielCollin
DanielCollin asked
on
Hi,

I want to do a similar thing like BounceChecker,TrueTime,TrueCoverage do (among more i guess)

This is what i want to do from my addin.

When Visual Studio is about to compile my c++ file i want to make a copy of that file, do some change in that file
(in my case add a temporary function call at the start of each function)

some example of how its supposed to work

 ....
 // "Visual C++" callback
 Build( filename, options, outname )
 {
   copy file to tempfile
   AddCustomCode tempfile          // own function
   cl.exe tempfile options outname // call visual c++ to        
                                   // comepile the tempfile
 }

Example code of how to do this would be really helpfull.

Thanks.

Daniel

 



Comment
Watch Question

Commented:
I don't know of an 'official' method for doing what you want however the following hack will work...

Look in the registry under:
HKEY_CURRENT_USER\Software\Microsoft\Devstudio\6.0\Build System\Components\Platforms\Win32 (x86)\Tools\32-bit C/C++ Compiler for 80x86

You'll find an entry that determines the undlying compiler driver that is spawned (default=cl.exe). Now you can replace this entry with the name of an alternate executable.

This executable should detect whether you want to do your thing or not and then  either:
a) Pass on the commandline unchanged to the real executable
or
b) Pass on the commandline with a tempfile to executable

Get the idea?

Rob

Author

Commented:
Ahhh,

Yeah its a bit of a hack, but that will do :)

Thanks.

Daniel

Author

Commented:
Ok,

I have tested it now and it works, BUT
I want to change the RegKey inside Visual Studio to make it
use "my" compiler, but i have to exit visual studio after i changed the key.

Is there someway to tell visual studio to "re-read" the key from the registry?

Daniel

Author

Commented:
Ok,

I have tested it now and it works, BUT
I want to change the RegKey inside Visual Studio to make it
use "my" compiler, but i have to exit visual studio after i changed the key.

Is there someway to tell visual studio to "re-read" the key from the registry?

Daniel

Explore More ContentExplore courses, solutions, and other research materials related to this topic.