Skip to content
9 changes: 6 additions & 3 deletions Actions/CreateApp/CreateApp.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,13 @@ try {
$sampleApp = (Get-Item -Path $sampleApp).FullName
}
else {
$sampleApp = Join-Path $folders[1] "Applications\testframework\performancetoolkit\Microsoft_Performance Toolkit Samples.app"
# Narrow the search to the Applications subdirectory if present, to avoid traversing the entire artifact tree
$searchRoot = Get-ChildItem -Path $folders[1] -Directory -ErrorAction SilentlyContinue | Where-Object { $_.Name -ieq 'Applications' } | Select-Object -First 1 -ExpandProperty FullName
if (!$searchRoot) { $searchRoot = $folders[1] }
$sampleApp = Get-ChildItem -Path $searchRoot -Filter "Microsoft_Performance Toolkit Samples.app" -File -Recurse -ErrorAction SilentlyContinue | Select-Object -First 1 -ExpandProperty FullName
}
if (!(Test-Path -Path $sampleApp)) {
throw "Could not locate sample app for the Business Central version"
if (!$sampleApp -or !(Test-Path -Path $sampleApp)) {
throw "Could not locate 'Microsoft_Performance Toolkit Samples.app' under '$($folders[1])'"
}
Comment thread
mazhelez marked this conversation as resolved.

Extract-AppFileToFolder -appFilename $sampleApp -generateAppJson -appFolder $tmpFolder
Expand Down
1 change: 1 addition & 0 deletions RELEASENOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ The `DownloadProjectDependencies` action now downloads only artifacts from depen
- Issue 2211 - Cannot create a release if a project contains only test apps
- Issue 2214 - Workspace compilation not working with external dependencies
- Issue 2235 - Workspace compilation: only the first `customCodeCops` entry resolved when multiple relative paths were configured. Relative `customCodeCops` paths are now resolved against the project folder before being passed to the compiler.
- Issue 2265 - Creating a Performance Test App fails on Linux due to case-sensitive path lookup for the Performance Toolkit sample app

## v9.0

Expand Down
24 changes: 24 additions & 0 deletions Tests/CreateApp.Action.Test.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,28 @@ Describe "CreateApp Action Tests" {

# Call action

It 'Should find Performance Toolkit sample app with <Casing> directory casing' -TestCases @(
@{ Casing = 'PascalCase'; Dirs = @('Applications', 'TestFramework', 'performancetoolkit') }
@{ Casing = 'lowercase'; Dirs = @('applications', 'testframework', 'performancetoolkit') }
) {
param($Casing, $Dirs)
$tempDir = Join-Path ([System.IO.Path]::GetTempPath()) ([Guid]::NewGuid().ToString())
try {
$sampleAppDir = Join-Path $tempDir $Dirs[0] $Dirs[1] $Dirs[2]
New-Item -Path $sampleAppDir -ItemType Directory -Force | Out-Null
$sampleAppFile = Join-Path $sampleAppDir "Microsoft_Performance Toolkit Samples.app"
Set-Content -Path $sampleAppFile -Value "dummy"

# Use the same lookup logic as in CreateApp.ps1: narrow to Applications subdirectory first
$searchRoot = Get-ChildItem -Path $tempDir -Directory -ErrorAction SilentlyContinue | Where-Object { $_.Name -ieq 'Applications' } | Select-Object -First 1 -ExpandProperty FullName
if (!$searchRoot) { $searchRoot = $tempDir }
$result = Get-ChildItem -Path $searchRoot -Filter "Microsoft_Performance Toolkit Samples.app" -File -Recurse -ErrorAction SilentlyContinue | Select-Object -First 1 -ExpandProperty FullName

$result | Should -Not -BeNullOrEmpty
$result | Should -Be $sampleAppFile
}
finally {
Remove-Item -Path $tempDir -Recurse -Force -ErrorAction SilentlyContinue
}
}
}