Skip to content

Commit 8143f8e

Browse files
Use dotnet run in CI smoke
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent aca068f commit 8143f8e

1 file changed

Lines changed: 10 additions & 62 deletions

File tree

testing/automation/run-cli-e2e.ps1

Lines changed: 10 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -5,71 +5,19 @@ $repoRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot)
55
$srcRoot = Join-Path $repoRoot 'src'
66
$configuration = if ($env:CONFIGURATION) { $env:CONFIGURATION } else { 'Release' }
77

8-
function Resolve-BuildArtifact {
9-
param(
10-
[Parameter(Mandatory = $true)]
11-
[string] $ProjectName,
12-
[Parameter(Mandatory = $true)]
13-
[string] $AssemblyName
14-
)
15-
16-
$binRoot = Join-Path (Join-Path $srcRoot $ProjectName) 'bin'
17-
$separator = [System.IO.Path]::DirectorySeparatorChar
18-
$configurationSegment = [string]::Concat($separator, $configuration, $separator)
19-
$targetFrameworkSegment = [string]::Concat($separator, 'net10.0', $separator)
20-
$processArchitecture = [System.Runtime.InteropServices.RuntimeInformation]::ProcessArchitecture.ToString().ToLowerInvariant()
21-
$processArchitectureSegment = [string]::Concat($separator, $processArchitecture, $separator)
22-
$knownArchitectureSegments = @('x86', 'x64', 'arm64') | ForEach-Object {
23-
[string]::Concat($separator, $_, $separator)
24-
}
25-
26-
$candidate = Get-ChildItem -Path $binRoot -Recurse -Filter $AssemblyName -File -ErrorAction SilentlyContinue |
27-
Where-Object { $_.FullName.Contains($configurationSegment) -and $_.FullName.Contains($targetFrameworkSegment) } |
28-
Sort-Object `
29-
@{ Expression = {
30-
if ($_.FullName.Contains($processArchitectureSegment)) {
31-
2
32-
}
33-
else {
34-
$hasDifferentArchitectureSegment = $false
35-
foreach ($architectureSegment in $knownArchitectureSegments) {
36-
if ($architectureSegment -ne $processArchitectureSegment -and $_.FullName.Contains($architectureSegment)) {
37-
$hasDifferentArchitectureSegment = $true
38-
break
39-
}
40-
}
41-
42-
if (-not $hasDifferentArchitectureSegment) {
43-
1
44-
}
45-
else {
46-
0
47-
}
48-
}
49-
}; Descending = $true },
50-
@{ Expression = 'LastWriteTimeUtc'; Descending = $true } |
51-
Select-Object -First 1
52-
53-
if ($null -eq $candidate) {
54-
throw "Assembly $AssemblyName not found under $binRoot"
55-
}
56-
57-
return $candidate.FullName
58-
}
59-
60-
$daemonDll = Resolve-BuildArtifact -ProjectName 'UniGetUI.Avalonia' -AssemblyName 'UniGetUI.Avalonia.dll'
61-
$cliDll = Resolve-BuildArtifact -ProjectName 'UniGetUI.Cli' -AssemblyName 'UniGetUI.Cli.dll'
8+
$daemonProject = Join-Path (Join-Path $srcRoot 'UniGetUI.Avalonia') 'UniGetUI.Avalonia.csproj'
9+
$cliProject = Join-Path (Join-Path $srcRoot 'UniGetUI.Cli') 'UniGetUI.Cli.csproj'
6210

63-
if (-not (Test-Path $daemonDll)) {
64-
throw "Daemon assembly not found at $daemonDll"
11+
if (-not (Test-Path $daemonProject)) {
12+
throw "Daemon project not found at $daemonProject"
6513
}
6614

67-
if (-not (Test-Path $cliDll)) {
68-
throw "CLI assembly not found at $cliDll"
15+
if (-not (Test-Path $cliProject)) {
16+
throw "CLI project not found at $cliProject"
6917
}
7018

71-
$daemonDll = (Resolve-Path $daemonDll).Path
72-
$cliDll = (Resolve-Path $cliDll).Path
19+
$daemonProject = (Resolve-Path $daemonProject).Path
20+
$cliProject = (Resolve-Path $cliProject).Path
7321

7422
$daemonRoot = Join-Path ([System.IO.Path]::GetTempPath()) ("unigetui-headless-" + [Guid]::NewGuid().ToString('N'))
7523
New-Item -ItemType Directory -Path $daemonRoot | Out-Null
@@ -79,7 +27,7 @@ $env:USERPROFILE = $daemonRoot
7927
$env:DOTNET_CLI_HOME = $daemonRoot
8028

8129
$transportArgs = @()
82-
$daemonArgs = @($daemonDll, '--headless')
30+
$daemonArgs = @('run', '--project', $daemonProject, '--configuration', $configuration, '--no-build', '--', '--headless')
8331

8432
if ($IsWindows) {
8533
$pipeName = "UniGetUI.CI.$([Guid]::NewGuid().ToString('N'))"
@@ -120,7 +68,7 @@ try {
12068
[string[]] $Arguments
12169
)
12270

123-
$output = & dotnet $cliDll @Arguments @transportArgs 2>&1
71+
$output = & dotnet run --project $cliProject --configuration $configuration --no-build -- @Arguments @transportArgs 2>&1
12472
if ($LASTEXITCODE -ne 0) {
12573
throw "CLI command failed ($LASTEXITCODE): $($Arguments -join ' ')`n$output"
12674
}

0 commit comments

Comments
 (0)