Skip to content

Commit

Permalink
Updates the build Appx tool to support build modes
Browse files Browse the repository at this point in the history
Compatible with the changes in CI
  • Loading branch information
CarlosNihelton committed Oct 6, 2023
1 parent 6a74dd9 commit 14bb14c
Showing 1 changed file with 29 additions and 17 deletions.
46 changes: 29 additions & 17 deletions tools/build/build-appx.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
Build the Ubuntu Pro For Windows Appx package for local use.
#>

param (
[Parameter(Mandatory = $true, HelpMessage = "prodution, end_to_end_tests.")]

[string]$mode
)

function Start-VsDevShell {
# Looking for a path like
# ${env:ProgramFiles}\Microsoft Visual Studio\$VERSION\$RELEASE\Common7\Tools\Launch-VsDevShell.ps1
Expand All @@ -25,15 +31,15 @@ function Start-VsDevShell {
continue
}

foreach ( $release in "Enterprise","Professional","Community") {
foreach ( $release in "Enterprise", "Professional", "Community") {
$devShell = "${vsRoot}\${version}\${release}\Common7\Tools\Launch-VsDevShell.ps1"
if (! (Test-Path "${devShell}") ) {
continue
}

& "${devShell}" -SkipAutomaticLocation
return
}
}
}

Write-Error "Visual Studio developer powershell could not be found"
Expand All @@ -57,10 +63,10 @@ function Update-Certificate {
# Replacing with local certificate
$wapproj = ".\msix\UbuntuProForWindows\UbuntuProForWindows.wapproj"
(Get-Content -Path "${wapproj}") `
-replace `
"<PackageCertificateThumbprint>.*</PackageCertificateThumbprint>", `
"<PackageCertificateThumbprint>${certificate_thumbprint}</PackageCertificateThumbprint>" `
| Set-Content -Path "${wapproj}"
-replace `
"<PackageCertificateThumbprint>.*</PackageCertificateThumbprint>", `
"<PackageCertificateThumbprint>${certificate_thumbprint}</PackageCertificateThumbprint>" `
| Set-Content -Path "${wapproj}"
}

function Install-Appx {
Expand Down Expand Up @@ -90,20 +96,26 @@ Update-Certificate

try {
msbuild.exe --version
} catch {
}
catch {
Start-VsDevShell
}

msbuild.exe `
.\msix\msix.sln `
-target:Build `
-maxCpuCount `
-property:Configuration=Release `
-property:AppxBundle=Always `
-property:AppxBundlePlatforms=x64 `
-property:ProcessorArchitecture=x64 `
-property:UapAppxPackageBuildMode=SideloadOnly `
-nologo `
If ($mode -eq 'production' -and $null -ne $env:UP4W_TEST_WITH_MS_STORE_MOCK) {
Write-Warning "Building the app in Release mode with UP4W_TEST_WITH_MS_STORE_MOCK env var set may lead to build failure or surprising results. Value is $env:UP4W_TEST_WITH_MS_STORE_MOCK."
}

msbuild.exe `
.\msix\msix.sln `
-target:Build `
-maxCpuCount `
-property:Configuration=$(If($mode -eq 'production'){"Release"} Else {"Debug"}) `
-property:AppxBundle=Always `
-property:AppxBundlePlatforms=x64 `
-property:ProcessorArchitecture=x64 `
-property:UapAppxPackageBuildMode=SideloadOnly `
-nologo `
-property:UP4W_END_TO_END=$(If($mode -eq 'end_to_end_tests'){"true"} Else {"false"}) `
-verbosity:normal

if (! $?) { exit 1 }
Expand Down

0 comments on commit 14bb14c

Please sign in to comment.