is a NuGet package containing Roslyn (static code) analyzers that report issues on .NET project files.
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
How to change the configuration of the rules can be found here. To configure (the severity) of the rules provided
The source code can be found at GitHub: github.com/dotnet-project-file-analyzers.
Issues (false positives, false negatives, etc.), and (rule) suggestions can be reported a the GibHub repository.
- Proj0001 MS Build project file could not be located
- Proj0002 Upgrade legacy MS Build project files
- Proj0003 Define usings explicit
- Proj0004 Run NuGet security audits automatically
- Proj0005 Define package reference assets as attributes
- Proj0006 Add additional files to improve static code analysis
- Proj0007 Remove empty nodes
- Proj0008 Remove folder nodes
- Proj0009 Use the TragetFramework node for a single target framework
- Proj0010 Define OutputType explicitly
- Proj0011 Define properties once
- Proj0012 Reassign properties with different value
- Proj0013 Include package references only once
- Proj0014 Include project references only once
- Proj0015 Order package references alphabetically
- Proj0016 Order project references alphabetically
- Proj0017 Can't create alias for static using directive
- Proj0018 Order using directives by type
- Proj0019 Order using directives alphabetically
- Proj0020 Item group should only contain nodes of a single type
- Proj0021 Build actions should have a single task
- Proj0022 Build actions should have a single task
- Proj0023 Use forward slashes in paths
- Proj0024 Order package versions alphabetically
- Proj0200 Define IsPackable explicitly
- Proj0201 Define the project version explicitly
- Proj0202 Define the project description explicitly
- Proj0203 Define the project authors explicitly
- Proj0204 Define the project tags explicitly
- Proj0205 Define the project repository URL explicitly
- Proj0206 Define the project URL explicitly
- Proj0207 Define the project copyright explicitly
- Proj0208 Define the project release notes explicitly
- Proj0209 Define the project readme file explicitly
- Proj0210 Define the project license explicitly
- Proj0211 Avoid using deprecated license definition
- Proj0212 Define the project icon file explicitly
- Proj0213 Define the project icon URL explicitly
- Proj0214 Define the NuGet project ID explicitly
- Proj0240 Enable package validation
- Proj0241 Enable package baseline validation
- Proj0242 Generate NuGet packages conditionally
- Proj0400 Define the project publishability explicitly
- Proj0600 Avoid generating packages on build if not packable
- Proj1000 Use the .NET project file analyzers
- Proj1001 Use analyzers for packages
- Proj1002 Use Microsoft's analyzers
- Proj1003 Use Sonar analyzers
- Proj1100 Avoid using Moq
- Proj1200 Exclude private assets as project file dependency
- Proj1700 Indent XML
- Proj2000 Embed valid resource files
- Proj2001 Define data in a resource file
- Proj2002 Sort resource file values alphabetically
- Proj2003 Add invariant fallback resources
- Proj2004 Add invariant fallback values
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:
<?xml version="1.0" encoding="utf-8"?>
<Project>
<ItemGroup>
<AdditionalFiles Include="../props/{file_name}" Link="Properties/{file_name}" />
</ItemGroup>
</Project>