diff --git a/tools/build/build-appx.ps1 b/tools/build/build-appx.ps1 index 33d166275..87cd5c415 100644 --- a/tools/build/build-appx.ps1 +++ b/tools/build/build-appx.ps1 @@ -44,10 +44,12 @@ function Update-Certificate { # Finding local certificate $certificate_path = "${PSScriptRoot}\.certificate_thumbprint" if (! (Test-Path "${certificate_path}") ) { - Write-Error "You need a certificate to build and install the Appx. ` + Write-Warning "You need a certificate to build and install the Appx. ` Create and install a certificate, and write its thumbprint in ${certificate_path}.` See https://learn.microsoft.com/en-us/windows/win32/appxpkg/how-to-create-a-package-signing-certificate for more details" - exit 1 + + Write-Output "Continuing with default certificate" + return } $certificate_thumbprint = Get-Content ${certificate_path} @@ -62,6 +64,8 @@ function Update-Certificate { } function Install-Appx { + Get-AppxPackage -Name "CanonicalGroupLimited.UbuntuProForWindows" | Remove-AppxPackage + $artifacts = ( Get-ChildItem ".\msix\UbuntuProForWindows\AppPackages\UbuntuProForWindows_*" ` | Sort-Object LastWriteTime ` @@ -84,7 +88,11 @@ Push-Location "${PSScriptRoot}\..\.." Update-Certificate -Start-VsDevShell +try { + msbuild.exe --version +} catch { + Start-VsDevShell +} msbuild.exe ` .\msix\msix.sln ` diff --git a/tools/build/build-deb.ps1 b/tools/build/build-deb.ps1 index c7a872329..8587b57ee 100644 --- a/tools/build/build-deb.ps1 +++ b/tools/build/build-deb.ps1 @@ -4,7 +4,7 @@ #> param( - [Parameter(Mandatory=$False,HelpMessage="The directory where the debian build artifacts will be stored in")] + [Parameter(Mandatory = $False, HelpMessage = "The directory where the debian build artifacts will be stored in")] [string]$OutputDir ) @@ -21,7 +21,7 @@ if ( $appx -eq "" ) { Write-Error "Ubuntu Preview is not installed" } -$env:WSL_UTF8=1 +$env:WSL_UTF8 = 1 if ( "$(wsl --list --verbose | Select-String Ubuntu-Preview)" -eq "" ) { ubuntupreview.exe install --root --ui=none @@ -29,12 +29,14 @@ if ( "$(wsl --list --verbose | Select-String Ubuntu-Preview)" -eq "" ) { Write-Error "could not install Ubuntu-Preview" exit 1 } + + Copy-Item -Path "${HOME}/.gitconfig" -Destination "\\wsl$\Ubuntu-Preview\etc\gitconfig" } # Write script to run -$scriptWindows=New-TemporaryFile +$scriptWindows = New-TemporaryFile -$scriptLinux=( wsl.exe -d Ubuntu-Preview -- wslpath -ua `'${scriptWindows}`' ) +$scriptLinux = ( wsl.exe -d Ubuntu-Preview -- wslpath -ua `'${scriptWindows}`' ) if ( "${LastExitCode}" -ne "0" ) { Write-Error "could not get build script's linux path" exit 1 @@ -47,9 +49,13 @@ set -eu git config --global --add safe.directory "$(pwd)" -# Update internal dependencies in the repo -# (we need git to work, and .git is not rsync'd) +# Update internal dependencies in the repo because +# we need git to work, and .git is not rsync'd. cd wsl-pro-service +go version || ( + sudo DEBIAN_FRONTEND=noninteractive apt update + sudo DEBIAN_FRONTEND=noninteractive apt install -y golang-go +) ./debian/update-internal-dependencies go mod tidy go mod vendor @@ -79,7 +85,7 @@ cp -f ${build_dir}/wsl-pro-service_* "${OutputDir}" # Set up output directory New-Item -Force -ItemType "Directory" -Path "${OutputDir}" | Out-Null -$outputLinux=( wsl.exe -d Ubuntu-Preview -- wslpath -ua `'${OutputDir}`' ) +$outputLinux = ( wsl.exe -d Ubuntu-Preview -- wslpath -ua `'${OutputDir}`' ) if ( "${LastExitCode}" -ne "0" ) { Write-Error "could not get output dir's linux path" exit 1 diff --git a/wsl-pro-service/debian/update-internal-dependencies b/wsl-pro-service/debian/update-internal-dependencies index 59d51f0ff..3b19d2ff8 100755 --- a/wsl-pro-service/debian/update-internal-dependencies +++ b/wsl-pro-service/debian/update-internal-dependencies @@ -2,7 +2,7 @@ set -eu # Add repo as private -go env -w GOPRIVATE=github.com/canonical/ubuntu-pro-for-windows +go env -w "GOPRIVATE=github.com/canonical/ubuntu-pro-for-windows" UP4W_SKIP_INTERNAL_DEPENDENCY_UPDATE=${UP4W_SKIP_INTERNAL_DEPENDENCY_UPDATE:-""}