Search code examples
c#.netmsbuildpostsharp

Quiet down PostSharp warnings at build without skipping PostSharp


I have PostSharp included in all of my projects, as per the recommended best practices for PostSharp. However, I don't have any aspects or other transformations in some of these assemblies; they just reference other projects that do have aspects in use.

At build time, I get the following warning:

The module 'xxxxxxx.dll' does not contain any aspect or other transformation. For improved build-time performance, consider disabling PostSharp for this module by setting the compilation symbol (aka constant) 'SkipPostSharp' in your project, or set the MSBuild property 'SkipPostSharp=True'.

Thanks for the info, PostSharp! But I've "considered disabling PostSharp for this module" and decided not to do so. I'm perfectly happy to lose a tiny bit of build-time performance, in exchange for not having to think about it later when I do decide to use PostSharp in a project previously devoid of aspects.

How do I get PostSharp to stop telling me about this hint, and without enabling SkipPostSharp?


Solution

  • In your project properties under the PostSharp tab there is a line entry "Disabled Messages (semi-colon separated list)"

    In that field enter the code for the particular message. I am not entirely sure what it is but try PS0121

    Alternatively, if you manually edit your project file "*.csproj" you can add the PostSharpDisableMessages element into your PropertyGroup for your applicable configurations as shown below.

      <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
        <DebugSymbols>true</DebugSymbols>
        <DebugType>full</DebugType>
        <Optimize>false</Optimize>
        <OutputPath>bin\Debug\</OutputPath>
        <DefineConstants>DEBUG;TRACE</DefineConstants>
        <ErrorReport>prompt</ErrorReport>
        <WarningLevel>4</WarningLevel>
        <ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch>None</ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch>
        <PostSharpDisabledMessages>PS0131;PS0121</PostSharpDisabledMessages>
      </PropertyGroup>