This Visual Studio extension and dotnet tool converts PackageReference
Version
child elements to attributes in C# project files (csproj
).
It can also convert all projects in a Visual Studio solution file (sln
).
-
Download and install the extension from the Visual Studio Marketplace.
-
Right-click on the root
Solution
node, or one or more projects, and selectConvert PackageReference Version elements to attributes...
. -
Wait until the process finishes.
Check the status bar or thePackageReferences Version to Attribute Extension
pane in theOutput Window
for details.
- Install the dotnet tool using the following command:
dotnet tool install PackageReferenceVersionToAttribute.Tool
- To convert all csproj files in the current directory and its subdirectories, run the tool with the command:
PackageReferenceVersionToAttribute.Tool .\**\*.csproj
- For additional options and usage, you can run:
PackageReferenceVersionToAttribute.Tool --help
The extension will create a backup of each project file.
For example, MyProject.csproj
will be copied to MyProject.csproj.bak
.
If the project file is source controlled, it will be checked out for modification.
The Version
child elements of PackageReference
will be converted to a Version
attribute.
For example, the following elements in the csproj
project file:
<PackageReference Include="Newtonsoft.Json">
<Version>13.0.3</Version>
</PackageReference>
will be converted to this:
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
Has this extension helped you at all?
If so, please rate and share it.
Thank you! :)