forked from CoreTweet/CoreTweet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.ps1
114 lines (100 loc) · 2.53 KB
/
build.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
<#
.SYNOPSIS
Build CoreTweet
.EXAMPLE
build -All
build -Binary
#>
param (
[switch]$All,
[switch]$Binary,
[switch]$Docs,
[switch]$Package,
[switch]$Clean,
[switch]$ExecuteTemplate,
[switch]$Help
)
if($Help)
{
echo "Usage: build.ps1 -All | -Binary | -Docs | -Package | -Clean | -ExecuteTemplate"
echo ""
echo "Targets:"
echo " All ... Build binaries, docs, and packages"
echo " Binary ... Build binaries only"
echo " Docs ... Build documents only"
echo " Packages ... Build nupkgs only"
echo " Clean ... Clean generated files"
echo " ExecuteTemplete ... Generate RestApis.cs"
exit
}
if(!($Binary -or $Docs -or $Package -or $Clean -or $ExecuteTemplate))
{
$All = $true
}
$solution = ".\CoreTweet-All.sln"
mkdir .\Release -Force > $null
$nuget = ".\ExternalDependencies\bin\nuget.exe"
$nuget_url = "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe"
function Download-NuGet
{
if(!(Test-Path $nuget))
{
echo "Downloading NuGet..."
mkdir -Force .\ExternalDependencies\bin > $null
Invoke-WebRequest $nuget_url -OutFile $nuget
}
}
if([Environment]::Is64BitOperatingSystem)
{
$msbuild = "C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe"
}
else
{
$msbuild = "C:\Program Files\MSBuild\14.0\Bin\MSBuild.exe"
}
if($Clean)
{
& $msbuild $solution /m /target:Clean
rm -Recurse -Force .\Release
rm CoreTweet.Shared\RestApis.cs
}
if($All -or $ExecuteTemplate -or $Binary)
{
& $msbuild RestApisGen\RestApisGen.csproj /p:Configuration=Debug
RestApisGen\bin\RestApisGen.exe
}
if($All -or $Binary)
{
Download-NuGet
& $nuget restore $solution
& $msbuild $solution /m /p:Configuration=Release
}
if($All -or $Docs)
{
try
{
Get-Command doxygen -ErrorAction Stop > $null
$existsDoxygen = $true
}
catch [System.Management.Automation.CommandNotFoundException]
{
echo "Doxygen is not installed"
$existsDoxygen = $false
}
if($existsDoxygen) { doxygen }
}
if($All -or $Package)
{
$version = $env:APPVEYOR_BUILD_VERSION
if($version -eq $null)
{
$version = (Get-Item .\Release\net40\CoreTweet.dll).VersionInfo.ProductVersion
}
Download-NuGet
& $nuget pack CoreTweet.nuspec -Version $version -OutputDirectory .\Release
if($env:APPVEYOR_REPO_BRANCH -eq "master")
{
Get-ChildItem .\Release\*.nupkg |
foreach { Push-AppveyorArtifact $_.FullName -FileName $_.Name }
}
}