PackageReferenceCleaner 1.1.0

dotnet add package PackageReferenceCleaner --version 1.1.0                
NuGet\Install-Package PackageReferenceCleaner -Version 1.1.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="PackageReferenceCleaner" Version="1.1.0">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add PackageReferenceCleaner --version 1.1.0                
#r "nuget: PackageReferenceCleaner, 1.1.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install PackageReferenceCleaner as a Cake Addin
#addin nuget:?package=PackageReferenceCleaner&version=1.1.0

// Install PackageReferenceCleaner as a Cake Tool
#tool nuget:?package=PackageReferenceCleaner&version=1.1.0                

PackageReference Cleaner

Cleans the following crazy NuGet package reference mess:

<ItemGroup>
  <PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.3.1" Pack="false" />
  <PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1">
    <PrivateAssets>all</PrivateAssets>
    <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
  </PackageReference>
  <PackageReference Include="NuGetizer" Version="1.0.1">
    <PrivateAssets>all</PrivateAssets>
    <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
  </PackageReference>
  <PackageReference Include="PolySharp" Version="1.12.1">
    <PrivateAssets>all</PrivateAssets>
    <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
  </PackageReference>
  <PackageReference Include="ThisAssembly.AssemblyInfo" Version="1.2.12">
    <PrivateAssets>all</PrivateAssets>
    <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
  </PackageReference>
  <PackageReference Include="ThisAssembly.Git" Version="1.2.12">
    <PrivateAssets>all</PrivateAssets>
    <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
  </PackageReference>
  <PackageReference Include="GitInfo" Version="3.0.5">
    <PrivateAssets>all</PrivateAssets>
    <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
  </PackageReference>
</ItemGroup>

Into this perfectly clean and 100% equivalent beauty:

<ItemGroup>
  <PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.3.1" Pack="false" />
  <PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="all" />
  <PackageReference Include="NuGetizer" Version="1.0.1" PrivateAssets="all" />
  <PackageReference Include="PackageReferenceCleaner" Version="1.0.0" PrivateAssets="all" />
  <PackageReference Include="PolySharp" Version="1.12.1" PrivateAssets="all" />
  <PackageReference Include="ThisAssembly.AssemblyInfo" Version="1.2.12" PrivateAssets="all" />
  <PackageReference Include="ThisAssembly.Git" Version="1.2.12" PrivateAssets="all" />
  <PackageReference Include="GitInfo" Version="3.0.5" PrivateAssets="all" />
</ItemGroup>

How it works

A diagnostic analyzer inspects the MSBuild project file looking for <PackageReference> with PrivateAssets=all (via inner element or attribute), removes all its child nodes and moves (if necessary) the PrivateAssets child element to an attribute.

This is done automatically whenever the analyzer runs, and nothing is saved unless a node was cleaned.

Sponsors

Clarius Org C. Augusto Proiete Kirill Osenkov MFB Technologies, Inc. Stephen Shaw Torutek DRIVE.NET, Inc. David Kean alternate text is missing from this package README image Daniel Gnägi Ashley Medway Keith Pickford bitbonk Thomas Bolon Yurii Rashkovskii Kori Francis Zdenek Havlin Sean Killeen Toni Wenzel Giorgi Dalakishvili Kelly White Allan Ritchie Mike James Uno Platform Dan Siegel Reuben Swartz Jeremy Simmons Jacob Foshee alternate text is missing from this package README image Eric Johnson Norman Mackay Certify The Web Taylor Mansfield Mårten Rånge David Petric Rich Lee Danilo Dantas alternate text is missing from this package README image Gary Woodfine alternate text is missing from this package README image alternate text is missing from this package README image Steve Bilogan Ix Technologies B.V. New Relic Chris Johnston‮ David JENNI alternate text is missing from this package README image Jonathan Oleg Kyrylchuk

Sponsor this project  

Learn more about GitHub Sponsors

There are no supported framework assets in this package.

Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.1.0 357 8/11/2023