Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to select which projects PostSharp processes instead of telling it which to exlude?

Tags:

postsharp

I can specify the SkipPostSharp constant to ensure a project is excluded from the list of projects PS processes. I want to do it the other way around though. I want PS to assume it shouldn't process anything that I don't specifically tell it to.

Is this achievable?

like image 278
Brandon Moore Avatar asked Mar 21 '12 23:03

Brandon Moore


1 Answers

There are three conditions for a project to be automatically processed by PostSharp:

  1. PostSharp has been installed using the setup program.
  2. The project has a reference (direct or indirect) to PostSharp.dll.
  3. The MSBuild property SkipPostSharp is different than true and the compilation symbol SkipPostSharp is undefined.

The third condition is what becomes false when you disable PostSharp by checking the option in VS project properties.

You could disable PostSharp by default by setting the SkipPostSharp=True property by default. This can be achieved by creating a file named PostSharp.Custom.targets in one of the parent directories of your projects, with the following content:

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
     <SkipPostSharp Condition="'$(SkipPostSharp)'==''">True</SkipPostSharp>
  </PropertyGroup>
</Project>

Then, in every project where PostSharp is actually needed, you would need to define the property SkipPostSharp=False. You will have to do that using a text editor, because the project property tab only allows to set the property to True or to undefine it.

like image 115
Gael Fraiteur Avatar answered Sep 25 '22 03:09

Gael Fraiteur