|
3 | 3 | ######################## |
4 | 4 |
|
5 | 5 | Push-Location $PSScriptRoot |
6 | | -Import-Module $PSScriptRoot\Build\Autofac.Build.psd1 -Force |
| 6 | +try { |
| 7 | + Import-Module $PSScriptRoot/build/Autofac.Build.psd1 -Force |
7 | 8 |
|
8 | | -$artifactsPath = "$PSScriptRoot\artifacts" |
9 | | -$packagesPath = "$artifactsPath\packages" |
10 | | -$sdkVersion = (Get-Content "$PSScriptRoot\global.json" | ConvertFrom-Json).sdk.version |
| 9 | + $artifactsPath = "$PSScriptRoot/artifacts" |
| 10 | + $packagesPath = "$artifactsPath/packages" |
11 | 11 |
|
12 | | -# Clean up artifacts folder |
13 | | -if (Test-Path $artifactsPath) { |
14 | | - Write-Message "Cleaning $artifactsPath folder" |
15 | | - Remove-Item $artifactsPath -Force -Recurse |
16 | | -} |
| 12 | + $globalJson = (Get-Content "$PSScriptRoot/global.json" | ConvertFrom-Json -NoEnumerate); |
| 13 | + |
| 14 | + $sdkVersion = $globalJson.sdk.version |
| 15 | + |
| 16 | + # Clean up artifacts folder |
| 17 | + if (Test-Path $artifactsPath) { |
| 18 | + Write-Message "Cleaning $artifactsPath folder" |
| 19 | + Remove-Item $artifactsPath -Force -Recurse |
| 20 | + } |
17 | 21 |
|
18 | | -# Install dotnet CLI |
19 | | -Write-Message "Installing .NET Core SDK version $sdkVersion" |
20 | | -Install-DotNetCli -Version $sdkVersion |
| 22 | + # Install dotnet SDK versions during CI. In a local build we assume you have |
| 23 | + # everything installed; on CI we'll force the install. If you install _any_ |
| 24 | + # SDKs, you have to install _all_ of them because you can't install SDKs in |
| 25 | + # two different locations. dotnet CLI locates SDKs relative to the |
| 26 | + # executable. |
| 27 | + if ($Null -ne $env:APPVEYOR_BUILD_NUMBER) { |
| 28 | + Install-DotNetCli -Version $sdkVersion |
| 29 | + foreach ($additional in $globalJson.additionalSdks) |
| 30 | + { |
| 31 | + Install-DotNetCli -Version $additional; |
| 32 | + } |
| 33 | + } |
21 | 34 |
|
22 | | -# Write out dotnet information |
23 | | -& dotnet --info |
| 35 | + # Write out dotnet information |
| 36 | + & dotnet --info |
24 | 37 |
|
25 | | -# Set version suffix |
26 | | -$branch = @{ $true = $env:APPVEYOR_REPO_BRANCH; $false = $(git symbolic-ref --short -q HEAD) }[$env:APPVEYOR_REPO_BRANCH -ne $NULL]; |
27 | | -$revision = @{ $true = "{0:00000}" -f [convert]::ToInt32("0" + $env:APPVEYOR_BUILD_NUMBER, 10); $false = "local" }[$env:APPVEYOR_BUILD_NUMBER -ne $NULL]; |
28 | | -$versionSuffix = @{ $true = ""; $false = "$($branch.Substring(0, [math]::Min(10,$branch.Length)))-$revision"}[$branch -eq "master" -and $revision -ne "local"] |
| 38 | + # Set version suffix |
| 39 | + $branch = @{ $true = $env:APPVEYOR_REPO_BRANCH; $false = $(git symbolic-ref --short -q HEAD) }[$NULL -ne $env:APPVEYOR_REPO_BRANCH]; |
| 40 | + $revision = @{ $true = "{0:00000}" -f [convert]::ToInt32("0" + $env:APPVEYOR_BUILD_NUMBER, 10); $false = "local" }[$NULL -ne $env:APPVEYOR_BUILD_NUMBER]; |
| 41 | + $versionSuffix = @{ $true = ""; $false = "$($branch.Substring(0, [math]::Min(10,$branch.Length)).Replace('/', '-'))-$revision" }[$branch -eq "master" -and $revision -ne "local"] |
29 | 42 |
|
30 | | -Write-Message "Package version suffix is '$versionSuffix'" |
| 43 | + Write-Message "Package version suffix is '$versionSuffix'" |
31 | 44 |
|
32 | | -# Package restore |
33 | | -Write-Message "Restoring packages" |
34 | | -Get-DotNetProjectDirectory -RootPath $PSScriptRoot | Restore-DependencyPackages |
| 45 | + # Package restore |
| 46 | + Write-Message "Restoring packages" |
| 47 | + Get-DotNetProjectDirectory -RootPath $PSScriptRoot | Restore-DependencyPackages |
35 | 48 |
|
36 | | -# Build/package |
37 | | -Write-Message "Building projects and packages" |
38 | | -Get-DotNetProjectDirectory -RootPath $PSScriptRoot\src | Invoke-DotNetPack -PackagesPath $packagesPath -VersionSuffix $versionSuffix |
| 49 | + # Build/package |
| 50 | + Write-Message "Building projects and packages" |
| 51 | + Get-DotNetProjectDirectory -RootPath $PSScriptRoot\src | Invoke-DotNetPack -PackagesPath $packagesPath -VersionSuffix $versionSuffix |
39 | 52 |
|
40 | | -# Test |
41 | | -Write-Message "Executing unit tests" |
42 | | -Get-DotNetProjectDirectory -RootPath $PSScriptRoot\test | Invoke-Test |
| 53 | + # Test |
| 54 | + Write-Message "Executing unit tests" |
| 55 | + Get-DotNetProjectDirectory -RootPath $PSScriptRoot\test | Invoke-Test |
43 | 56 |
|
44 | | -# Finished |
45 | | -Write-Message "Build finished" |
46 | | -Pop-Location |
| 57 | + |
| 58 | + # Finished |
| 59 | + Write-Message "Build finished" |
| 60 | +} |
| 61 | +finally { |
| 62 | + Pop-Location |
| 63 | +} |
0 commit comments