SimonD
SimonD

Reputation: 1547

Package reference condition - exclude for some project

I have the following entry in Package.props file on solution level:

<ItemGroup Label="My Label" Condition=" '$(SHFBSchemaVersion)' == '' ">
    <PackageReference Include="StyleCop.Analyzers">
      <PrivateAssets>all</PrivateAssets>
      <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
    </PackageReference>    
  </ItemGroup>

How should I edit this so that reference for StyleCop will be excluded for some project? Something like:

<ItemGroup Label="My Label" Condition=" '$(SHFBSchemaVersion)' == '' " Exclude="MyAwsomeProject">

So I would like that 'MyAwsomeProject' will not have a reference to StyleCop.

Upvotes: 1

Views: 980

Answers (1)

SimonD
SimonD

Reputation: 1547

I managed to get it working like this:

<ItemGroup Label="My Label" Condition=" '$(SHFBSchemaVersion)' == ''  And '$(AssemblyName)' != 'MyAwsomeProject'">
    <PackageReference Include="StyleCop.Analyzers">
      <PrivateAssets>all</PrivateAssets>
      <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
    </PackageReference>    
</ItemGroup>

Upvotes: 0

Related Questions