Skip to content

Instantly share code, notes, and snippets.

@JonCanning
Last active May 12, 2020 21:15
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JonCanning/a083e80c53eb68fac32fe1bfe8e63c48 to your computer and use it in GitHub Desktop.
Save JonCanning/a083e80c53eb68fac32fe1bfe8e63c48 to your computer and use it in GitHub Desktop.
dotnet nuget update packages
$regex = [regex] 'PackageReference Include="([^"]*)" Version="([^"]*)"'
ForEach ($file in get-childitem . -recurse | where {$_.extension -like "*proj"})
{
$proj = $file.fullname
$content = Get-Content $proj
$match = $regex.Match($content)
if ($match.Success) {
$name = $match.Groups[1].Value
$version = $match.Groups[2].Value
if ($version -notin "-") {
iex "dotnet add $proj package $name"
}
}
}
#!/bin/bash
regex='PackageReference Include="([^"]*)" Version="([^"]*)"'
find . -name "*.*proj" | while read proj
do
while read line
do
if [[ $line =~ $regex ]]
then
name="${BASH_REMATCH[1]}"
version="${BASH_REMATCH[2]}"
if [[ $version != *-* ]]
then
dotnet add $proj package $name
fi
fi
done < $proj
done
@JonCanning
Copy link
Author

Update all packages except pre release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment