← All recipes
Moderne licensed

Convert packages.config to <PackageReference>

Recipe IDOpenRewrite.CSharp.Recipes.ConvertPackagesConfigToPackageReferenceArtifactOpenRewrite.Recipes.CSharp.Core

Moves NuGet dependencies from packages.config into <PackageReference> items in the sibling project file, classifying top-level vs. transitive packages and reconstructing IncludeAssets/ExcludeAssets/PrivateAssets from the resolved dependency graph. Removes packaged <Reference>/<Import>/<Analyzer> wiring, the EnsureNuGetPackageBuildImports target and NuGetPackageImportStamp property, rewrites remaining packages/ folder paths to $(PkgXxx) properties, deletes packages.config, and flags package behaviors that PackageReference does not support (install.ps1, XDT config transforms, legacy content/ assets) for manual follow-up.

Single recipecsharpdotnetpackages-configcsprojnugetProprietary

Usage

This recipe has no required configuration options. You’ll need the Moderne CLI configured before running the command below.

mod run . --recipe OpenRewrite.CSharp.Recipes.ConvertPackagesConfigToPackageReference

If the recipe isn’t available locally, install it with:

mod config recipes nuget install OpenRewrite.Recipes.CSharp.Core

Options

NameTypeDescription
TrimTransitiveBooleanDrop packages.config entries that are transitive dependencies of other entries instead of keeping them as explicit top-level pins. The restored package versions may drift over time as ranges re-resolve. Defaults to false.