-
Notifications
You must be signed in to change notification settings - Fork 139
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #71 from neutmute/build
command line build scripts
- Loading branch information
Showing
3 changed files
with
135 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
powershell -f build.ps1 -configuration release | ||
powershell -f build.ps1 -configuration debug |
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,90 @@ | ||
$Script:UseWriteHost = $true | ||
|
||
if(!$Global:ColorScheme) { | ||
$Global:ColorScheme = @{ | ||
"Banner"=[ConsoleColor]::Cyan | ||
"RuntimeName"=[ConsoleColor]::Yellow | ||
"Help_Header"=[ConsoleColor]::Yellow | ||
"Help_Switch"=[ConsoleColor]::Green | ||
"Help_Argument"=[ConsoleColor]::Cyan | ||
"Help_Optional"=[ConsoleColor]::Gray | ||
"Help_Command"=[ConsoleColor]::DarkYellow | ||
"Help_Executable"=[ConsoleColor]::DarkYellow | ||
"ParameterName"=[ConsoleColor]::Cyan | ||
"Warning" = [ConsoleColor]::Yellow | ||
} | ||
} | ||
|
||
function _WriteOut { | ||
param( | ||
[Parameter(Mandatory=$false, Position=0, ValueFromPipeline=$true)][string]$msg, | ||
[Parameter(Mandatory=$false)][ConsoleColor]$ForegroundColor, | ||
[Parameter(Mandatory=$false)][ConsoleColor]$BackgroundColor, | ||
[Parameter(Mandatory=$false)][switch]$NoNewLine) | ||
|
||
if($__TestWriteTo) { | ||
$cur = Get-Variable -Name $__TestWriteTo -ValueOnly -Scope Global -ErrorAction SilentlyContinue | ||
$val = $cur + "$msg" | ||
if(!$NoNewLine) { | ||
$val += [Environment]::NewLine | ||
} | ||
Set-Variable -Name $__TestWriteTo -Value $val -Scope Global -Force | ||
return | ||
} | ||
|
||
if(!$Script:UseWriteHost) { | ||
if(!$msg) { | ||
$msg = "" | ||
} | ||
if($NoNewLine) { | ||
[Console]::Write($msg) | ||
} else { | ||
[Console]::WriteLine($msg) | ||
} | ||
} | ||
else { | ||
try { | ||
if(!$ForegroundColor) { | ||
$ForegroundColor = $host.UI.RawUI.ForegroundColor | ||
} | ||
if(!$BackgroundColor) { | ||
$BackgroundColor = $host.UI.RawUI.BackgroundColor | ||
} | ||
|
||
Write-Host $msg -ForegroundColor:$ForegroundColor -BackgroundColor:$BackgroundColor -NoNewLine:$NoNewLine | ||
} catch { | ||
$Script:UseWriteHost = $false | ||
_WriteOut $msg | ||
} | ||
} | ||
} | ||
|
||
function _WriteConfig{ | ||
param( | ||
[Parameter(Mandatory=$true,Position=0)]$name, | ||
[Parameter(Mandatory=$true,Position=1)]$value) | ||
|
||
_WriteOut -NoNewline -ForegroundColor $Global:ColorScheme.ParameterName "${name}: " | ||
_WriteOut "$value" | ||
|
||
} | ||
|
||
function _DownloadNuget{ | ||
param( | ||
[Parameter(Mandatory=$true,Position=0)]$rootPath) | ||
|
||
$sourceNugetExe = "http://nuget.org/nuget.exe" | ||
$targetNugetExe = "$rootPath\nuget.exe" | ||
|
||
|
||
if(!(Test-Path $targetNugetExe )){ | ||
_WriteOut "Downloading nuget to $targetNugetExe" | ||
Invoke-WebRequest $sourceNugetExe -OutFile $targetNugetExe | ||
} | ||
else{ | ||
# _WriteOut "nuget.exe is already present" | ||
} | ||
|
||
Set-Alias nuget $targetNugetExe -Scope Global | ||
|
||
} |
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,43 @@ | ||
param( | ||
[string]$configuration = "Release" | ||
) | ||
|
||
. ".\build.common.ps1" | ||
|
||
$solutionName = "RaspberrySharp.IO" | ||
|
||
function init { | ||
# Initialization | ||
$global:rootFolder = Split-Path -parent $script:MyInvocation.MyCommand.Path | ||
$global:rootFolder = Join-Path $rootFolder . | ||
$global:packagesFolder = Join-Path $rootFolder packages | ||
$global:outputFolder = Join-Path $rootFolder _artifacts | ||
$global:msbuild = "C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe" | ||
|
||
_WriteOut -ForegroundColor $ColorScheme.Banner "-= $solutionName Build =-" | ||
_WriteConfig "rootFolder" $rootFolder | ||
} | ||
|
||
function restorePackages{ | ||
_WriteOut -ForegroundColor $ColorScheme.Banner "nuget restore" | ||
|
||
New-Item -Force -ItemType directory -Path $packagesFolder | ||
_DownloadNuget $packagesFolder | ||
nuget restore | ||
} | ||
|
||
function buildSolution{ | ||
|
||
_WriteOut -ForegroundColor $ColorScheme.Banner "Build Solution" | ||
& $msbuild "$rootFolder\$solutionName.sln" /p:Configuration=$configuration | ||
|
||
} | ||
|
||
|
||
init | ||
|
||
restorePackages | ||
|
||
buildSolution | ||
|
||
Write-Host "Build $configuration complete" |