https://github.com/danielmackay/directory.build.props
https://github.com/danielmackay/directory.build.props
Last synced: 4 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/danielmackay/directory.build.props
- Owner: danielmackay
- License: mit
- Created: 2024-08-05T21:16:29.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-08-16T11:08:10.000Z (almost 2 years ago)
- Last Synced: 2024-08-16T12:29:05.979Z (almost 2 years ago)
- Size: 9.77 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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.