An open API service indexing awesome lists of open source software.

https://github.com/danielmackay/directory.build.props


https://github.com/danielmackay/directory.build.props

Last synced: 4 months ago
JSON representation

Awesome Lists containing this project

README

          

# Directory.Build.props

Add global static code analysis to your .NET projects. This avoids having to update each `.csproj` file individually.

## Usage

Create a `Directory.Build.props` file in the root of your solution:

```xml


net8.0
enable
enable


latest
Recommended
true
true
true




all
runtime; build; native; contentfiles; analyzers; buildtransitive

```

## Features

- `TargetFramework` - Set the target .NET framework of all projects
- `ImplicitUsings` - use default usings provided by .NET to keep your usings cleaner
- `Nullable` - Reference types are non-nullably by default. This helps to avoid null reference exceptions
- `AnalysisLevel` - Use the latest available code analysis rules. This ensures that the code is checked against the most up-to-date standards and practices.
- `AnalysisMode` - `Recommended` Enables most rules, but is slightly less aggressive than `All` (maximum)
- `TreatWarningsAsErrors` - Any warnings will be promoted to errors for `Release` builds
- `CodeAnalysisTreatWarningsAsErrors` - Code analysis warnings (CAXXXX) will be treated as errors
- `EnforceCodeStyleInBuild` - Code analysis rules (IDEXXXX) will show as warnings

## What is a `Directory.Build.props`?

A Directory.Build.props file is an MSBuild file used in .NET projects to define common properties and configurations that apply to multiple projects within a directory tree. This file helps centralize the configuration and reduce redundancy by allowing you to specify settings that will be inherited by all projects under the directory where the file is located.