Cats.Build.Blacklist 2.0.1

dotnet add package Cats.Build.Blacklist --version 2.0.1
                    
NuGet\Install-Package Cats.Build.Blacklist -Version 2.0.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Cats.Build.Blacklist" Version="2.0.1">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Cats.Build.Blacklist" Version="2.0.1" />
                    
Directory.Packages.props
<PackageReference Include="Cats.Build.Blacklist">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Cats.Build.Blacklist --version 2.0.1
                    
#r "nuget: Cats.Build.Blacklist, 2.0.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Cats.Build.Blacklist@2.0.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Cats.Build.Blacklist&version=2.0.1
                    
Install as a Cake Addin
#tool nuget:?package=Cats.Build.Blacklist&version=2.0.1
                    
Install as a Cake Tool

MSBuild Blacklist

A simple MSBuild task to check your project's dependencies against a blacklist and fail if any matches are found.

Why?

  1. Prevent packages with breaking features/bugs from being referenced in your project (includes transitive dependencies)
  2. Prevent packages with strict usage licences from being installed (e.g. AGPL)
  3. Prevent unwanted project references

Installation

Install the alternate text is missing from this package README image into the project(s) that need a blacklist configured.

    Install-Package Cats.Build.Blacklist

Usage

NuGet Packages

To configure the package blacklist create a text file in the root of the project directory package.blacklist. Add each package ID you wish to blacklist on a newline. Optionally, you can add a NuGet version range which should be on the same line as the ID separated by a forward slash (/). Comments can be added by prefixing with a hash (#).

# This is a comment
iTextSharp # Blacklist all versions of iTextSharp due to AGPL license
Newtonsoft.Json/[6.0.1,7.0.0) # Blacklist versions 6.0.1 <= x < 7.0.0

Add the package ID multiple times to perform a logical OR between the rules.

Newtonsoft.Json/[6.0.1] # Blacklist versions 6.0.1
Newtonsoft.Json/[9.0.0] # Blacklist versions 9.0.0 (i.e. with above rule, 6.0.1 or 9.0.0 will be blacklisted)

Trying to build the project will result in an error if any of the blacklisted packages are found.

Project References

If you want to blacklist a project reference (e.g. to stop a business logic project referencing the UI), then create a text file in the project directory project.blacklist. It works the same as above, with the project names on separate lines.

MyAwesomeApp.UI # Blacklist UI reference from business logic project

How it works?

The build task reads the generated project.assets.json file that is usually found in the obj folder. This is a map of all the project's dependencies, which is used to determine if there are any matches on the blacklist.

You can override the any file paths used by the task by setting a property group in your csproj.

<PropertyGroup>
  <CatsProjectAssetsFilePath>custom\path\file.json</CatsProjectAssetsFilePath>
  <CatsPackageBlacklistFilePath>custom\path\file.blacklist</CatsPackageBlacklistFilePath>
  <CatsProjectBlacklistFilePath>custom\path\file.blacklist</CatsProjectBlacklistFilePath>
</PropertyGroup>
There are no supported framework assets in this package.

Learn more about Target Frameworks and .NET Standard.

  • net10.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.0.1 276 5/20/2026
2.0.0 120 5/20/2026
1.1.0 2,043 10/18/2021
1.0.0 803 1/16/2021
0.0.1-pre 494 12/22/2020

- Target net10
- Support for "project.assets.json" version 4