It may seem unusual to debug build-time logic, but you can debug the build process like any other process.
To do this, attach a debugger to the PostSharp process. If you use the standard MSBuild targets for PostSharp, set the MSBuild property PostSharpAttachDebugger to True.
This technique is easier to explain when the build-time logic (your aspect, for instance) and the transformed assembly are in different Visual Studio projects.
Suppose you have your aspect logic in MyAspects.csproj and unit tests (that is, the code to be transformed) in MyAspects.Test.csproj. To debug the build-time logic of MyAspects.csproj:
Open Visual Studio and load the solution containing
MyAspects.csproj.Open the Visual Studio Command Prompt and go to the directory containing
MyAspects.Test.csproj.Build
MyAspects.csprojusing Visual Studio as usual.From the command prompt, type:
msbuild MyAspects.Test.csproj /T:Rebuild /P:PostSharpAttachDebugger=TrueThe build process hits a breakpoint. When this happens, attach the Visual Studio instance that contains
MyAspects.csprojto the build process.Note
Because of a bug in Visual Studio, you need to use the mixed debugging engine. To do that, check the option Manually choose the debugging engines in the Visual Studio Just-In-Time Debugger and select both the managed and the native engines.
Set breakpoints in your code and continue the program execution.