diff --git a/AppHandling/Extract-AppFileToFolder.ps1 b/AppHandling/Extract-AppFileToFolder.ps1 index 6ae43f7b0..448b9bcb0 100644 --- a/AppHandling/Extract-AppFileToFolder.ps1 +++ b/AppHandling/Extract-AppFileToFolder.ps1 @@ -29,7 +29,7 @@ function Extract-AppFileToFolder { $telemetryScope = InitTelemetryScope -name $MyInvocation.InvocationName -parameterValues $PSBoundParameters -includeParameters @() try { - + Set-StrictMode -Off if ($appFolder -eq "") { if ($openFolder) { $generateAppJson = $true @@ -112,7 +112,6 @@ try { } if ($generateAppJson) { - #Set-StrictMode -Off $manifest = [xml](Get-Content -path (Join-Path $appFolder "NavxManifest.xml") -Encoding UTF8) $runtimeStr = "$($manifest.Package.App.Attributes | Where-Object { $_.name -eq "Runtime" } | % { $_.Value } )" if ($runtimeStr) { @@ -171,19 +170,49 @@ try { } else { $manifest.Package.ChildNodes | Where-Object { $_.name -eq "ResourceExposurePolicy" } | % { - $xmlResExp = [ordered]@{} $resExp = [ordered]@{} - "allowDebugging", "allowDownloadingSource", "includeSourceInSymbolFile" | % { + "allowDebugging", "allowDownloadingSource", "includeSourceInSymbolFile","applyToDevExtension" | % { $prop = $_ - if ($xmlResExp.PSObject.Properties.Name -eq $prop) { + if ($manifest.Package.ResourceExposurePolicy.Attributes | Where-Object { $_.name -eq $prop } | % { $_.Value -eq "true" }) { $resExp += @{ - "$prop" = $xmlResExp."$prop" -eq "true" + "$prop" = $true } } } $appJson += @{ "resourceExposurePolicy" = $resExp } } - + } + if ($runtime -ge [System.Version]"12.0") { + $manifest.Package.ChildNodes | Where-Object { $_.name -eq "Source" } | % { + $node = $_ + $ht = [ordered]@{} + "repositoryUrl", "commit" | % { + $prop = $_ + if ($node) { + $node.Attributes | Where-Object { $_.name -eq $prop } | % { + $ht += @{ + "$prop" = $_.Value + } + } + } + } + $appJson += @{ "source" = $ht } + } + $manifest.Package.ChildNodes | Where-Object { $_.name -eq "Build" } | % { + $node = $_ + $ht = [ordered]@{} + "by", "url" | % { + $prop = $_ + if ($node) { + $node.Attributes | Where-Object { $_.name -eq $prop } | % { + $ht += @{ + "$prop" = $_.Value + } + } + } + } + $appJson += @{ "build" = $ht } + } } if ($runtime -ge [System.Version]"5.0") { $appInsightsKey = $manifest.Package.App.Attributes | Where-Object { $_.name -eq "applicationInsightsKey" } | % { $_.Value } @@ -287,7 +316,6 @@ try { } } $appJson | convertTo-json | Set-Content -Path (Join-Path $appFolder "app.json") -Encoding UTF8 - Set-StrictMode -Version 2.0 } if ($openFolder) { @@ -299,6 +327,7 @@ catch { throw } finally { + Set-StrictMode -Version 2.0 TrackTrace -telemetryScope $telemetryScope } } diff --git a/HelperFunctions.ps1 b/HelperFunctions.ps1 index 00cf323d4..6bd55aa58 100644 --- a/HelperFunctions.ps1 +++ b/HelperFunctions.ps1 @@ -543,33 +543,36 @@ function CopyAppFilesToFolder { } } elseif (Test-Path $appFile -PathType Leaf) { - if ([string]::new([char[]](Get-Content $appFile @byteEncodingParam -TotalCount 2)) -eq "PK") { - $tmpFolder = Join-Path ([System.IO.Path]::GetTempPath()) ([Guid]::NewGuid().ToString()) - $copied = $false - try { - if ($appFile -notlike "*.zip") { - $orgAppFile = $appFile - $appFile = Join-Path ([System.IO.Path]::GetTempPath()) "$([System.IO.Path]::GetFileName($orgAppFile)).zip" - Copy-Item $orgAppFile $appFile - $copied = $true + Get-ChildItem $appFile | ForEach-Object { + $appFile = $_.FullName + if ([string]::new([char[]](Get-Content $appFile @byteEncodingParam -TotalCount 2)) -eq "PK") { + $tmpFolder = Join-Path ([System.IO.Path]::GetTempPath()) ([Guid]::NewGuid().ToString()) + $copied = $false + try { + if ($appFile -notlike "*.zip") { + $orgAppFile = $appFile + $appFile = Join-Path ([System.IO.Path]::GetTempPath()) "$([System.IO.Path]::GetFileName($orgAppFile)).zip" + Copy-Item $orgAppFile $appFile + $copied = $true + } + Expand-Archive $appfile -DestinationPath $tmpFolder -Force + Get-ChildItem -Path $tmpFolder -Recurse | Where-Object { $_.Name -like "*.app" -or $_.Name -like "*.zip" } | % { + CopyAppFilesToFolder -appFile $_.FullName -folder $folder + } } - Expand-Archive $appfile -DestinationPath $tmpFolder -Force - Get-ChildItem -Path $tmpFolder -Recurse | Where-Object { $_.Name -like "*.app" -or $_.Name -like "*.zip" } | % { - CopyAppFilesToFolder -appFile $_.FullName -folder $folder + finally { + Remove-Item -Path $tmpFolder -Recurse -Force + if ($copied) { Remove-Item -Path $appFile -Force } } } - finally { - Remove-Item -Path $tmpFolder -Recurse -Force - if ($copied) { Remove-Item -Path $appFile -Force } - } - } - else { - $destFile = Join-Path $folder "$([System.IO.Path]::GetFileNameWithoutExtension($appFile)).app" - if (Test-Path $destFile) { - Write-Host -ForegroundColor Yellow "::WARNING::$([System.IO.Path]::GetFileName($destFile)) already exists, it looks like you have multiple app files with the same name. App filenames must be unique." + else { + $destFile = Join-Path $folder "$([System.IO.Path]::GetFileNameWithoutExtension($appFile)).app" + if (Test-Path $destFile) { + Write-Host -ForegroundColor Yellow "::WARNING::$([System.IO.Path]::GetFileName($destFile)) already exists, it looks like you have multiple app files with the same name. App filenames must be unique." + } + Copy-Item -Path $appFile -Destination $destFile -Force + $destFile } - Copy-Item -Path $appFile -Destination $destFile -Force - $destFile } } else {