forked from reactiveui/ReactiveUI
-
Notifications
You must be signed in to change notification settings - Fork 0
/
MakeRelease.ps1
154 lines (120 loc) · 4.07 KB
/
MakeRelease.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
143
144
145
146
147
148
149
150
151
152
153
154
Param([string]$version = $null)
$Archs = {
"Mono",
"Monoandroid",
"Monomac",
"Monotouch",
"Net45",
"Portable-Net45+Win8+WP8+WPA81",
"Portable-Net45+WinRT45+WP8+MonoAndroid10+MonoTouch10",
"Portable-Win81+Wpa81",
"uap10.0",
"WPA81",
"WP8",
"WP81"
"Xamarin.iOS10",
"Xamarin.Mac10"
}
$Projects = {
"ReactiveUI",
"ReactiveUI.AndroidSupport",
"ReactiveUI.Blend",
"ReactiveUI.Events",
"ReactiveUI.Testing",
"ReactiveUI.Winforms",
"ReactiveUI.XamForms",
"RxUIViewModelGenerator"
}
$MSBuildLocation = "C:\Program Files (x86)\MSBuild\14.0\bin"
$SlnFileExists = Test-Path ".\ReactiveUI_VSAll.sln"
if ($SlnFileExists -eq $False) {
echo "*** ERROR: Run this in the project root ***"
exit -1
}
$url = "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe"
$nugetExe = "$(pwd)\nuget.exe"
$nugetExists = Test-Path $nugetExe
if($nugetExists -eq $False) {
"NuGet: Downloading latest from [$url]`nSaving at [$nugetExe]"
$client = new-object System.Net.WebClient
$client.DownloadFile($url, $nugetExe)
}
& $nugetExe restore .\ReactiveUI.sln
& "$MSBuildLocation\MSBuild.exe" /v:m /t:Rebuild /p:Configuration=Release /p:Platform="Any CPU" /maxcpucount:1 .\ReactiveUI.sln
###
### Build the Release directory
###
if (Test-Path .\Release) {
rmdir -r -force .\Release
}
foreach-object $Archs | %{mkdir -Path ".\Release\$_" | out-null}
foreach-object $Archs | %{
$currentArch = $_
foreach-object $Projects | %{cp -r -fo ".\$_\bin\Release\$currentArch\*" ".\Release\$currentArch"}
#ls -r | ?{$_.FullName.Contains("bin\Release\$currentArch") -and $_.Length} | %{echo cp $_.FullName ".\Release\$currentArch"}
}
get-childitem -r .\Release | ?{$_.FullName.Contains("Clousot")} | %{rm $_.FullName}
###
### Build NuGet Packages
###
if (Test-Path .\NuGet-Release) {
rm -r -fo .\NuGet-Release
}
# Update Nuspecs if we have a version
if($version) {
$nuspecs = ls -r .\NuGet\*.nuspec
foreach($nuspec in $nuspecs) {
$xml = New-Object XML
$xml.Load($nuspec)
# specify NS
$nsMgr = New-Object System.Xml.XmlNamespaceManager($xml.NameTable)
$nsMgr.AddNamespace("ns", "http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd")
# PowerShell makes editing XML docs so easy!
$xml.package.metadata.version = "$version"
# get the rxui dependencies and update them
$deps = $xml.SelectNodes("//ns:dependency[contains(@id, 'reactiveui')]", $nsMgr)
foreach($dep in $deps) {
$dep.version = "[" + $version + "]"
}
$xml.Save($nuspec)
}
}
cp -r .\NuGet .\NuGet-Release
$libDirs = get-childitem -r .\NuGet-Release | ?{$_.Name -eq "lib"}
$srcDirs = get-childitem -r .\NuGet-Release | ?{$_.Name -eq "src"} | %{get-childitem $_.FullName}
$toolsDirs = get-childitem -r .\NuGet-Release | ?{$_.Name -eq "tools"}
$nugetReleaseDir = Resolve-Path ".\NuGet-Release"
# copy binaries
foreach ($dir in $libDirs) {
# only copy binaries which have a matching file in the destination folder
robocopy ".\Release" $dir.FullName /S /XL
}
# copy tools
foreach ($dir in $toolsDirs) {
echo "foo"
echo $dir.FullName
$files = get-childitem $dir.FullName
foreach ($file in $files) {
echo "bar"
echo $file.FullName
$src = ".\Release\Net45\" + $file.Name
cp -fo "$src" $file.FullName
}
}
# copy source
foreach ($dir in $srcDirs) {
$projName = $dir.Name
$projFolderName = $projName.Replace("-", ".")
robocopy ".\$projFolderName\" "$($dir.FullName)" *.cs /S
}
$stubs = get-childitem -r -file .\NuGet-Release | ?{$_.Length -eq 0} | ?{!$_.FullName.Contains("src")}
if ($stubs) {
echo "*** BUILD FAILED ***"
echo ""
echo "*** There are still stubs in the NuGet output, did you fully build? ***"
echo $stubs
#exit 1
}
mkdir -path artifacts -ea silentlycontinue | out-null
$specFiles = get-childitem -r .\NuGet-Release | ?{$_.Name.EndsWith(".nuspec")}
$specFiles | %{& $nugetExe pack -symbols $_.FullName -OutputDirectory artifacts}