From 3a7123ebeb09c231e0394358b5b52314618611b1 Mon Sep 17 00:00:00 2001 From: Elvis Shi <45674121+Elvis-Shi@users.noreply.github.com> Date: Tue, 24 Nov 2020 08:20:02 -0800 Subject: [PATCH] Add BizTalk Server project build component to build agent machine. (#1960) * Add BizTalk Project Build components, including msi and vsix. * Add BizTalk Build Components to software report. * Use registry/folder check replace actually BizTalk Project building for testing purpose. * Remove unnecessary try/catch. * Make sure BizTalk related software report only for Windows 2019 OS. * Add statement to make sure BizTalk test only invoked in Win19 env. * Fix test failue when no test runs use "skip" * Update the TestName to be identity to BizTalk.Test.ps1 --- .../Install-BizTalkBuildComponent.ps1 | 83 +++++++++++++++++++ .../SoftwareReport/SoftwareReport.Common.psm1 | 5 ++ .../SoftwareReport.Generator.ps1 | 9 ++ images/win/scripts/Tests/BizTalk.Tests.ps1 | 19 +++++ images/win/toolsets/toolset-2019.json | 5 ++ images/win/windows2019.json | 6 ++ 6 files changed, 127 insertions(+) create mode 100644 images/win/scripts/Installers/Install-BizTalkBuildComponent.ps1 create mode 100644 images/win/scripts/Tests/BizTalk.Tests.ps1 diff --git a/images/win/scripts/Installers/Install-BizTalkBuildComponent.ps1 b/images/win/scripts/Installers/Install-BizTalkBuildComponent.ps1 new file mode 100644 index 000000000..8f4462961 --- /dev/null +++ b/images/win/scripts/Installers/Install-BizTalkBuildComponent.ps1 @@ -0,0 +1,83 @@ +################################################################################ +## File: Install-BizTalkBuildComponent.ps1 +## Desc: Install BizTalk Project Build Component +################################################################################ + +function Install-Msi +{ + <# + .SYNOPSIS + A helper function to install executables. + + .DESCRIPTION + install .exe or .msi binaries from specified Path. + + .PARAMETER MsiPath + Msi or exe path. Required parameter. + + .PARAMETER LogPath + The log file path where installation will write log to. Required parameter. + + .EXAMPLE + Install-Msi -MsiPath "c:\temp\abc.msi" -LogPath "c:\abc.log" + #> + + Param + ( + [Parameter(Mandatory)] + [String] $MsiPath, + [Parameter(Mandatory)] + [String] $LogPath + ) + + try + { + $filePath = "msiexec.exe" + + Write-Host "Starting Install $MsiPath..." + $ArgumentList = ('/i', $MsiPath, '/QN', '/norestart', "/l*v",$LogPath) + $process = Start-Process -FilePath $filePath -ArgumentList $ArgumentList -Wait -PassThru -Verb runAs + + $exitCode = $process.ExitCode + if ($exitCode -eq 0 -or $exitCode -eq 3010) + { + Write-Host "Installation for $MsiPath is successful." + } + else + { + Write-Host "Non zero exit code returned by $MsiPath installation process: $exitCode" + Get-Content $LogPath | Write-Host + exit $exitCode + } + } + catch + { + Write-Host "Failed to install $MsiPath : $($_.Exception.Message)" + exit 1 + } +} + +$bizTalkBuildComponentUri = "https://aka.ms/BuildComponentSetup.EN" + +# Download +Write-Host "BizTalk Project Build Component download..." +$setupZipFile = Start-DownloadWithRetry -Url $bizTalkBuildComponentUri -Name "BuildComponentSetup.EN.zip" + +# Unzip +$setupPath = "C:\BizTalkBuildComponent" +if (-not (Test-Path -Path $setupPath)) { + $null = New-Item -Path $setupPath -ItemType Directory -Force +} + +Write-Host "Unzip $setupZipFile to $setupPath..." +Extract-7Zip -Path $setupZipFile -DestinationPath $setupPath +Remove-Item $setupZipFile + +# Install +Install-Msi -MsiPath "$setupPath\Bootstrap.msi" -LogPath "$setupPath\bootstrap.log" +Install-Msi -MsiPath "$setupPath\BuildComponentSetup.msi" -LogPath "$setupPath\buildComponentSetup.log" + +Remove-Item $setupPath -Recurse -Force + +# Test +Invoke-PesterTests -TestFile "BizTalk" -TestName "BizTalk Build Component Setup" \ No newline at end of file diff --git a/images/win/scripts/SoftwareReport/SoftwareReport.Common.psm1 b/images/win/scripts/SoftwareReport/SoftwareReport.Common.psm1 index be9603f62..adf6bb37c 100644 --- a/images/win/scripts/SoftwareReport/SoftwareReport.Common.psm1 +++ b/images/win/scripts/SoftwareReport/SoftwareReport.Common.psm1 @@ -286,6 +286,11 @@ function Get-YAMLLintVersion { yamllint --version } +function Get-BizTalkVersion { + $bizTalkReg = Get-ItemProperty "HKLM:\SOFTWARE\WOW6432Node\Microsoft\BizTalk Server\3.0" + return "- $($bizTalkReg.ProductName) $($bizTalkReg.ProductVersion) " +} + function Get-PipxVersion { $pipxVersion = pipx --version return "Pipx $pipxVersion" diff --git a/images/win/scripts/SoftwareReport/SoftwareReport.Generator.ps1 b/images/win/scripts/SoftwareReport/SoftwareReport.Generator.ps1 index 9918a606b..d7589d94e 100644 --- a/images/win/scripts/SoftwareReport/SoftwareReport.Generator.ps1 +++ b/images/win/scripts/SoftwareReport/SoftwareReport.Generator.ps1 @@ -139,6 +139,15 @@ $markdown += New-MDList -Style Unordered -Lines @( $markdown += New-MDHeader "MSYS2" -Level 3 $markdown += Get-PacmanVersion $markdown += New-MDNewLine + +if(Test-IsWin19) +{ + $markdown += New-MDHeader "BizTalk Server" -Level 3 + $markdown += Get-BizTalkVersion + $markdown += New-MDNewLine +} + +$markdown += New-MDHeader "Notes:" -Level 5 $markdown += @' ``` Location: C:\msys64 diff --git a/images/win/scripts/Tests/BizTalk.Tests.ps1 b/images/win/scripts/Tests/BizTalk.Tests.ps1 new file mode 100644 index 000000000..efe792162 --- /dev/null +++ b/images/win/scripts/Tests/BizTalk.Tests.ps1 @@ -0,0 +1,19 @@ +################################################################################ +## File: BizTalk.Tests.ps1 +## Desc: Test BizTalk project build component installed. +################################################################################ + +Describe "BizTalk Build Component Setup" -Skip:(Test-IsWin16) { + It "BizTalk Registry Check" { + Test-Path "HKLM:\SOFTWARE\WOW6432Node\Microsoft\BizTalk Server\3.0" | Should -BeTrue + } + + It "BizTalk Folder Check" { + "${env:ProgramFiles(x86)}\Microsoft BizTalk Server" | Should -Exist + } + + It "BizTalk Build Targets files Check" { + "${env:ProgramFiles(x86)}\MSBuild\Microsoft\BizTalk\BizTalkC.targets" | Should -Exist + "${env:ProgramFiles(x86)}\MSBuild\Microsoft\BizTalk\BizTalkCommon.targets" | Should -Exist + } +} \ No newline at end of file diff --git a/images/win/toolsets/toolset-2019.json b/images/win/toolsets/toolset-2019.json index 717256141..2cabda472 100644 --- a/images/win/toolsets/toolset-2019.json +++ b/images/win/toolsets/toolset-2019.json @@ -281,6 +281,11 @@ "name": "Microsoft.VisualStudio.Installer.Projects.vsix", "url": "https://marketplace.visualstudio.com/_apis/public/gallery/publishers/VisualStudioClient/vsextensions/MicrosoftVisualStudio2017InstallerProjects/latest/vspackage", "id": "VSInstallerProjects" + }, + { + "name": "BizTalkVsix.vsix", + "url": "https://marketplace.visualstudio.com/_apis/public/gallery/publishers/ms-biztalk/vsextensions/BizTalk/3.13.2.0/vspackage", + "id": "BizTalkProjectSystem.BD1D0FA0-E48A-4270-995F-F110DD9F7838" } ] }, diff --git a/images/win/windows2019.json b/images/win/windows2019.json index c1c19073f..43567f368 100644 --- a/images/win/windows2019.json +++ b/images/win/windows2019.json @@ -313,6 +313,12 @@ "{{ template_dir }}/scripts/Installers/Install-CodeQLBundle.ps1" ] }, + { + "type": "powershell", + "scripts": [ + "{{ template_dir }}/scripts/Installers/Install-BizTalkBuildComponent.ps1" + ] + }, { "type": "powershell", "scripts": [