Skip to content

Convert your .NET dependencies to the Directory.Packages.props format

License

Notifications You must be signed in to change notification settings

Vannevelj/directory-packages-props-converter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

directory-packages-props-converter

Converts your projects to use Central Package Management. <PackageReference> dependencies have their Version removed in each individual .csproj file. Instead, a Directory.Packages.props file is created in the root folder which contains the version for each separate dependency.

Getting started

Download the binary from the releases.

Mac:

chmod +x ./directory-packages-props-converter
./directory-packages-props-converter .

If your Mac prevents you from running the executable, right-click the executable and select "Open" to override the default block.


Windows:

.\directory-packages-props-converter.exe .

Once you've ran the script, you'll see a new Directory.Packages.props like this:

<Project>
  <PropertyGroup>
    <ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
  </PropertyGroup>

  <ItemGroup>

    <PackageVersion Include="MSTest.TestAdapter" Version="3.0.2" />
    <PackageVersion Include="MSTest.TestFramework" Version="3.0.2" />
    <PackageVersion Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.2.0" />
    <PackageVersion Include="Microsoft.AspNetCore.Mvc" Version="2.2.0" />
    <PackageVersion Include="Microsoft.CodeAnalysis" Version="4.4.0" />
  
  </ItemGroup>
</Project>

and corresponding .csproj changes like this

<ItemGroup>
-    <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.1" />
-    <PackageReference Include="MSTest.TestAdapter" Version="3.0.2" />
+    <PackageReference Include="Microsoft.NET.Test.Sdk" />
+    <PackageReference Include="MSTest.TestAdapter" />
</ItemGroup>

Notes

  • When multiple versions are detected for a particular dependency, the highest version number is used
  • Supports .csproj and Directory.Build.props files
  • Partial support for version ranges like [1.1.0, 2]: they will be included in Directory.Packages.props but without trying to discover the largest version

About

Convert your .NET dependencies to the Directory.Packages.props format

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages