Build Configuration
Language version, nullable types, and build settings
Source Control
SourceLink and repository metadata
Package Management
Central Package Management and NuGet audit
Code Injection
Polyfills, shared code, and extensions
Analyzers
Built-in .NET analyzers configuration
Usage Examples
Common configuration patterns
Build Configuration
C# language version. SDK enforces
latest by default.Nullable reference types. Enabled by default.
Enable implicit global usings.
Produce reproducible builds with identical binary output.
Treat all warnings as errors in CI or Release builds.
Enforce code style rules during build in CI or Release.
Source Control & SourceLink
Enable SourceLink for debugging into source. Requires git repository.
Include repository URL in NuGet package metadata.
Embed source files not tracked by git in the PDB.
Include git commit hash in assembly informational version.
Package Management
Enable Central Package Management (CPM).
Pin transitive package versions centrally.
Validate NuGet packages during build.
NuGet Audit
Enable security vulnerability auditing for packages.
Audit mode:
direct for direct dependencies only, all for transitive too.Minimum vulnerability severity to report.
Code Injection
Shared Code
Inject
Throw guard clause utilities. Provides Throw.IfNull(),
Throw.IfNullOrEmpty(), etc.Auto-generate
CLAUDE.md files for AI assistant context.Polyfills (Legacy TFM Support)
All polyfills default tofalse and are opt-in. Set to true to inject.
Bundle: Inject all applicable polyfills based on target framework.
Index/Range structs for
netstandard2.0 and older TFMs (enables array[^1]
syntax).IsExternalInit for init-only properties and records (pre-.NET 5).required keyword support (pre-.NET 7).Nullable reference type attributes (pre-.NET Core 3.1).
CallerArgumentExpression attribute (pre-.NET 6).UnreachableException type (pre-.NET 7).ExperimentalAttribute (pre-.NET 8).Trimmer/AOT attributes (pre-.NET 5).
String methods with
StringComparison parameter (fixes CA1307/CA2249 on
netstandard2.0).TimeProvider abstraction for testable time operations.System.Threading.Lock type polyfill.Extensions
Source generator helpers:
EquatableArray, DiagnosticInfo, LocationInfo.Common comparers including
StringOrdinalComparer.FakeLogger for testing logging in unit tests.Analyzer Configuration
Enable built-in .NET analyzers.
Analysis level:
latest-all enables all latest analyzers.Report analyzer execution time in build output.
Usage Examples
Polyfill Configuration
Polyfill Configuration
Use
InjectAllPolyfillsOnLegacy to enable all polyfills at once, or enable specific ones individually.Code Injection Options
Code Injection Options
Disable auto-generated code or shared utilities when not needed.
