tags:

views:

328

answers:

1

Lately, I've been working with PostSharp a bit. It is an AOP framework that allows us to do compile time code injection. You can just reference PostSharp assemblies, use it in your code and after compilation, you'll get an assembly that the desired code has been injected into it. I tried to find out how PostSharp integrates itself into the compilation process of Visual Studio and changes the code, but no results till now.

Is there any way to get Visual Studio to run some code during or after the compilation without using the project's post-build task or any plug-in?

+1  A: 

The magic is on last line of C:\Windows\Microsoft.NET\Framework\v3.5\Microsoft.Common.targets. This loads a file c:\Program Files\MSBuild\v3.5\Custom.After.Microsoft.Common.targets, if present.

So PostSharp edits this file during installation and adds a reference to its own targets file.

Gael Fraiteur