-
Notifications
You must be signed in to change notification settings - Fork 3
/
gfile.ps1
56 lines (45 loc) · 1.67 KB
/
gfile.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
[cmdletbinding()]
param(
[Parameter(Position=0)]
[ValidateSet('Release','Debug')]
[string]$configuration = 'Release',
[Parameter(Position=1)]
[System.IO.DirectoryInfo]$outputRoot
)
function InternalGet-ScriptDirectory{
split-path (((Get-Variable MyInvocation -Scope 1).Value).MyCommand.Path)
}
$scriptDir = ((InternalGet-ScriptDirectory) + "\")
[System.IO.FileInfo]$slnPath = (Join-Path $scriptDir vsfolders.sln)
if($outputRoot -eq $null){
$outputRoot = (Join-Path $scriptDir 'OutputRoot')
}
#[System.IO.DirectoryInfo]$outputRoot = (
task default -dependsOn build
task init {
requires 'https://raw.githubusercontent.com/ligershark/psbuild/master/src/GetPSBuild.ps1' -condition (-not (Get-Command -Module psbuild -Name Invoke-MSBuild -ErrorAction SilentlyContinue) )
requires 'https://raw.githubusercontent.com/ligershark/nuget-powershell/master/get-nugetps.ps1' -condition (-not (Get-Command -Module nuget-powershell -Name Get-NuGetPackage -ErrorAction SilentlyContinue) )
# ensure output root exists
if(-not (Test-Path $outputRoot)){
'Creating outputroot folder at [{0}]' -f $outputRoot | Write-Verbose
New-Item -ItemType Directory -Path $outputRoot
}
}
task build {
Invoke-MSBuild -projectsToBuild $slnPath -configuration $configuration -outputPath $outputRoot
} -dependsOn restorepackages
task restorepackages{
Push-Location
try{
Set-Location ($slnPath.Directory.FullName)
&(Get-Nuget) restore
}
finally{
Pop-Location
}
}
task clean{
if($outputRoot -ne $null -and (-not ([string]::IsNullOrWhiteSpace( $outputRoot.FullName ))) ) {
Remove-Item -Path $outputRoot -Recurse
}
}