Skip to content

Commit

Permalink
Add build scripts.
Browse files Browse the repository at this point in the history
  • Loading branch information
MatthewKing committed Jul 4, 2018
1 parent fc393d9 commit f174b0b
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 24 deletions.
29 changes: 5 additions & 24 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,25 +1,6 @@
# build folders
[Bb]in/
[Oo]bj/

# build results
[Dd]ebug/
[Rr]elease/

# user-specific files
.vs/
*.suo
*.user
*.sln.docstates

# ncrunch
*.crunchsolution*
*.ncrunchsolution*
*.ncrunchproject*

# nuget
packages/

# other
*.[Cc]ache
project.lock.json
.vscode/
bin/
obj/
build/tools/
artifacts/
2 changes: 2 additions & 0 deletions build/build.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@echo off
powershell.exe -NoProfile -ExecutionPolicy Bypass -File "%~dp0\build.ps1"
44 changes: 44 additions & 0 deletions build/build.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Get the root project directory.
$root = Resolve-Path (Join-Path $PSScriptRoot '..')

# Set up the tools directory.
$toolsDir = "$root\build\tools"
if ((Test-Path -path $toolsDir) -eq $false) {
New-Item $toolsDir -Type Directory | Out-Null
}

# Set up the output directory.
$outputDir = "$root\artifacts"
if ((Test-Path -path $outputDir) -eq $false) {
New-Item $outputDir -Type Directory | Out-Null
}

# Find or download NuGet.
$nuget = "$toolsDir\nuget.exe"
if ((Test-Path $nuget) -eq $false) {
Invoke-WebRequest -Uri https://dist.nuget.org/win-x86-commandline/latest/nuget.exe -OutFile $nuget
}

# Find or download VSWhere.
$vswhere = "$toolsDir\vswhere\tools\vswhere.exe"
if ((Test-Path $vswhere) -eq $false) {
& $nuget install vswhere -ExcludeVersion -OutputDirectory $toolsDir
}

# Find VS using VSWhere
$vs = & $vswhere -latest -products * -requires Microsoft.Component.MSBuild -property installationPath
if ((Test-Path $vs) -eq $false) {
throw 'Could not find VS installation'
}

# Locate MSBuild using resolved VS path.
$msbuild = Resolve-Path "$vs\MSBuild\*\Bin\MSBuild.exe"
if ((Test-Path $msbuild) -eq $false) {
throw 'Could not find MSBuild'
}

# Set MSBuild alias.
Set-Alias MSBuild $msbuild

# Build and pack.
MSBuild "/t:Restore;Build;Pack" "/p:Configuration=Release,OutputPath=$outputDir" "$root\src\NGuard\NGuard.csproj"

0 comments on commit f174b0b

Please sign in to comment.