Last active
July 20, 2017 21:52
-
-
Save aggieben/953345520eb1b9a6df58c5158f7249d6 to your computer and use it in GitHub Desktop.
List installed .NET Core SDK versions
This file contains 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/sh | |
# Benjamin Collins <[email protected]> | |
# Requires GNU readlink (get on macOS with `brew install coreutils`) | |
READLINK=${READLINK:-readlink} | |
cliPath=$(which dotnet) | |
netDir=$(dirname $($READLINK -f $cliPath)) | |
ls -1 "$netDir/sdk" |
This file contains 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
REM - from http://joshua.poehls.me/powershell-batch-file-wrapper/ | |
@ECHO OFF | |
SET SCRIPTNAME=%~d0%~p0%~n0.ps1 | |
SET ARGS=%* | |
IF [%ARGS%] NEQ [] GOTO ESCAPE_ARGS | |
:POWERSHELL | |
PowerShell.exe -NoProfile -NonInteractive -NoLogo -ExecutionPolicy Unrestricted -Command "& { & '%SCRIPTNAME%' @args; EXIT $LASTEXITCODE }" %ARGS% | |
EXIT /B %ERRORLEVEL% | |
:ESCAPE_ARGS | |
SET ARGS=%ARGS:"=\"% | |
SET ARGS=%ARGS:`=``% | |
SET ARGS=%ARGS:'=`'% | |
SET ARGS=%ARGS:$=`$% | |
SET ARGS=%ARGS:{=`}% | |
SET ARGS=%ARGS:}=`}% | |
SET ARGS=%ARGS:(=`(% | |
SET ARGS=%ARGS:)=`)% | |
SET ARGS=%ARGS:,=`,% | |
SET ARGS=%ARGS:^%=% | |
GOTO POWERSHELL |
This file contains 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
<# | |
.SYNOPSIS | |
Lists installed versions of the .NET Core SDK. | |
.NOTES | |
Version: 1.0 | |
Author: Ben Collins <[email protected]> | |
Creation Date: 1/5/2017 | |
#> | |
#$DebugPreference = "Continue" | |
$cliPath = Get-Command dotnet.exe | Select-Object -ExpandProperty Source | |
Write-Debug "Using $cliPath" | |
$netDir = Split-Path $cliPath | |
Get-ChildItem "$netDir/sdk" | Select-Object -ExpandProperty Name |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It seems that he new dotnet installations on macOS don't use a link, so it fails. For macOS, this works on my machine: