forked from micahlmartin/OAuth2Provider
-
Notifications
You must be signed in to change notification settings - Fork 0
/
default.ps1
143 lines (108 loc) · 3.99 KB
/
default.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
properties {
$TargetFramework = "net-4.0"
$DownloadDependentPackages = $true
$UploadPackage = $false
$NugetKey = ""
}
$baseDir = resolve-path .
$releaseRoot = "$baseDir\Release"
$releaseDir = "$releaseRoot\net40"
$buildBase = "$baseDir\build"
$sourceDir = "$baseDir\src"
$outDir = "$buildBase\output"
$toolsDir = "$baseDir\tools"
$binariesDir = "$baseDir\binaries"
$ilMergeTool = "$toolsDir\ILMerge\ILMerge.exe"
$nugetExec = "$toolsDir\NuGet\NuGet.exe"
$script:msBuild = ""
$script:isEnvironmentInitialized = $false
$script:ilmergeTargetFramework = ""
$script:msBuildTargetFramework = ""
$ilMergeKey = "$srcDir\NServiceBus.snk"
$script:packageVersion = "1.0.0"
$nunitexec = "packages\NUnit.Runners.lite.2.6.0.12051\nunit-console.exe"
$script:nunitTargetFramework = "/framework=4.0";
include $toolsDir\psake\buildutils.ps1
task default -depends ReleaseOAuth
task Clean {
delete-directory $binariesDir -ErrorAction silentlycontinue
}
task Init -depends Clean {
create-directory $binariesDir
}
task InstallDependentPackages {
cd "$baseDir\packages"
$files = dir -Exclude *.config
cd $baseDir
$installDependentPackages = $DownloadDependentPackages;
if($installDependentPackages -eq $false){
$installDependentPackages = ((($files -ne $null) -and ($files.count -gt 0)) -eq $false)
}
if($installDependentPackages){
dir -recurse -include ('packages.config') |ForEach-Object {
$packageconfig = [io.path]::Combine($_.directory,$_.name)
write-host $packageconfig
exec{ &$nugetExec install $packageconfig -o packages }
}
}
}
task InitEnvironment{
if($script:isEnvironmentInitialized -ne $true){
if ($TargetFramework -eq "net-4.0"){
$netfxInstallroot =""
$netfxInstallroot = Get-RegistryValue 'HKLM:\SOFTWARE\Microsoft\.NETFramework\' 'InstallRoot'
$netfxCurrent = $netfxInstallroot + "v4.0.30319"
$script:msBuild = $netfxCurrent + "\msbuild.exe"
echo ".Net 4.0 build requested - $script:msBuild"
$script:ilmergeTargetFramework = "v4," + $netfxCurrent
$script:msBuildTargetFramework ="/p:TargetFrameworkVersion=v4.0 /ToolsVersion:4.0"
$script:nunitTargetFramework = "/framework=4.0";
$script:isEnvironmentInitialized = $true
}
}
}
task CompileMain -depends InstallDependentPackages, InitEnvironment, Init {
$solutionFile = "$sourceDir\OAuth.sln"
exec { &$script:msBuild $solutionFile /p:OutDir="$buildBase\" }
Copy-Item "$buildBase\OAuth2Provider.dll" $binariesDir
}
task TestMain -depends CompileMain {
if((Test-Path -Path $buildBase\test-reports) -eq $false){
Create-Directory $buildBase\test-reports
}
$testAssemblies = @()
$testAssemblies += dir $buildBase\*Tests.dll
exec {&$nunitexec $testAssemblies $script:nunitTargetFramework}
}
task PrepareRelease -depends CompileMain, TestMain {
if((Test-Path $releaseRoot) -eq $true){
Delete-Directory $releaseRoot
}
Create-Directory $releaseRoot
if ($TargetFramework -eq "net-4.0"){
$releaseDir = "$releaseRoot\net40"
}
Create-Directory $releaseDir
Copy-Item -Force -Recurse "$baseDir\binaries" $releaseDir\binaries -ErrorAction SilentlyContinue
}
task CreatePackages -depends PrepareRelease {
if(($UploadPackage) -and ($NugetKey -eq "")){
throw "Could not find the NuGet access key Package Cannot be uploaded without access key"
}
import-module $toolsDir\NuGet\packit.psm1
Write-Output "Loading the module for packing.............."
$packit.push_to_nuget = $UploadPackage
$packit.nugetKey = $NugetKey
$packit.framework_Isolated_Binaries_Loc = "$baseDir\release"
$packit.PackagingArtifactsRoot = "$baseDir\release\PackagingArtifacts"
$packit.packageOutPutDir = "$baseDir\release\packages"
$packit.targeted_Frameworks = "net40";
#region Packing NServiceBus
$packageName = "OAuth2Provider"
$packit.package_description = "OAuth 2 Provider"
invoke-packit $packageName $script:packageVersion @{log4net="[2.0.0]"; "Newtonsoft.Json"="[4.5.5]"} "binaries\OAuth2Provider.dll" @{}
#endregion
remove-module packit
}
task ReleaseOAuth -depends CreatePackages {
}