.NET project file analyzers community

.NET project file analyzers logo

.NET project file analyzers

is a NuGet package containing Roslyn (static code) analyzers that report issues on .NET project files.

The documentation reflects the current repository state of the features, not the released ones. Check the Release Notes to understand if the documented feature you want to use has been released.

Installation

DotNetProjectFile.AnalyzersDotNetProjectFile.Analyzers

To use the analyzers, you must include the analyzer package in your project file:

<Project Sdk="Microsoft.NET.Sdk">

  <ItemGroup>
    <PackageReference Include="DotNetProjectFile.Analyzers" Version="*" PrivateAssets="all" />
  </ItemGroup>

</Project>

Or via the command line:

dotnet package add DotNetProjectFile.Analyzers

Configuration

How to change the configuration of the rules can be found here. To configure (the severity) of the rules provided

Sdk

.NET Project File Analyzers ships with its own SDK. This allows files shared by multiple projects to be analyzed. More info can be found here.

GitHub repository

The source code can be found at GitHub: github.com/dotnet-project-file-analyzers.

Issues and suggestions

Issues (false positives, false negatives, etc.), and (rule) suggestions can be reported a the GibHub repository.

MS Build project file rules

Packaging

Publishing

Test projects

.NET Project File Analyzers SDK

Central Package Management

Analyzers

Formatting

Other

Resource file rules

Generic

INI

Additional files

To fully benefit from these analyzers it is recommended to add the project file (and imported projects/props) as additional files.

To add a project file:

<Project Sdk="Microsoft.NET.Sdk">

  <ItemGroup>
    <AdditionalFiles Include="*.??proj" Visible="false" />
  </ItemGroup>

</Project>

To add a props file:

<Project>

  <ItemGroup>
    <AdditionalFiles Include="../props/{file_name}" Link="Properties/{file_name}" />
  </ItemGroup>

</Project>

Sonar integration

By default, results by .NET project file analyzers are not added to Sonar’s reporting. Read here how to configure this correctly.

License

.NET project file analyzers is licensed under MIT.