WebDucer
WebDucer

Reputation: 1134

Postsharp aspect on solution with build subfolders

We have the following build output structure:

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

If we use the aspect (that depends on NLog and Json.Net) on projects in the root directory ([assembly: OurAspect]) it works well.

If we try to use this aspect in the projects that are compiled in the subfolders we get the exeption, that the DLLs on whitch the aspect is depend on couldn't be found.

How can we configure the PostSharp to use the DLLs from root build directory to compile the projects inside the subfolders?

Upvotes: 2

Views: 142

Answers (1)

WebDucer
WebDucer

Reputation: 1134

After two days of testing and trying, I solved the problem by using the solution wide configuration (with .pssln file).

<?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>

The projects have only the reference to the PostSharp library (over NuGet and with copy flag off). The main project have NuGet references to PostSharp, Aspect and its dependencies (to have this in a package folder and to copy them once to the output folder).

This solution works for our solution structure.

Upvotes: 2

Related Questions