-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
31 additions
and
105 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,109 +1,15 @@ | ||
$root = $(Get-Item $($MyInvocation.MyCommand.Path)).DirectoryName | ||
|
||
function Install-Dnvm | ||
{ | ||
& where.exe dnvm 2>&1 | Out-Null | ||
if(($LASTEXITCODE -ne 0) -Or ((Test-Path Env:\APPVEYOR) -eq $true)) | ||
{ | ||
Write-Host "DNVM not found" | ||
&{$Branch='dev';iex ((New-Object net.webclient).DownloadString('https://raw.githubusercontent.com/aspnet/Home/dev/dnvminstall.ps1'))} | ||
|
||
# Normally this happens automatically during install but AppVeyor has | ||
# an issue where you may need to manually re-run setup from within this process. | ||
if($env:DNX_HOME -eq $NULL) | ||
{ | ||
Write-Host "Initial DNVM environment setup failed; running manual setup" | ||
$tempDnvmPath = Join-Path $env:TEMP "dnvminstall" | ||
$dnvmSetupCmdPath = Join-Path $tempDnvmPath "dnvm.ps1" | ||
& $dnvmSetupCmdPath setup | ||
} | ||
} | ||
} | ||
|
||
function Get-DnxVersion | ||
{ | ||
$globalJson = Join-Path $PSScriptRoot "global.json" | ||
$jsonData = Get-Content -Path $globalJson -Raw | ConvertFrom-JSON | ||
return $jsonData.sdk.version | ||
} | ||
|
||
function Restore-Packages | ||
{ | ||
param([string] $DirectoryName) | ||
& dnu restore ("""" + $DirectoryName + """") | ||
} | ||
|
||
function Build-Projects | ||
{ | ||
param($Directory, $pack) | ||
|
||
$DirectoryName = $Directory.DirectoryName | ||
$artifactsFolder = join-path $root "artifacts" | ||
$projectsFolder = join-path $artifactsFolder $Directory.Name | ||
$buildFolder = join-path $projectsFolder "testbin" | ||
$packageFolder = join-path $projectsFolder "packages" | ||
|
||
& dnu build ("""" + $DirectoryName + """") --configuration Release --out $buildFolder; if($LASTEXITCODE -ne 0) { exit 1 } | ||
|
||
if($pack){ | ||
& dnu pack ("""" + $DirectoryName + """") --configuration Release --out $packageFolder; if($LASTEXITCODE -ne 0) { exit 1 } | ||
} | ||
} | ||
|
||
function Test-Projects | ||
{ | ||
param([string] $DirectoryName) | ||
& dnx -p ("""" + $DirectoryName + """") test; if($LASTEXITCODE -ne 0) { exit 2 } | ||
} | ||
|
||
function Remove-PathVariable | ||
{ | ||
param([string] $VariableToRemove) | ||
$path = [Environment]::GetEnvironmentVariable("PATH", "User") | ||
$newItems = $path.Split(';') | Where-Object { $_.ToString() -inotlike $VariableToRemove } | ||
[Environment]::SetEnvironmentVariable("PATH", [System.String]::Join(';', $newItems), "User") | ||
$path = [Environment]::GetEnvironmentVariable("PATH", "Process") | ||
$newItems = $path.Split(';') | Where-Object { $_.ToString() -inotlike $VariableToRemove } | ||
[Environment]::SetEnvironmentVariable("PATH", [System.String]::Join(';', $newItems), "Process") | ||
} | ||
|
||
Push-Location $PSScriptRoot | ||
|
||
$dnxVersion = Get-DnxVersion | ||
|
||
# Clean | ||
if(Test-Path .\artifacts) { Remove-Item .\artifacts -Force -Recurse } | ||
|
||
# Remove the installed DNVM from the path and force use of | ||
# per-user DNVM (which we can upgrade as needed without admin permissions) | ||
Remove-PathVariable "*Program Files\Microsoft DNX\DNVM*" | ||
|
||
# Make sure per-user DNVM is installed | ||
Install-Dnvm | ||
|
||
# Install DNX | ||
dnvm install $dnxVersion -r CoreCLR -NoNative | ||
dnvm install $dnxVersion -r CLR -NoNative | ||
dnvm use $dnxVersion -r CLR | ||
|
||
# Package restore | ||
Get-ChildItem -Path . -Filter *.xproj -Recurse | ForEach-Object { Restore-Packages $_.DirectoryName } | ||
|
||
# Set build number | ||
$env:DNX_BUILD_VERSION = @{ $true = $env:APPVEYOR_BUILD_NUMBER; $false = 1 }[$env:APPVEYOR_BUILD_NUMBER -ne $NULL]; | ||
Write-Host "Build number: " $env:DNX_BUILD_VERSION | ||
|
||
# Build/package | ||
Get-ChildItem -Path .\src -Filter *.xproj -Recurse | ForEach-Object { Build-Projects $_ $true } | ||
Get-ChildItem -Path .\test -Filter *.xproj -Recurse | ForEach-Object { Build-Projects $_ $false } | ||
& dotnet restore | ||
|
||
# Test | ||
Get-ChildItem -Path .\test -Filter *.xproj -Recurse | ForEach-Object { Test-Projects $_.DirectoryName } | ||
$revision = @{ $true = $env:APPVEYOR_BUILD_NUMBER; $false = 1 }[$env:APPVEYOR_BUILD_NUMBER -ne $NULL]; | ||
|
||
# Switch to Core CLR | ||
dnvm use $dnxVersion -r CoreCLR | ||
Push-Location src/Serilog.Sinks.Trace | ||
|
||
# Test again | ||
Get-ChildItem -Path .\test -Filter *.xproj -Recurse | ForEach-Object { Test-Projects $_.DirectoryName } | ||
& dotnet pack -c Release -o ..\..\.\artifacts --version-suffix=$revision | ||
if($LASTEXITCODE -ne 0) { exit 1 } | ||
|
||
Pop-Location | ||
Pop-Location |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
version: '{build}' | ||
image: Visual Studio 2015 | ||
configuration: Release | ||
install: | ||
- ps: mkdir -Force ".\build\" | Out-Null | ||
- ps: Invoke-WebRequest "https://raw.githubusercontent.com/dotnet/cli/rel/1.0.0/scripts/obtain/install.ps1" -OutFile ".\build\installcli.ps1" | ||
- ps: $env:DOTNET_INSTALL_DIR = "$pwd\.dotnetcli" | ||
- ps: '& .\build\installcli.ps1 -InstallDir "$env:DOTNET_INSTALL_DIR" -NoPath' | ||
- ps: $env:Path = "$env:DOTNET_INSTALL_DIR;$env:Path" | ||
build_script: | ||
- ps: ./Build.ps1 | ||
test: off | ||
artifacts: | ||
- path: artifacts/Serilog.*.nupkg | ||
deploy: | ||
- provider: NuGet | ||
api_key: | ||
secure: nvZ/z+pMS91b3kG4DgfES5AcmwwGoBYQxr9kp4XiJHj25SAlgdIxFx++1N0lFH2x | ||
skip_symbols: true | ||
on: | ||
branch: /^(dev|master)$/ |
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