@@ -15,6 +15,20 @@ function Test-IsWindows
1515 [environment ]::OSVersion.Platform -ne " Unix"
1616}
1717
18+ function Get-UbuntuVersion
19+ {
20+ <#
21+ . DESCRIPTION
22+ Gets the Ubuntu version.
23+
24+ . EXAMPLE
25+ $ubuntuVersion = Get-UbuntuVersion
26+ #>
27+
28+ $version = Invoke-Cmd " lsb_release -r -s"
29+ return $version
30+ }
31+
1832function Invoke-UnsafeCmd ($cmd )
1933{
2034 <#
@@ -235,7 +249,10 @@ function Get-NetCoreSdkFromWeb ($version)
235249 The SDK version which should be downloaded.
236250 #>
237251
238- $os = if (Test-IsWindows ) { " windows" } else { " linux" }
252+ Write-Host " Downloading .NET Core SDK $version ..."
253+
254+ $os = if (Test-IsWindows ) { " windows" } else { " linux" }
255+ $ext = if (Test-IsWindows ) { " .zip" } else { " .tar.gz" }
239256
240257 $response = Invoke-WebRequest `
241258 - Uri " https://www.microsoft.com/net/download/thank-you/dotnet-sdk-$version -$os -x64-binaries" `
@@ -247,13 +264,17 @@ function Get-NetCoreSdkFromWeb ($version)
247264 | Where-Object { $_.onclick -eq " recordManualDownload()" } `
248265 | Select-Object - Expand href
249266
250- $tempFile = [System.IO.Path ]::GetTempFileName()
267+ $tempFile = [System.IO.Path ]::GetTempFileName() + $ext
268+
251269 $webClient = New-Object System.Net.WebClient
252270 $webClient.DownloadFile ($downloadLink , $tempFile )
271+
272+ Write-Host " Download finished. SDK has been saved to '$tempFile '."
273+
253274 return $tempFile
254275}
255276
256- function Install-NetCoreSdk ($sdkZipPath )
277+ function Install-NetCoreSdkFromArchive ($sdkArchivePath )
257278{
258279 <#
259280 . DESCRIPTION
@@ -263,13 +284,35 @@ function Install-NetCoreSdk ($sdkZipPath)
263284 The zip archive which contains the .NET Core SDK.
264285 #>
265286
287+ if (Test-IsWindows )
288+ {
289+ $env: DOTNET_INSTALL_DIR = [System.IO.Path ]::Combine($pwd , " .dotnetsdk" )
290+ New-Item $env: DOTNET_INSTALL_DIR - ItemType Directory - Force | Out-Null
291+ Write-Host " Created folder '$env: DOTNET_INSTALL_DIR '."
292+ Expand-Archive - LiteralPath $sdkArchivePath - DestinationPath $env: DOTNET_INSTALL_DIR - Force
293+ Write-Host " Extracted '$sdkArchivePath ' to folder '$env: DOTNET_INSTALL_DIR '."
294+ $env: Path = " $env: DOTNET_INSTALL_DIR ;$env: Path "
295+ Write-Host " Added '$env: DOTNET_INSTALL_DIR ' to the environment variables."
296+ }
297+ else
298+ {
299+ $dotnetInstallDir = " $env: HOME /.dotnetsdk"
300+ Invoke-Cmd " mkdir -p $dotnetInstallDir "
301+ Write-Host " Created folder '$dotnetInstallDir '."
302+ Invoke-Cmd " tar -xf $sdkArchivePath -C $dotnetInstallDir "
303+ Write-Host " Extracted '$sdkArchivePath ' to folder '$dotnetInstallDir '."
304+ $env: PATH = " $env: PATH :$dotnetInstallDir "
305+ Write-Host " Added '$dotnetInstallDir ' to the environment variables."
306+ }
307+ }
266308
267- $env: DOTNET_INSTALL_DIR = " $pwd \.dotnetsdk"
268- New-Item $env: DOTNET_INSTALL_DIR - ItemType Directory - Force
269-
270- Add-Type - AssemblyName System.IO.Compression.FileSystem;
271- [System.IO.Compression.ZipFile ]::ExtractToDirectory($sdkZipPath , $env: DOTNET_INSTALL_DIR )
272- $env: Path = " $env: DOTNET_INSTALL_DIR ;$env: Path "
309+ function Install-NetCoreSdkForUbuntu ($ubuntuVersion , $sdkVersion )
310+ {
311+ Invoke-Cmd " wget -q https://packages.microsoft.com/config/ubuntu/$ubuntuVersion /packages-microsoft-prod.deb"
312+ Invoke-Cmd " sudo dpkg -i packages-microsoft-prod.deb"
313+ Invoke-Cmd " sudo apt-get install apt-transport-https"
314+ Invoke-Cmd " sudo apt-get update"
315+ Invoke-Cmd " sudo apt-get -y install dotnet-sdk-$sdkVersion "
273316}
274317
275318# ----------------------------------------------
@@ -280,14 +323,11 @@ function Test-IsAppVeyorBuild { return ($env:APPVEYOR -eq $true
280323function Test-IsAppVeyorBuildTriggeredByGitTag { return ($env: APPVEYOR_REPO_TAG -eq $true ) }
281324function Get-AppVeyorGitTag { return $env: APPVEYOR_REPO_TAG_NAME }
282325
283- function Update-AppVeyorBuildVersion ($projFile )
326+ function Update-AppVeyorBuildVersion ($version )
284327{
285328 if (Test-IsAppVeyorBuild )
286329 {
287330 Write-Host " Updating AppVeyor build version..." - ForegroundColor Magenta
288-
289- [xml ]$xml = Get-Content $projFile
290- $version = $xml.Project.PropertyGroup.Version
291331 $buildVersion = " $version -$env: APPVEYOR_BUILD_NUMBER "
292332 Write-Host " Setting AppVeyor build version to $buildVersion ."
293333 Update-AppveyorBuild - Version $buildVersion
0 commit comments