Skip to content

Commit

Permalink
feat: add Update-DotnetTools
Browse files Browse the repository at this point in the history
guitarrapc committed Sep 9, 2023
1 parent 2cce3b8 commit 9b65f21
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions dotnet-tools/Upodate-DotnetTools.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<#
.SYNOPSIS
Update all dotnet tools installed on the system.
See https://learn.microsoft.com/en-us/dotnet/core/tools/global-tools for dotnet-tools.
.EXAMPLE
# Update Project's dotnet tools
Update-DotnetTools
# Update Global dotnet tools
Update-DotnetTools -Global
#>
function Update-DotnetTools {
param(
[Switch]$Global
)

$globalSwitch = ""
if ($Global) {
$globalSwitch = "-g"
}

# $ dotnet tool list -g
# Package Id Version Commands
# ---------------------------------------------------
# dotnet-ildasm 0.12.2 dotnet-ildasm
# unitybuildrunner 3.4.0 UnityBuildRunner
$tools = dotnet tool list $globalSwitch | Select-Object -Skip 2
# dotnet-ildasm 0.12.2 dotnet-ildasm
# unitybuildrunner 3.4.0 UnityBuildRunner

foreach ($tool in $tools) {
# dotnet-ildasm 0.12.2 dotnet-ildasm
# 13
$end = $tool.IndexOf(" ")
# dotnet-ildasm
$toolName = ($tool.Substring(0, $end)).Trim()
dotnet tool update $globalSwitch "$toolName"
}
}

0 comments on commit 9b65f21

Please sign in to comment.