Permalink
Browse files

Adding build.ps1

  • Loading branch information...
1 parent 712bc83 commit bb3d94e9bff2d130993b9be7407d2116a1e7f51f @emgarten emgarten committed May 20, 2016
Showing with 86 additions and 1 deletion.
  1. +2 −1 .gitignore
  2. +4 −0 .nuget/packages.config
  3. +80 −0 build.ps1
View
@@ -8,9 +8,10 @@
# Build results
-# Project K
project.lock.json
artifacts/
+.nuget/nuget.exe
+cli/
# VSCode
**/.vs/
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<packages>
+ <package id="xunit.runner.console" version="2.1.0" targetFramework="net45" />
+</packages>
View
@@ -0,0 +1,80 @@
+param (
+ [ValidateSet("debug", "release")]
+ [string]$Configuration = 'release'
+ )
+
+$RepoRoot = $PSScriptRoot
+
+$ArtifactsDir = Join-Path $RepoRoot 'artifacts'
+$CLIRoot = Join-Path $RepoRoot 'cli'
+$DotNetExe = Join-Path $CLIRoot 'dotnet.exe'
+$NuGetExe = Join-Path $RepoRoot '.nuget\nuget.exe'
+
+New-Item -ItemType Directory -Force -Path $CLIRoot | Out-Null
+New-Item -ItemType Directory -Force -Path $ArtifactsDir | Out-Null
+
+if (-not (Test-Path $NuGetExe))
+{
+ wget https://dist.nuget.org/win-x86-commandline/latest/nuget.exe -OutFile $NuGetExe
+}
+
+& $NuGetExe restore (Join-Path $RepoRoot '.nuget\packages.config') -SolutionDirectory $RepoRoot
+
+# install dotnet CLI
+$env:DOTNET_HOME=$CLIRoot
+
+$installDotnet = Join-Path $CLIRoot "install.ps1"
+$env:DOTNET_INSTALL_DIR=$NuGetClientRoot
+
+New-Item -ItemType Directory -Force -Path $CLIRoot
+
+wget https://raw.githubusercontent.com/dotnet/cli/rel/1.0.0/scripts/obtain/install.ps1 -OutFile cli/install.ps1
+
+& cli/install.ps1 -Channel beta -i $CLIRoot -Version 1.0.0-preview1-002702
+
+if (-not (Test-Path $DotNetExe)) {
+ Write-Host "Unable to find dotnet.exe. The CLI install may have failed."
+ Exit 1
+}
+
+# Display build info
+& $DotNetExe --info
+
+
+# download nuget packages
+& $DotNetExe restore $RepoRoot
+
+# Run tests
+$TestDir = Join-Path $RepoRoot test\JsonLDTests
+pushd $TestDir
+
+# core clr
+
+& $DotNetExe test --configuration $Configuration -f netcoreapp1.0
+
+if (-not $?) {
+ Error-Log "Tests failed!!!"
+ Exit 1
+}
+
+# net46
+& $DotNetExe build --configuration $Configuration -f net46 --runtime win7-x64
+
+$xunit = Join-Path $RepoRoot packages\xunit.runner.console.2.1.0\tools\xunit.console.x86.exe
+
+& $xunit bin\release\net46\win7-x64\JsonLDTests.dll -html (Join-Path $ArtifactsDir "testresults.html")
+
+if (-not $?) {
+ Error-Log "Tests failed!!!"
+ Exit 1
+}
+
+popd
+
+# Pack
+
+Write-Host "Creating nupkg"
+
+& $DotNetExe pack (Join-Path $RepoRoot src\JsonLD) --configuration $Configuration --output $ArtifactsDir
+
+Write-Host "Success!"

0 comments on commit bb3d94e

Please sign in to comment.