|
1 | | -function Install-Dnvm |
2 | | -{ |
3 | | - & where.exe dnvm 2>&1 | Out-Null |
4 | | - if(($LASTEXITCODE -ne 0) -Or ((Test-Path Env:\APPVEYOR) -eq $true)) |
5 | | - { |
6 | | - Write-Host "DNVM not found" |
7 | | - &{$Branch='dev';iex ((New-Object net.webclient).DownloadString('https://raw.githubusercontent.com/aspnet/Home/dev/dnvminstall.ps1'))} |
8 | | - |
9 | | - # Normally this happens automatically during install but AppVeyor has |
10 | | - # an issue where you may need to manually re-run setup from within this process. |
11 | | - if($env:DNX_HOME -eq $NULL) |
12 | | - { |
13 | | - Write-Host "Initial DNVM environment setup failed; running manual setup" |
14 | | - $tempDnvmPath = Join-Path $env:TEMP "dnvminstall" |
15 | | - $dnvmSetupCmdPath = Join-Path $tempDnvmPath "dnvm.ps1" |
16 | | - & $dnvmSetupCmdPath setup |
17 | | - } |
18 | | - } |
19 | | -} |
20 | | - |
21 | | -function Get-DnxVersion |
22 | | -{ |
23 | | - $globalJson = Join-Path $PSScriptRoot "global.json" |
24 | | - $jsonData = Get-Content -Path $globalJson -Raw | ConvertFrom-JSON |
25 | | - return $jsonData.sdk.version |
26 | | -} |
27 | | - |
28 | | -function Restore-Packages |
29 | | -{ |
30 | | - param([string] $DirectoryName) |
31 | | - & dnu restore ("""" + $DirectoryName + """") |
32 | | -} |
33 | | - |
34 | | -function Build-Projects |
35 | | -{ |
36 | | - param([string] $DirectoryName) |
37 | | - & dnu build ("""" + $DirectoryName + """") --configuration Release --out .\artifacts\testbin; if($LASTEXITCODE -ne 0) { exit 1 } |
38 | | - & dnu pack ("""" + $DirectoryName + """") --configuration Release --out .\artifacts\packages; if($LASTEXITCODE -ne 0) { exit 1 } |
39 | | -} |
40 | | - |
41 | | -function Build-TestProjects |
42 | | -{ |
43 | | - param([string] $DirectoryName) |
44 | | - & dnu build ("""" + $DirectoryName + """") --configuration Release --out .\artifacts\testbin; if($LASTEXITCODE -ne 0) { exit 1 } |
45 | | -} |
46 | | - |
47 | | -function Test-Projects |
48 | | -{ |
49 | | - param([string] $DirectoryName) |
50 | | - & dnx -p ("""" + $DirectoryName + """") test; if($LASTEXITCODE -ne 0) { exit 2 } |
51 | | -} |
52 | | - |
53 | | -function Remove-PathVariable |
54 | | -{ |
55 | | - param([string] $VariableToRemove) |
56 | | - $path = [Environment]::GetEnvironmentVariable("PATH", "User") |
57 | | - $newItems = $path.Split(';') | Where-Object { $_.ToString() -inotlike $VariableToRemove } |
58 | | - [Environment]::SetEnvironmentVariable("PATH", [System.String]::Join(';', $newItems), "User") |
59 | | - $path = [Environment]::GetEnvironmentVariable("PATH", "Process") |
60 | | - $newItems = $path.Split(';') | Where-Object { $_.ToString() -inotlike $VariableToRemove } |
61 | | - [Environment]::SetEnvironmentVariable("PATH", [System.String]::Join(';', $newItems), "Process") |
62 | | -} |
63 | | - |
64 | 1 | Push-Location $PSScriptRoot |
65 | 2 |
|
66 | | -$dnxVersion = Get-DnxVersion |
67 | | - |
68 | | -# Clean |
69 | 3 | if(Test-Path .\artifacts) { Remove-Item .\artifacts -Force -Recurse } |
70 | 4 |
|
71 | | -# Remove the installed DNVM from the path and force use of |
72 | | -# per-user DNVM (which we can upgrade as needed without admin permissions) |
73 | | -Remove-PathVariable "*Program Files\Microsoft DNX\DNVM*" |
74 | | - |
75 | | -# Make sure per-user DNVM is installed |
76 | | -Install-Dnvm |
77 | | - |
78 | | -# Install DNX |
79 | | -dnvm install $dnxVersion -r CoreCLR -NoNative |
80 | | -dnvm install $dnxVersion -r CLR -NoNative |
81 | | -dnvm use $dnxVersion -r CLR |
| 5 | +& dotnet restore |
82 | 6 |
|
83 | | -# Package restore |
84 | | -Get-ChildItem -Path . -Filter *.xproj -Recurse | ForEach-Object { Restore-Packages $_.DirectoryName } |
| 7 | +$revision = @{ $true = $env:APPVEYOR_BUILD_NUMBER; $false = 1 }[$env:APPVEYOR_BUILD_NUMBER -ne $NULL]; |
85 | 8 |
|
86 | | -# Set build number |
87 | | -$env:DNX_BUILD_VERSION = @{ $true = $env:APPVEYOR_BUILD_NUMBER; $false = 1 }[$env:APPVEYOR_BUILD_NUMBER -ne $NULL]; |
88 | | -Write-Host "Build number: " $env:DNX_BUILD_VERSION |
| 9 | +Push-Location src/Serilog.Settings.Configuration |
89 | 10 |
|
90 | | -# Build/package |
91 | | -Get-ChildItem -Path .\src -Filter *.xproj -Recurse | ForEach-Object { Build-Projects $_.DirectoryName } |
92 | | -Get-ChildItem -Path .\test -Filter *.xproj -Recurse | ForEach-Object { Build-TestProjects $_.DirectoryName } |
| 11 | +& dotnet pack -c Release -o ..\..\.\artifacts --version-suffix=$revision |
| 12 | +if($LASTEXITCODE -ne 0) { exit 1 } |
93 | 13 |
|
94 | | -# Test |
95 | | -Get-ChildItem -Path .\test -Filter *.xproj -Recurse | ForEach-Object { Test-Projects $_.DirectoryName } |
96 | | - |
97 | | -# Switch to Core CLR |
98 | | -dnvm use $dnxVersion -r CoreCLR |
| 14 | +Pop-Location |
| 15 | +Push-Location test/Serilog.Settings.Configuration.Tests |
99 | 16 |
|
100 | | -# Test again |
101 | | -Get-ChildItem -Path .\test -Filter *.xproj -Recurse | ForEach-Object { Test-Projects $_.DirectoryName } |
| 17 | +& dotnet test -c Release |
| 18 | +if($LASTEXITCODE -ne 0) { exit 2 } |
102 | 19 |
|
103 | 20 | Pop-Location |
| 21 | +Pop-Location |
0 commit comments