Opinionated MSBuild SDK for .NET projects.
global.json:
{
"sdk": {
"version": "11.0.100",
"rollForward": "latestFeature"
},
"msbuild-sdks": {
"ANcpLua.NET.Sdk": "4.0.1",
"ANcpLua.NET.Sdk.Web": "4.0.1",
"ANcpLua.NET.Sdk.Test": "4.0.1"
}
}Requires .NET SDK 11.0.100 or later; the build stops with a POLICY error on an older SDK.
<!-- Library/Console/Worker -->
<Project Sdk="ANcpLua.NET.Sdk"></Project>
<!-- Web API -->
<Project Sdk="ANcpLua.NET.Sdk.Web"></Project>
<!-- Test -->
<Project Sdk="ANcpLua.NET.Sdk.Test"></Project>All variants force <ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally> (and the
enforcement target errors if a consumer overrides it). Every consuming repo must ship a
Directory.Packages.props at or above the consumer's directory — even an empty one suffices:
<!-- Directory.Packages.props -->
<Project>
<PropertyGroup>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
</PropertyGroup>
</Project>Without it, restore fails with NU1015: PackageReference items do not have a version specified
on the SDK-injected analyzers (ANcpLua.Analyzers, Microsoft.CodeAnalysis.BannedApiAnalyzers)
because the SDK switches them to GlobalPackageReference, which only resolves through CPM.
4.0 moves the version truth to .NET 11: .NET SDK 11.0.100, Roslyn 5.12.0, ANcpLua.Analyzers 3.0.0,
the 11.0 runtime and ASP.NET Core packages (DotNetRuntimeVersion 11.0.0), Microsoft.Extensions 11.0.1,
Basic.Reference.Assemblies 1.8.15, and a net11.0 default for projects that declare no target framework.
ANcpLua.Analyzers 3.0.0 is compiled against Roslyn 5.12, so an older compiler reports CS9057 and runs
none of its rules — that is why the SDK now requires SDK 11.
Renovate opens one dotnet-11 PR per consumer that moves sdk.version and the msbuild-sdks entries
together. Finish that PR on its branch:
- Target framework. Change
net10.0tonet11.0(keepnetstandard2.0for analyzers and generators). Packages pinned to$(AspNetCoreVersion)or$(DotNetRuntimeVersion)are 11.0 now and restore only fornet11.0(NU1202 otherwise).net11.0defaults to C# 15; don't addLangVersion. - Other .NET 10 pins. A
mise.tomldotnetline,dotnet-version/container images in CI and Dockerfiles (mcr.microsoft.com/dotnet/*:10.0to11.0). - Local overrides. In a repo-local
Version.props, delete entries that are now equal to or below the SDK's values. - New findings. Build with
-c Release(warnings are errors there). The usual ones:IDE0028: collection initializers with constructor arguments become C# 15 collection expression arguments:new HashSet<string>(StringComparer.Ordinal) { "a" }becomes[with(StringComparer.Ordinal), "a"]. ADictionarytakeswith(...)only with no elements (CS9215otherwise), so fill it after creating it.dotnet format style --diagnostics IDE0028applies the fix.- New .NET 11 CA rules ship as suggestions (see
src/Config/Analyzer.Microsoft.CodeAnalysis.NetAnalyzers.editorconfig). - Analyzer or generator projects that compile against Roslyn 5.12 get
ITypeSymbol.IsUnion,IsClosed,GetClosedDerivedTypeInfoandUnionCaseTypesas stable APIs; dropRSEXPERIMENTAL006suppressions andLanguageVersion.Previewworkarounds for C# 15.
- ANcpLua.Analyzers rules — the 89 AL00xx/AL18xx diagnostics this SDK auto-injects, organized by domain band.
- Per-rule editorconfig profile — the severity table shipped alongside the SDK; consumers override individual rules via the standard
dotnet_diagnostic.{ID}.severity = …form.
- ANcpLua.Analyzers — Custom Roslyn analyzers (auto-injected)
- ANcpLua.Roslyn.Utilities — Source generator utilities
- ANcpLua.Agents — MAF runtime helpers + agent test infrastructure
Initial architecture inspired by Meziantou.NET.Sdk.