Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get the project path/output path during Postsharp compile time

Tags:

postsharp

Is it possible to find out the project folder/project file or output path of the assembly during compile time in Postsharp, i.e. during CompileTimeInitialize for example, when the assembly is being built?

like image 389
Anupheaus Avatar asked Apr 14 '26 15:04

Anupheaus


1 Answers

You can find out the path to the current project file by evaluating the 'MSBuildProjectFullPath' property during compile time:

public override void CompileTimeInitialize(MethodBase method, AspectInfo aspectInfo)
{
    string projectPath =
        PostSharpEnvironment.CurrentProject
            .EvaluateExpression("{$MSBuildProjectFullPath}");
}

The list of some other PostSharp properties can be found on this documentation page.

like image 98
AlexD Avatar answered Apr 19 '26 17:04

AlexD



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!