1+ # !/usr/bin/env pwsh
2+ $DotNetInstallerUri = ' https://dot.net/v1/dotnet-install.ps1' ;
3+ $DotNetUnixInstallerUri = ' https://dot.net/v1/dotnet-install.sh'
4+ $DotNetChannel = ' LTS'
5+ $PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path - Parent
6+
7+ [string ] $DotNetVersion = ' '
8+ foreach ($line in Get-Content (Join-Path $PSScriptRoot ' build.config' ))
9+ {
10+ if ($line -like ' DOTNET_VERSION=*' ) {
11+ $DotNetVersion = $line.SubString (15 )
12+ }
13+ }
14+
15+
16+ if ([string ]::IsNullOrEmpty($DotNetVersion )) {
17+ ' Failed to parse .NET Core SDK Version'
18+ exit 1
19+ }
20+
21+ $DotNetInstallerUri = " https://dot.net/v1/dotnet-install.ps1" ;
22+
23+ # Make sure tools folder exists
24+ $PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path - Parent
25+ $ToolPath = Join-Path $PSScriptRoot " tools"
26+ if (! (Test-Path $ToolPath )) {
27+ Write-Verbose " Creating tools directory..."
28+ New-Item - Path $ToolPath - Type directory | out-null
29+ }
30+
31+ # ##########################################################################
32+ # INSTALL .NET CORE CLI
33+ # ##########################################################################
34+
35+ Function Remove-PathVariable ([string ]$VariableToRemove )
36+ {
37+ $path = [Environment ]::GetEnvironmentVariable(" PATH" , " User" )
38+ $newItems = $path.Split (' ;' ) | Where-Object { $_.ToString () -inotlike $VariableToRemove }
39+ [Environment ]::SetEnvironmentVariable(" PATH" , [System.String ]::Join(' ;' , $newItems ), " User" )
40+ $path = [Environment ]::GetEnvironmentVariable(" PATH" , " Process" )
41+ $newItems = $path.Split (' ;' ) | Where-Object { $_.ToString () -inotlike $VariableToRemove }
42+ [Environment ]::SetEnvironmentVariable(" PATH" , [System.String ]::Join(' ;' , $newItems ), " Process" )
43+ }
44+
45+ # Get .NET Core CLI path if installed.
46+ $FoundDotNetCliVersion = $null ;
47+ if (Get-Command dotnet - ErrorAction SilentlyContinue) {
48+ $FoundDotNetCliVersion = dotnet -- version;
49+ }
50+
51+ if ($FoundDotNetCliVersion -ne $DotNetVersion ) {
52+ $InstallPath = Join-Path $PSScriptRoot " .dotnet"
53+ if (! (Test-Path $InstallPath )) {
54+ mkdir - Force $InstallPath | Out-Null ;
55+ }
56+ (New-Object System.Net.WebClient).DownloadFile($DotNetInstallerUri , " $InstallPath \dotnet-install.ps1" );
57+ & $InstallPath \dotnet- install.ps1 - Version $DotNetVersion - InstallDir $InstallPath ;
58+
59+ Remove-PathVariable " $InstallPath "
60+ $env: PATH = " $InstallPath ;$env: PATH "
61+ $env: DOTNET_SKIP_FIRST_TIME_EXPERIENCE = 1
62+ $env: DOTNET_CLI_TELEMETRY_OPTOUT = 1
63+ }
64+
65+ # ##########################################################################
66+ # RUN BUILD SCRIPT
67+ # ##########################################################################
68+
69+ dotnet run -- project build/ Engage.Dnn.SqlServerTypes.Build.csproj -- $args
70+ exit $LASTEXITCODE ;
0 commit comments