postsharp - 在 Postsharp 编译期间获取项目路径/输出路径

标签 postsharp

是否有可能在 Postsharp 的编译期间找到程序集的项目文件夹/项目文件或输出路径,例如,在 CompileTimeInitialize 期间,当正在构建程序集时?

最佳答案

您可以在编译期间通过评估“MSBuildProjectFullPath”属性找出当前项目文件的路径:

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

一些其他 PostSharp 属性的列表可以在这个 documentation page 上找到.

关于postsharp - 在 Postsharp 编译期间获取项目路径/输出路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16327619/

相关文章:

c# - 我可以更改后编译器的顺序吗?

c# - 使用 ASP.NET Core 内存缓存的 PostSharp 缓存 MethodInterceptionAspect

c# - 如何设置默认的 NHibernate CommandTimeOut 默认值

c# - PostSharp 切入点

asp.net - 根据方法名称过滤 log4net - 不太明白

c# - PostSharp Tools for Visual Studio 2019 无法在 Visual 中安装

c# - 为什么要使用 LinesOfCodeAvoidedAttribute 类?

c# - 后锐利。如何引入可序列化属性

c# - 使用 PostSharp 在 c# 中的构造函数上应用方面

C# 可以将对象附加到方法调用而不将其作为参数吗?