.net 具有生成子文件夹的解决方案的Postsharp特性

.net 具有生成子文件夹的解决方案的Postsharp特性,.net,projects-and-solutions,postsharp,aspect,.net,Projects And Solutions,Postsharp,Aspect,我们有以下构建输出结构: <Root> modules Module1.dll Module2.dll functions Function1.dll Function1.dll ... Main.exe CommonLibraries.dll PostSharp.dll NLog.dll Newtow

我们有以下构建输出结构:

<Root>
        modules
            Module1.dll
            Module2.dll
        functions
            Function1.dll
            Function1.dll
        ...
    Main.exe
    CommonLibraries.dll
    PostSharp.dll
    NLog.dll
    Newtownsoft.Json.dll
    OurAspect.dll
    ...

模块
Module1.dll
Module2.dll
功能
函数1.dll
函数1.dll
...
Main.exe
CommonLibraries.dll
PostSharp.dll
NLog.dll
Newtownsoft.Json.dll
OurAspect.dll
...
如果我们在根目录(
[assembly:OurAspect]
)中的项目上使用aspect(这取决于
NLog
Json.Net
),它工作得很好

如果我们尝试在子文件夹中编译的项目中使用此方面,则无法找到该方面所依赖的DLL


我们如何配置PostSharp以使用根构建目录中的DLL来编译子文件夹中的项目?

经过两天的测试和尝试,我使用解决方案范围的配置(使用.pssln文件)解决了这个问题


这些项目只有对PostSharp库的引用(在NuGet上,且复制标志处于关闭状态)。主项目具有对PostSharp、Aspect及其依赖项的NuGet引用(将其保存在包文件夹中,并将其复制到输出文件夹)

此解决方案适用于我们的解决方案结构

<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.postsharp.org/1.0/configuration">
    <Property Name="LogEnabled" Value="False" />
    <SearchPath Directory="packages\TraceLogAspectLib.1.0.26\lib\net40" />
    <SearchPath Directory="packages\NLog.3.1.0.0\lib\net40" />
    <SearchPath Directory="packages\Newtonsoft.Json.6.0.4\lib\net40" />
    <Multicast xmlns:aop="clr-namespace:aop.namespace.aspect;assembly:LogAspectLib">
        <When Condition="{$LogEnabled}">
            <aop:TraceLogAspect AttributeTargetTypes="solution.namespace.*" />
        </When>
    </Multicast>
</Project>