forked from IdentityServer/IdentityServer3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
default.ps1
88 lines (76 loc) · 3.17 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
properties {
$base_directory = Resolve-Path .
$src_directory = "$base_directory\source"
$output_directory = "$base_directory\build"
$dist_directory = "$base_directory\distribution"
$sln_file = "$src_directory\Thinktecture.IdentityServer.v3.sln"
$target_config = "Release"
$framework_version = "v4.5"
$xunit_path = "$src_directory\packages\xunit.runners.1.9.2\tools\xunit.console.clr4.exe"
$ilmerge_path = "$src_directory\packages\ILMerge.2.13.0307\ILMerge.exe"
$nuget_path = "$src_directory\.nuget\nuget.exe"
$buildNumber = 0;
$version = "1.0.0.0"
$preRelease = $null
}
task default -depends Clean, RunTests, CreateNuGetPackage
task Clean {
rmdir $output_directory -ea SilentlyContinue -recurse
rmdir $dist_directory -ea SilentlyContinue -recurse
exec { msbuild /nologo /verbosity:quiet $sln_file /p:Configuration=$target_config /t:Clean }
}
task Compile -depends UpdateVersion {
exec { msbuild /nologo /verbosity:q $sln_file /p:Configuration=$target_config /p:TargetFrameworkVersion=v4.5 }
}
task UpdateVersion {
$vSplit = $version.Split('.')
if($vSplit.Length -ne 4)
{
throw "Version number is invalid. Must be in the form of 0.0.0.0"
}
$major = $vSplit[0]
$minor = $vSplit[1]
$patch = $vSplit[2]
$assemblyFileVersion = "$major.$minor.$patch.$buildNumber"
$assemblyVersion = "$major.$minor.0.0"
$versionAssemblyInfoFile = "$src_directory/VersionAssemblyInfo.cs"
"using System.Reflection;" > $versionAssemblyInfoFile
"" >> $versionAssemblyInfoFile
"[assembly: AssemblyVersion(""$assemblyVersion"")]" >> $versionAssemblyInfoFile
"[assembly: AssemblyFileVersion(""$assemblyFileVersion"")]" >> $versionAssemblyInfoFile
}
task RunTests -depends Compile {
$project = "Thinktecture.IdentityServer.Core.Tests"
mkdir $output_directory\xunit\$project -ea SilentlyContinue
.$xunit_path "$src_directory\Tests\UnitTests\bin\Release\$project.dll" /html "$output_directory\xunit\$project\index.html"
}
task ILMerge -depends Compile {
$input_dlls = "$output_directory\Thinktecture.IdentityServer.Core.dll"
Get-ChildItem -Path $output_directory -Filter *.dll |
foreach-object {
# Exclude Thinktecture.IdentityServer.Core.dll as that will be the primary assembly
if ("$_" -ne "Thinktecture.IdentityServer.Core.dll" -and
"$_" -ne "Owin.dll") {
$input_dlls = "$input_dlls $output_directory\$_"
}
}
New-Item $dist_directory\lib\net45 -Type Directory
Invoke-Expression "$ilmerge_path /targetplatform:v4 /internalize /allowDup /target:library /out:$dist_directory\lib\net45\Thinktecture.IdentityServer.dll $input_dlls"
}
task CreateNuGetPackage -depends ILMerge {
$vSplit = $version.Split('.')
if($vSplit.Length -ne 4)
{
throw "Version number is invalid. Must be in the form of 0.0.0.0"
}
$major = $vSplit[0]
$minor = $vSplit[1]
$patch = $vSplit[2]
$packageVersion = "$major.$minor.$patch"
if($preRelease){
$packageVersion = "$packageVersion-$preRelease"
}
copy-item $src_directory\Thinktecture.IdentityServer.v3.nuspec $dist_directory
copy-item $output_directory\Thinktecture.IdentityServer.xml $dist_directory\lib\net45\
exec { . $nuget_path pack $dist_directory\Thinktecture.IdentityServer.v3.nuspec -BasePath $dist_directory -o $dist_directory -version $packageVersion }
}