This repository has been archived by the owner on Aug 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathBuild.ps1
134 lines (114 loc) · 7.11 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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
param
(
[Parameter()]
[string] $Configuration = "Release",
[Parameter()]
[string] $BuildNumber = "+",
[Parameter()]
[string] $VersionSuffix = ""
)
$ErrorActionPreference = "Stop"
$watch = [System.Diagnostics.Stopwatch]::StartNew()
$scriptPath = $PSScriptRoot
$productName = "Speedy"
# $scriptPath = "C:\Workspaces\GitHub\$productName"
# $BuildNumber = 1
# $VersionSuffix = "RC7"
# $Version = "12.1.0"
# $nugetVersion = "12.1.0"
if ($scriptPath.Length -le 0)
{
$scriptPath = "C:\Workspaces\GitHub\$productName"
}
$destination = "$scriptPath\Binaries"
$destination2 = "C:\Workspaces\Nuget\Development"
Push-Location $scriptPath
if (Test-Path $destination -PathType Container)
{
Remove-Item $destination -Recurse -Force
}
New-Item $destination -ItemType Directory | Out-Null
if (!(Test-Path $destination2 -PathType Container))
{
New-Item $destination2 -ItemType Directory | Out-Null
}
try
{
# Prepare the build for versioning!
# $newVersion = .\IncrementVersion.ps1 -Build +
$newVersion = .\IncrementVersion.ps1 -Major 12 -Minor 1 -Build $BuildNumber -Revision 0
$nugetVersion = ([Version] $newVersion).ToString(3)
if ($VersionSuffix.Length -gt 0)
{
$nugetVersion = "$nugetVersion-$VersionSuffix"
}
$projectFiles = "$scriptPath\Speedy\Speedy.csproj",
"$scriptPath\Speedy.Automation\Speedy.Automation.csproj",
"$scriptPath\Speedy.Application\Speedy.Application.csproj",
"$scriptPath\Speedy.Application.Maui\Speedy.Application.Maui.csproj",
"$scriptPath\Speedy.Application.Web\Speedy.Application.Web.csproj",
"$scriptPath\Speedy.Application.WPF\Speedy.Application.WPF.csproj",
"$scriptPath\Speedy.Application.Xamarin\Speedy.Application.Xamarin.csproj",
"$scriptPath\Speedy.EntityFramework\Speedy.EntityFramework.csproj",
"$scriptPath\Speedy.ServiceHosting\Speedy.ServiceHosting.csproj"
# Set the nuget version
foreach ($filePath in $projectFiles)
{
$fileXml = [xml](Get-Content -Path $filePath)
$fileXml.Project.PropertyGroup.Version = $nugetVersion
Set-Content -Path $filePath -Value (Format-Xml $fileXml.OuterXml) -Encoding UTF8
}
& nuget.exe restore "$scriptPath\$productName.sln"
# /v:m You can specify the following verbosity levels: q[uiet], m[inimal], n[ormal] (default), d[etailed], and diag[nostic].
$msbuild = "C:\Program Files\Microsoft Visual Studio\2022\Professional\Msbuild\Current\Bin\MSBuild.exe"
& $msbuild "$scriptPath\$productName.sln" /p:Configuration="$Configuration" /t:Rebuild /v:m /m
if ($LASTEXITCODE -ne 0)
{
Write-Host "Build has failed! " $LASTEXITCODE $watch.Elapsed -ForegroundColor Red
exit $LASTEXITCODE
}
& "NuGet.exe" pack "$scriptPath\Speedy.Application.Uwp\Speedy.Application.Uwp.nuspec" -Prop Configuration="$Configuration" -Version $nugetVersion -OutputDirectory "$scriptPath\Speedy.Application.Uwp\bin\$Configuration\"
Copy-Item "$productName\bin\$Configuration\$productName.$nugetVersion.nupkg" "$destination\"
Copy-Item "$productName.Automation\bin\$Configuration\$productName.Automation.$nugetVersion.nupkg" "$destination\"
Copy-Item "$productName.Application\bin\$Configuration\$productName.Application.$nugetVersion.nupkg" "$destination\"
Copy-Item "$productName.Application.Maui\bin\$Configuration\$productName.Application.Maui.$nugetVersion.nupkg" "$destination\"
Copy-Item "$productName.Application.Uwp\bin\$Configuration\$productName.Application.Uwp.$nugetVersion.nupkg" "$destination\"
Copy-Item "$productName.Application.Web\bin\$Configuration\$productName.Application.Web.$nugetVersion.nupkg" "$destination\"
Copy-Item "$productName.Application.WPF\bin\$Configuration\$productName.Application.WPF.$nugetVersion.nupkg" "$destination\"
Copy-Item "$productName.Application.Xamarin\bin\$Configuration\$productName.Application.Xamarin.$nugetVersion.nupkg" "$destination\"
Copy-Item "$productName.EntityFramework\bin\$Configuration\$productName.EntityFramework.$nugetVersion.nupkg" "$destination\"
Copy-Item "$productName.ServiceHosting\bin\$Configuration\$productName.ServiceHosting.$nugetVersion.nupkg" "$destination\"
Copy-Item "$productName\bin\$Configuration\$productName.$nugetVersion.nupkg" "$destination\$productName.$nugetVersion.nupkg.zip"
Copy-Item "$productName.Automation\bin\$Configuration\$productName.Automation.$nugetVersion.nupkg" "$destination\$productName.Automation.$nugetVersion.nupkg.zip"
Copy-Item "$productName.Application\bin\$Configuration\$productName.Application.$nugetVersion.nupkg" "$destination\$productName.Application.$nugetVersion.nupkg.zip"
Copy-Item "$productName.Application.Maui\bin\$Configuration\$productName.Application.Maui.$nugetVersion.nupkg" "$destination\$productName.Application.Maui.$nugetVersion.nupkg.zip"
Copy-Item "$productName.Application.Uwp\bin\$Configuration\$productName.Application.Uwp.$nugetVersion.nupkg" "$destination\$productName.Application.Uwp.$nugetVersion.nupkg.zip"
Copy-Item "$productName.Application.Web\bin\$Configuration\$productName.Application.Web.$nugetVersion.nupkg" "$destination\$productName.Application.Web.$nugetVersion.nupkg.zip"
Copy-Item "$productName.Application.WPF\bin\$Configuration\$productName.Application.WPF.$nugetVersion.nupkg" "$destination\$productName.Application.WPF.$nugetVersion.nupkg.zip"
Copy-Item "$productName.Application.Xamarin\bin\$Configuration\$productName.Application.Xamarin.$nugetVersion.nupkg" "$destination\$productName.Application.Xamarin.$nugetVersion.nupkg.zip"
Copy-Item "$productName.EntityFramework\bin\$Configuration\$productName.EntityFramework.$nugetVersion.nupkg" "$destination\$productName.EntityFramework.$nugetVersion.nupkg.zip"
Copy-Item "$productName.ServiceHosting\bin\$Configuration\$productName.ServiceHosting.$nugetVersion.nupkg" "$destination\$productName.ServiceHosting.$nugetVersion.nupkg.zip"
Copy-Item "$productName\bin\$Configuration\$productName.$nugetVersion.nupkg" "$destination2\"
Copy-Item "$productName.Automation\bin\$Configuration\$productName.Automation.$nugetVersion.nupkg" "$destination2\"
Copy-Item "$productName.Application\bin\$Configuration\$productName.Application.$nugetVersion.nupkg" "$destination2\"
Copy-Item "$productName.Application.Maui\bin\$Configuration\$productName.Application.Maui.$nugetVersion.nupkg" "$destination2\"
Copy-Item "$productName.Application.Uwp\bin\$Configuration\$productName.Application.Uwp.$nugetVersion.nupkg" "$destination2\"
Copy-Item "$productName.Application.Web\bin\$Configuration\$productName.Application.Web.$nugetVersion.nupkg" "$destination2\"
Copy-Item "$productName.Application.WPF\bin\$Configuration\$productName.Application.WPF.$nugetVersion.nupkg" "$destination2\"
Copy-Item "$productName.Application.Xamarin\bin\$Configuration\$productName.Application.Xamarin.$nugetVersion.nupkg" "$destination2\"
Copy-Item "$productName.EntityFramework\bin\$Configuration\$productName.EntityFramework.$nugetVersion.nupkg" "$destination2\"
Copy-Item "$productName.ServiceHosting\bin\$Configuration\$productName.ServiceHosting.$nugetVersion.nupkg" "$destination2\"
Write-Host
Set-Location $scriptPath
Write-Host "Build: " $watch.Elapsed -ForegroundColor Yellow
}
catch
{
Write-Host $_.Exception.ToString() -ForegroundColor Red
Write-Host "Build Failed:" $watch.Elapsed -ForegroundColor Red
exit $LASTEXITCODE
}
finally
{
Pop-Location
}