-
-
Notifications
You must be signed in to change notification settings - Fork 251
Expand file tree
/
Copy pathcommon.ps1
More file actions
162 lines (148 loc) · 5.53 KB
/
Copy pathcommon.ps1
File metadata and controls
162 lines (148 loc) · 5.53 KB
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
155
156
157
158
159
160
161
162
. $PSScriptRoot/pester.ps1
AfterAll {
Pop-Location
}
BeforeAll {
Push-Location $PSScriptRoot
$env:SENTRY_LOG_LEVEL = 'debug';
function GetSentryPackageVersion()
{
(Select-Xml -Path "$PSScriptRoot/../Directory.Build.props" -XPath "/Project/PropertyGroup/VersionPrefix").Node.InnerText
}
function RegisterLocalPackage([string] $name)
{
$packageVersion = GetSentryPackageVersion
$packagePath = "$PSScriptRoot/../src/$name/bin/Release/$name.$packageVersion.nupkg"
if (-not (Test-Path env:CI))
{
Write-Host "Packaging $name, expected output path: $packagePath"
dotnet pack "$PSScriptRoot/../src/$name" -c Release --nologo -p:Version=$packageVersion -p:IsPackable=true | ForEach-Object { Write-Host $_ }
if ($LASTEXITCODE -ne 0)
{
throw "Failed to package $name."
}
}
Write-Host "Using package $packagePath - $((Get-Item $packagePath).Length) bytes"
dotnet nuget push $packagePath --source integration-test | ForEach-Object { Write-Host $_ }
if ($LASTEXITCODE -ne 0)
{
throw "Failed to add package $name to a local nuget source."
}
# We need to remove the package from cache or it won't re resolved properly
Remove-Item -Path ~/.nuget/packages/$($name.ToLower())/$packageVersion -Recurse -Force -ErrorAction SilentlyContinue
}
Remove-Item -Path "$PSScriptRoot/packages" -Recurse -Force -ErrorAction SilentlyContinue
New-Item -ItemType Directory -Path "$PSScriptRoot/packages" | Out-Null
RegisterLocalPackage 'Sentry'
function RunDotnetWithSentryCLI([string] $action, [string]$project, [bool]$Symbols, [bool]$Sources, [string]$TargetFramework)
{
$rootDir = $PSScriptRoot
$result = Invoke-SentryServer {
Param([string]$url)
Write-Host "::group::${action}ing $project"
try
{
dotnet $action $project -flp:logfile=build.log `
-c Release `
--nologo `
--framework $TargetFramework `
/p:SentryUploadSymbols=$Symbols `
/p:SentryUploadSources=$Sources `
/p:SentryOrg=org `
/p:SentryProject=project `
/p:SentryUrl=$url `
/p:SentryAuthToken=dummy `
| ForEach-Object {
if ($_ -match "^Time Elapsed ")
{
"Time Elapsed [value removed]"
}
elseif ($_ -match "\[[0-9/]+\]")
{
# Skip lines like `[102/103] Sentry.Samples.Maui.dll -> Sentry.Samples.Maui.dll.so`
}
else
{
"$_".Replace('\', '/').Replace($rootDir, '')
}
}
| ForEach-Object {
Write-Host " $_"
$_
}
}
finally
{
Write-Host "::endgroup::"
}
}
if ($action -eq "build")
{
$result.ScriptOutput | Should -Contain 'Build succeeded.'
}
elseif ($action -eq "publish")
{
$result.ScriptOutput | Should -AnyElementMatch "$((Get-Item $project).Basename) -> .*$project/bin/Release/$TargetFramework/.*/publish"
}
$result.ScriptOutput | Should -Not -AnyElementMatch "Preparing upload to Sentry for project 'Sentry'"
$result.HasErrors() | Should -BeFalse
$result
}
function AddPackageReference([string] $projectPath, [string] $package)
{
Push-Location $projectPath
try
{
dotnet restore | ForEach-Object { Write-Host $_ }
if ($LASTEXITCODE -ne 0)
{
throw "Failed to restore the test app project."
}
$packageVersion = GetSentryPackageVersion
dotnet add package $package --source $PSScriptRoot/packages --version $packageVersion --no-restore | ForEach-Object { Write-Host $_ }
if ($LASTEXITCODE -ne 0)
{
throw "Failed to add package dependency to the test app project."
}
}
finally
{
Pop-Location
}
}
function DotnetNew([string] $type, [string] $name, [string] $framework)
{
Remove-Item -Path $name -Recurse -Force -ErrorAction SilentlyContinue
dotnet new $type --output $name --framework $framework | ForEach-Object { Write-Host $_ }
if ($LASTEXITCODE -ne 0)
{
throw "Failed to create the test app '$name' from template '$type'."
}
if ($type -eq 'maui')
{
@"
<Project>
<PropertyGroup>
<SentryUploadAndroidProguardMapping>true</SentryUploadAndroidProguardMapping>
<AndroidLinkTool Condition=`" '`$(AndroidLinkTool)' == '' `">r8</AndroidLinkTool>
<AndroidDexTool Condition=`" '`$(AndroidDexTool)' == '' `">d8</AndroidDexTool>
</PropertyGroup>
</Project>
"@ | Out-File $name/Directory.Build.props
}
if ($type -eq 'console')
{
AddPackageReference $name 'Sentry'
if (!$IsMacOS -or $framework -eq 'net8.0')
{
@"
<Project>
<PropertyGroup>
<PublishAot>true</PublishAot>
</PropertyGroup>
</Project>
"@ | Out-File $name/Directory.Build.props
}
}
}
}