mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-02-23 19:49:43 +01:00
support installer
This commit is contained in:
@@ -22,9 +22,15 @@ parameters:
|
||||
- name: variables
|
||||
type: object
|
||||
default: {}
|
||||
- name: uiTestProjectPattern
|
||||
type: string
|
||||
default: '*UITest*.csproj'
|
||||
- name: uiTestProjectsToBuild
|
||||
type: object
|
||||
default:
|
||||
- 'src/modules/fancyzones/UITests-FancyZones/UITests-FancyZones.csproj'
|
||||
- 'src/modules/fancyzones/UITests-FancyZonesEditor/UITests-FancyZonesEditor.csproj'
|
||||
- 'src/modules/MouseUtils/MouseUtils.UITests/MouseUtils.UITests.csproj'
|
||||
- 'src/modules/Workspaces/WorkspacesEditorUITest/WorkspacesEditorUITest.csproj'
|
||||
- 'src/modules/imageresizer/tests/ImageResizerUITest.csproj'
|
||||
- 'src/modules/Hosts/Hosts.UITests/Hosts.UITests.csproj'
|
||||
|
||||
jobs:
|
||||
- job: BuildUITests
|
||||
@@ -42,7 +48,7 @@ jobs:
|
||||
variables:
|
||||
JobOutputDirectory: $(Build.ArtifactStagingDirectory)
|
||||
LogOutputDirectory: $(Build.ArtifactStagingDirectory)\logs
|
||||
JobOutputArtifactName: build-uitests-$(BuildPlatform)-$(BuildConfiguration)
|
||||
JobOutputArtifactName: build-$(BuildPlatform)-$(BuildConfiguration)
|
||||
NUGET_RESTORE_MSBUILD_ARGS: /p:Platform=$(BuildPlatform)
|
||||
${{ insert }}: ${{ parameters.variables }}
|
||||
displayName: Build UI Tests Only
|
||||
@@ -77,70 +83,25 @@ jobs:
|
||||
restoreSolution: PowerToys.sln
|
||||
restoreDirectory: '$(Build.SourcesDirectory)\packages'
|
||||
|
||||
# Dynamically discover and build UI test projects
|
||||
- pwsh: |
|
||||
$uiTestProjects = @()
|
||||
|
||||
# Search for UI test projects using the pattern
|
||||
$projectFiles = Get-ChildItem -Path "$(Build.SourcesDirectory)" -Filter "${{ parameters.uiTestProjectPattern }}" -Recurse
|
||||
|
||||
Write-Host "Found $($projectFiles.Count) UI test projects:"
|
||||
foreach ($project in $projectFiles) {
|
||||
$relativePath = $project.FullName.Replace("$(Build.SourcesDirectory)\", "").Replace("\", "/")
|
||||
Write-Host " - $relativePath"
|
||||
$uiTestProjects += $relativePath
|
||||
}
|
||||
|
||||
if ($uiTestProjects.Count -eq 0) {
|
||||
Write-Host "##vso[task.logissue type=warning]No UI test projects found with pattern: ${{ parameters.uiTestProjectPattern }}"
|
||||
exit 0
|
||||
}
|
||||
|
||||
# Build each discovered project
|
||||
foreach ($project in $uiTestProjects) {
|
||||
Write-Host "Building project: $project"
|
||||
|
||||
# Generate safe artifact name for logging
|
||||
$artifactName = $project -replace '[/\\]', '_' -replace '\.csproj$', ''
|
||||
|
||||
# Use VSBuild for consistency with the main build pipeline
|
||||
$msbuildArgs = @(
|
||||
"-restore",
|
||||
"-graph",
|
||||
"/p:RestorePackagesConfig=true",
|
||||
"/p:BuildProjectReferences=true",
|
||||
"/p:CIBuild=true",
|
||||
"/bl:$(LogOutputDirectory)\build-$artifactName.binlog",
|
||||
"$(NUGET_RESTORE_MSBUILD_ARGS)"
|
||||
)
|
||||
|
||||
$arguments = @{
|
||||
'FilePath' = 'dotnet'
|
||||
'ArgumentList' = @(
|
||||
'build',
|
||||
$project,
|
||||
'--configuration', '$(BuildConfiguration)',
|
||||
'--verbosity', 'minimal'
|
||||
) + $msbuildArgs
|
||||
'WorkingDirectory' = '$(Build.SourcesDirectory)'
|
||||
'NoNewWindow' = $true
|
||||
'Wait' = $true
|
||||
'PassThru' = $true
|
||||
}
|
||||
|
||||
$process = Start-Process @arguments
|
||||
|
||||
if ($process.ExitCode -ne 0) {
|
||||
Write-Host "##vso[task.logissue type=error]Build failed for project: $project"
|
||||
exit $process.ExitCode
|
||||
}
|
||||
|
||||
Write-Host "Successfully built: $project"
|
||||
}
|
||||
|
||||
Write-Host "All UI test projects built successfully!"
|
||||
displayName: Discover and Build UI Test Projects
|
||||
workingDirectory: $(Build.SourcesDirectory)
|
||||
# Build only UI test projects
|
||||
- ${{ each project in parameters.uiTestProjectsToBuild }}:
|
||||
- task: VSBuild@1
|
||||
displayName: Build UI Test Project ${{ project }}
|
||||
inputs:
|
||||
solution: ${{ project }}
|
||||
vsVersion: 17.0
|
||||
msbuildArgs: >-
|
||||
-restore
|
||||
-graph
|
||||
/p:RestorePackagesConfig=true
|
||||
/p:BuildProjectReferences=true
|
||||
/p:CIBuild=true
|
||||
/bl:$(LogOutputDirectory)\build-${{ join('_',split(project, '/')) }}.binlog
|
||||
$(NUGET_RESTORE_MSBUILD_ARGS)
|
||||
platform: $(BuildPlatform)
|
||||
configuration: $(BuildConfiguration)
|
||||
msbuildArchitecture: x64
|
||||
maximumCpuCount: true
|
||||
|
||||
# Stage test project outputs with directory structure
|
||||
- task: CopyFiles@2
|
||||
|
||||
@@ -137,7 +137,7 @@ namespace Microsoft.PowerToys.UITest
|
||||
{
|
||||
@"C:\Program Files\PowerToys",
|
||||
@"C:\Program Files (x86)\PowerToys",
|
||||
Environment.ExpandEnvironmentVariables(@"%LocalAppData%\Microsoft\PowerToys"),
|
||||
Environment.ExpandEnvironmentVariables(@"%LocalAppData%\PowerToys"),
|
||||
Environment.ExpandEnvironmentVariables(@"%ProgramFiles%\PowerToys"),
|
||||
};
|
||||
|
||||
|
||||
@@ -33,12 +33,17 @@ namespace Microsoft.PowerToys.UITest
|
||||
|
||||
private PowerToysModule scope;
|
||||
|
||||
private bool UseInstallerForTest { get; }
|
||||
|
||||
[UnconditionalSuppressMessage("SingleFile", "IL3000:Avoid accessing Assembly file path when publishing as a single file", Justification = "<Pending>")]
|
||||
public SessionHelper(PowerToysModule scope)
|
||||
{
|
||||
this.scope = scope;
|
||||
this.sessionPath = ModuleConfigData.Instance.GetModulePath(scope);
|
||||
this.locationPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
|
||||
string? useInstallerForTestEnv =
|
||||
Environment.GetEnvironmentVariable("useInstallerForTest") ?? Environment.GetEnvironmentVariable("USEINSTALLERFORTEST");
|
||||
UseInstallerForTest = !string.IsNullOrEmpty(useInstallerForTestEnv) && bool.TryParse(useInstallerForTestEnv, out bool result) && result;
|
||||
this.locationPath = UseInstallerForTest ? string.Empty : Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
|
||||
|
||||
CheckWinAppDriverAndRoot();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user