-
Notifications
You must be signed in to change notification settings - Fork 72
/
build.ps1
60 lines (52 loc) · 1.44 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
# Copyright (c) Microsoft. All rights reserved.
# Licensed under the MIT license. See LICENSE file in the project root for full license information.
function GetAssemblyVersionFromFile($filename)
{
$regex = 'AssemblyInformationalVersion\("(\d{1,3}\.\d{1,3}\.\d{1,3}(?:-[A-Za-z0-9-]+)?)"\)'
$values = select-string -Path $filename -Pattern $regex | % { $_.Matches } | % { $_.Groups } | % { $_.Value }
if( $values.Count -eq 2 ) {
return $values[1]
}
Write-Host "Error: Unable to find AssemblyInformationalVersion in $filename" -foregroundcolor "red"
exit
}
function Build-Solution
{
Param(
[String] $Configuration = 'Debug',
[String] $Platform = 'Any CPU'
)
dotnet.exe restore amqp.sln
if (-Not $?)
{
throw "Restore failed."
}
dotnet.exe build amqp.sln -c $Configuration --no-restore /p:Platform="$Platform"
if (-Not $?)
{
throw "Build failed."
}
}
function Run-Tests
{
Param(
[String] $Configuration = 'Debug'
)
dotnet.exe test -c $Configuration --no-build .\test\Test.Microsoft.Amqp\Test.Microsoft.Amqp.csproj --logger "GitHubActions;report-warnings=false"
if (-Not $?)
{
throw "Test failed."
}
}
function Create-Package
{
Param(
[String] $Configuration = 'Signed'
)
$ver = GetAssemblyVersionFromFile(".\src\Properties\Version.cs")
dotnet.exe pack -p:Version=$ver -c $Configuration --no-build .\src\Microsoft.Azure.Amqp.csproj
if (-Not $?)
{
throw "Packaging failed for version $ver."
}
}