Last active
May 12, 2020 21:15
-
-
Save JonCanning/a083e80c53eb68fac32fe1bfe8e63c48 to your computer and use it in GitHub Desktop.
dotnet nuget update packages
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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" | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Update all packages except pre release