msbuild-modernization

Migrates legacy MSBuild project files to SDK-style format with PackageReference and Directory.Build consolidation.

Updated Jul 12, 2026
One-click install
npx skills add https://github.com/Patrick-Rex/DotNetTechSamples --skill msbuild-modernization-patrick-rex
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: msbuild-modernization
Source: https://github.com/Patrick-Rex/DotNetTechSamples/tree/main/.agents/plugins/dotnet-msbuild/skills/msbuild-modernization
Command: npx skills add https://github.com/Patrick-Rex/DotNetTechSamples --skill msbuild-modernization-patrick-rex

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Legacy .NET projects carry verbose XML, explicit file lists, packages.config, and AssemblyInfo.cs boilerplate that make builds hard to maintain. This Skill provides a step-by-step checklist to convert those projects into minimal SDK-style .csproj files. ## Core Features & Use Cases - Legacy Detection: Identifies legacy projects via ToolsVersion attributes, MSBuildToolsPath imports, packages.config, and .csproj files over 50 lines. - Seven-Step Migration Checklist: Covers root element replacement, TargetFramework mapping, implicit globbing, AssemblyInfo removal, packages.config to PackageReference conversion, boilerplate cleanup, and enabling Nullable/ImplicitUsings. - Consolidation Guidance: Explains Central Package Management with Directory.Packages.props and shared settings via Directory.Build.props/targets. - Use Case: A team inherits a .NET Framework 4.7.2 solution with 80-line .csproj files and packages.config. Use this Skill to reduce each project to ~10 lines, migrate NuGet references, and centralize shared properties. ## Quick Start Convert this legacy .csproj file to SDK-style format and migrate its packages.config to PackageReference entries.

Frequently Asked Questions about msbuild-modernization

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I convert a legacy .csproj to SDK-style format?

Replace the root element with <Project Sdk="Microsoft.NET.Sdk">, change TargetFrameworkVersion to TargetFramework (e.g., v4.7.2 to net472), delete explicit Compile includes and AssemblyInfo.cs, and remove default configuration boilerplate. The SDK supplies globbing and defaults automatically.

How to migrate packages.config to PackageReference?

Convert each packages.config entry into a <PackageReference Include="..." Version="..." /> item in the .csproj, then delete packages.config. Visual Studio offers a right-click migration option, and SDK-style projects auto-generate binding redirects.

What are the signs of a legacy MSBuild project file?

Legacy indicators include a ToolsVersion attribute, <Import Project="$(MSBuildToolsPath)\..."> lines, explicit <Compile Include> entries for every file, a packages.config file, and Properties/AssemblyInfo.cs. A .csproj over 50 lines for a simple project is likely legacy.

Can SDK-style projects still target .NET Framework?

Yes. SDK-style projects support .NET Framework targets such as net461, net472, and net48 via the TargetFramework property. You can also multi-target with <TargetFrameworks>net472;net8.0</TargetFrameworks>.

Should I set LangVersion to latest in my project?

No. The effective language version depends on the installed SDK, so builds can vary across machines. Omit LangVersion, pin the SDK with global.json, or set an explicit numeric version like <LangVersion>12</LangVersion> for reproducible builds.

When should I not migrate a project to SDK-style?

Do not migrate projects already in SDK-style format, non-.NET build systems like npm or Maven, or .NET Framework projects that cannot move to SDK-style due to tooling constraints. The Skill explicitly excludes these cases.