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.
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
.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.
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
- Proj0025 Migrate from ruleset file to .editorconfig file
- Proj0026 Remove IncludeAssets when redundant
- Proj0027 Override <TargetFrameworks> with <TargetFrameworks>
- Proj0028 Define conditions on level 1
- Proj0029 Use C# specific properties only when applicable
- Proj0030 Use VB.NET specific properties only when applicable
- Proj0031 Adopt preferred casing of nodes
- 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
- Proj0215 Provide a compliant NuGet package icon
- Proj0216 Define the product name explicitly
- Proj0240 Enable package validation
- Proj0241 Enable package baseline validation
- Proj0242 Generate NuGet packages conditionally
- Proj0600 Avoid generating packages on build if not packable
- Proj0450 Test projects should not be packable
- Proj0451 Test projects should not be publishable
- Proj0452 Test projects require Microsoft.NET.Test.Sdk
- Proj0453 Using Microsoft.NET.Test.Sdk implies a test project
- Proj0800 Configure Central Package Management
- Proj0801 Include 'Directory.Packages.props'
- Proj0802 Enable Central Package Management centrally
- Proj0803 Use VersionOverride only with Central Package Management enabled
- Proj0804 Use Version only with Central Package Management not enabled
- Proj0805 Define version for PackageReference
- Proj0806 VersionOverride should change the version
- Proj0807 Use Directory.Packages.props only for Central Package Management
- 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
- Proj1101 Package references should have stable versions
- Proj1200 Exclude private assets as project file dependency
- 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
- Proj2005 Escape XML nodes of resource values
- Proj2100 Indent RESX
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>
By default, results by .NET project file analyzers are not added to Sonar's reporting. Read here how to configure this correctly.
.NET project file analyzers is licensed under MIT.