diff --git a/build/azure-pipelines.yml b/build/azure-pipelines.yml index 8b05dbd..24ee80a 100644 --- a/build/azure-pipelines.yml +++ b/build/azure-pipelines.yml @@ -65,29 +65,11 @@ extends: filePath: './build/scripts/SetupBuildInfo.ps1' arguments: -Version $(MSIXVersion) -IsAzurePipelineBuild - - task: MSBuild@1 - displayName: Restoring packages - inputs: - solution: '$(solution)' - msbuildArchitecture: '${{ platform }}' - platform: '${{ platform }}' - configuration: '${{ configuration }}' - msbuildArguments: '/t:Restore' - - - task: MsixPackaging@1 + - task: PowerShell@2 displayName: Building MSIX inputs: - outputPath: 'BuildOutput\GitHubExtension_${{ configuration }}_${{ platform }}.msix' - solution: '$(solution)' - clean: false - generateBundle: false - buildConfiguration: '${{ configuration }}' - buildPlatform: '${{ platform }}' - updateAppVersion: false - appPackageDistributionMode: 'SideloadOnly' - msbuildLocationMethod: 'version' - msbuildVersion: 'latest' - msbuildArchitecture: '${{ platform }}' + filePath: './build/scripts/Build.ps1' + arguments: -Platform "${{ platform }}" -Configuration "${{ configuration }}" -Version $(MSIXVersion) - template: ./build/templates/EsrpSigning-Steps.yml@self parameters: @@ -131,7 +113,7 @@ extends: - task: PowerShell@2 displayName: 'Run Unittests' - condition: ne('${{ platform}}', 'arm64') + condition: ne('${{ platform }}', 'arm64') retryCountOnTaskFailure: 2 inputs: filePath: 'build/scripts/Test.ps1' diff --git a/build/scripts/Build.ps1 b/build/scripts/Build.ps1 index f755e2e..29c83fe 100644 --- a/build/scripts/Build.ps1 +++ b/build/scripts/Build.ps1 @@ -2,10 +2,6 @@ Param( [string]$Platform = "x64", [string]$Configuration = "debug", [string]$Version, - [string]$ClientId, - [string]$ClientSecret, - [string]$BuildStep = "all", - [string]$AzureBuildingBranch = "main", [switch]$IsAzurePipelineBuild = $false, [switch]$Help = $false ) @@ -47,36 +43,12 @@ Options: Exit } -# Install NuGet Cred Provider -Invoke-Expression "& { $(irm https://aka.ms/install-artifacts-credprovider.ps1) } -AddNetfx" - # Root is two levels up from the script location. $env:Build_RootDirectory = (Get-Item $PSScriptRoot).parent.parent.FullName $env:Build_Platform = $Platform.ToLower() $env:Build_Configuration = $Configuration.ToLower() -$env:msix_version = build\scripts\CreateBuildInfo.ps1 -Version $Version -IsAzurePipelineBuild $IsAzurePipelineBuild $isAdmin = ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] 'Administrator') -# Set GitHub OAuth Client App configuration if build-time parameters are present -$OAuthConfigFilePath = (Join-Path $env:Build_RootDirectory "src\GitHubExtension\Configuration\OAuthConfiguration.cs") -if (![string]::IsNullOrWhitespace($ClientId)) { - (Get-Content $OAuthConfigFilePath).Replace("%BUILD_TIME_GITHUB_CLIENT_ID_PLACEHOLDER%", $ClientId) | Set-Content $OAuthConfigFilePath -} -else { - Write-Host "ClientId not found at Build-time" -} - -if (![string]::IsNullOrWhitespace($ClientSecret)) { - (Get-Content $OAuthConfigFilePath).Replace("%BUILD_TIME_GITHUB_CLIENT_SECRET_PLACEHOLDER%", $ClientSecret) | Set-Content $OAuthConfigFilePath -} -else { - Write-Host "ClientSecret not found at Build-time" -} - -if ($IsAzurePipelineBuild) { - Copy-Item (Join-Path $env:Build_RootDirectory "build\nuget.config.internal") -Destination (Join-Path $env:Build_RootDirectory "nuget.config") -} - $msbuildPath = &"${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" -latest -prerelease -products * -requires Microsoft.Component.MSBuild -find MSBuild\**\Bin\MSBuild.exe $ErrorActionPreference = "Stop" @@ -84,39 +56,21 @@ $ErrorActionPreference = "Stop" . (Join-Path $env:Build_RootDirectory "build\scripts\CertSignAndInstall.ps1") Try { - $appxmanifestPath = (Join-Path $env:Build_RootDirectory "GitHubExtension\Package.appxmanifest") - - [Reflection.Assembly]::LoadWithPartialName("System.Xml.Linq") - $xIdentity = [System.Xml.Linq.XName]::Get("{http://schemas.microsoft.com/appx/manifest/foundation/windows10}Identity"); - - # Update the appxmanifest - $appxmanifest = [System.Xml.Linq.XDocument]::Load($appxmanifestPath) - $appxmanifest.Root.Element($xIdentity).Attribute("Version").Value = $env:msix_version - $appxmanifest.Save($appxmanifestPath) - - $appxPackageDir = (Join-Path $env:Build_RootDirectory "AppxPackages\$configuration") - $solutionPath = (Join-Path $env:Build_RootDirectory "GitHubExtension.sln") $msbuildArgs = @( ($solutionPath), ("/p:platform="+$platform), ("/p:configuration="+$configuration), ("/restore"), ("/binaryLogger:GitHubExtension.$platform.$configuration.binlog"), - ("/p:AppxPackageOutput=$appxPackageDir\GitHubExtension-$platform.msix"), + ("/p:AppxPackageOutput=$appxPackageDir\GitHubExtension_$configuration" + "_$Version" + "_$platform.msix"), ("/p:AppxPackageSigningEnabled=false"), - ("/p:GenerateAppxPackageOnBuild=true"), - ("/p:BuildRing=$buildRing") + ("/p:GenerateAppxPackageOnBuild=true") ) & $msbuildPath $msbuildArgs if (-not($IsAzurePipelineBuild) -And $isAdmin) { - Invoke-SignPackage "$appxPackageDir\GitHubExtension-$platform.msix" + Invoke-SignPackage "$appxPackageDir\GitHubExtension_$configuration" + "_$Version" + "_$platform.msix" } - - # Reset the appxmanifest to prevent unnecessary code changes - $appxmanifest = [System.Xml.Linq.XDocument]::Load($appxmanifestPath) - $appxmanifest.Root.Element($xIdentity).Attribute("Version").Value = "0.0.0.0" - $appxmanifest.Save($appxmanifestPath) } Catch { $formatString = "`n{0}`n`n{1}`n`n" $fields = $_, $_.ScriptStackTrace diff --git a/build/scripts/Test.ps1 b/build/scripts/Test.ps1 index 24f3812..ddc47c5 100644 --- a/build/scripts/Test.ps1 +++ b/build/scripts/Test.ps1 @@ -45,55 +45,17 @@ $vstestPath = &"${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhe $ErrorActionPreference = "Stop" -$isInstalled = Get-ChildItem HKLM:\SOFTWARE\$_\Microsoft\Windows\CurrentVersion\Uninstall\ | ? {($_.GetValue("DisplayName")) -like "*Windows Application Driver*"} - -if (-not($IsAzurePipelineBuild)) { - if ($isInstalled){ - Write-Host "WinAppDriver is already installed on this computer." - } - else { - Write-Host "WinAppDriver will be installed in the background." - $url = "https://github.com/microsoft/WinAppDriver/releases/download/v1.2.99/WindowsApplicationDriver-1.2.99-win-x64.exe" - $outpath = "$env:Build_SourcesDirectory\temp" - Invoke-WebRequest -Uri $url -OutFile "$env:Build_SourcesDirectory\temp\WinAppDriverx64.exe" - - Start-Process -Wait -Filepath $env:Build_SourcesDirectory\WinAppDriverx64.exe -ArgumentList "/S" -PassThru - } - - start-Process -FilePath "C:\Program Files\Windows Application Driver\WinAppDriver.exe" -} - Try { foreach ($platform in $env:Build_Platform.Split(",")) { foreach ($configuration in $env:Build_Configuration.Split(",")) { - # TODO: UI tests are currently disabled in pipeline until signing is solved - if (-not($IsAzurePipelineBuild)) { - $Package = Get-AppPackage "GitHubExtension" - if ($Package) { - Write-Host "Uninstalling old GitHubExtension" - Remove-AppPackage -Package $Package.PackageFullName - } - Write-Host "Installing GitHubExtension" - Add-AppPackage "AppxPackages\$platform\$configuration\GitHubExtension.msix" - } - $vstestArgs = @( ("/Platform:$platform"), ("/Logger:trx;LogFileName=GitHubExtension.Test-$platform-$configuration.trx"), - ("/TestCaseFilter:""TestCategory=Unit"""), + ("/TestCaseFilter:""TestCategory!=LiveData"""), ("BuildOutput\$configuration\$platform\GitHubExtension.Test\GitHubExtension.Test.dll") ) - $winAppTestArgs = @( - ("/Platform:$platform"), - ("/Logger:trx;LogFileName=GitHubExtension.UITest-$platform-$configuration.trx"), - ("BuildOutput\$configuration\$platform\GitHubExtension.UITest\GitHubExtension.UITest.dll") - ) & $vstestPath $vstestArgs - # TODO: UI tests are currently disabled in pipeline until signing is solved - if (-not($IsAzurePipelineBuild)) { - & $vstestPath $winAppTestArgs - } } } } Catch { @@ -103,10 +65,6 @@ Try { Exit 1 } -if (-not($IsAzurePipelineBuild)) { - Stop-Process -Name "WinAppDriver" -} - $TotalTime = (Get-Date)-$StartTime $TotalMinutes = [math]::Floor($TotalTime.TotalMinutes) $TotalSeconds = [math]::Ceiling($TotalTime.TotalSeconds)