These are a couple of useful scripts -- for use in tandem -- that make it easier to migrate PackageReference Include=...
items to a common Packages.props
file. Use them in combination with each other like:
New-PackagesProps (Get-PackageReference ./MySolution.sln) | Set-Content -Path ./Packages.props
Or, you can use the Get-SolutionProject
to get the projects referenced in the solution:
Get-SolutionProject ./MySolution.sln
Or, if you have intentions of just getting packages from solution(s) or project(s):
# Will traverse referenced projects and spit out their PackageReferences
Get-PackageReference ./MySolution.sln
# Will output all PackageReferences in project
Get-PackageReference ./MyProject.csproj
# Will output all PackageReferences in input projects
Get-ChildItem -Recurse *.csproj | Get-PackageReference