2015-11-25 01:48:58 +00:00
|
|
|
# Copyright (c) .NET Foundation and contributors. All rights reserved.
|
|
|
|
# Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
|
|
|
|
|
|
param(
|
2015-12-28 19:47:21 +00:00
|
|
|
[Parameter(Mandatory=$true)][string]$inputMsi
|
2015-11-25 01:48:58 +00:00
|
|
|
)
|
|
|
|
|
2015-12-28 19:47:21 +00:00
|
|
|
. "$PSScriptRoot\..\..\scripts\common\_common.ps1"
|
2015-11-25 01:48:58 +00:00
|
|
|
|
2016-02-19 17:06:21 +00:00
|
|
|
$RepoRoot = Convert-Path "$PSScriptRoot\..\.."
|
|
|
|
|
|
|
|
function CopyInstaller([string]$destination)
|
|
|
|
{
|
|
|
|
# Copy both the .msi and the .exe to the testBin directory so
|
|
|
|
# the tests running in the docker container have access to them.
|
|
|
|
Copy-Item $inputMsi -Destination:$destination
|
2016-03-07 17:34:18 +00:00
|
|
|
|
2016-02-19 17:06:21 +00:00
|
|
|
$BundlePath = [System.IO.Path]::ChangeExtension($inputMsi, "exe")
|
|
|
|
Copy-Item $BundlePath -Destination:$destination
|
|
|
|
}
|
|
|
|
|
|
|
|
function CopyTestXUnitRunner([string]$destination)
|
|
|
|
{
|
|
|
|
$XUnitRunnerDir = Join-Path $env:NUGET_PACKAGES xunit.runner.console\2.1.0\tools
|
2016-03-07 17:34:18 +00:00
|
|
|
|
2016-02-19 17:06:21 +00:00
|
|
|
Copy-Item $XUnitRunnerDir\xunit.console.exe -Destination:$destination
|
|
|
|
Copy-Item $XUnitRunnerDir\xunit.runner.utility.desktop.dll -Destination:$destination
|
2015-11-25 01:48:58 +00:00
|
|
|
}
|
|
|
|
|
2016-02-19 17:06:21 +00:00
|
|
|
Write-Host "Running tests for MSI installer at $inputMsi."
|
2015-11-25 01:48:58 +00:00
|
|
|
|
|
|
|
if(!(Test-Path $inputMsi))
|
|
|
|
{
|
|
|
|
throw "$inputMsi not found"
|
|
|
|
}
|
|
|
|
|
2016-02-19 17:06:21 +00:00
|
|
|
$testName = "Microsoft.DotNet.Cli.Msi.Tests"
|
|
|
|
$testDir="$PSScriptRoot\$testName"
|
|
|
|
$testBin="$RepoRoot\artifacts\tests\$testName"
|
2015-11-25 01:48:58 +00:00
|
|
|
|
2016-03-17 00:54:44 +00:00
|
|
|
pushd "$Stage2Dir"
|
2015-11-25 01:48:58 +00:00
|
|
|
|
|
|
|
try {
|
|
|
|
.\dotnet restore `
|
2016-02-09 18:27:03 +00:00
|
|
|
$testDir `
|
2015-11-25 01:48:58 +00:00
|
|
|
-f https://www.myget.org/F/dotnet-buildtools/api/v3/index.json | Out-Host
|
|
|
|
|
|
|
|
if($LastExitCode -ne 0)
|
|
|
|
{
|
|
|
|
throw "dotnet restore failed with exit code $LastExitCode."
|
|
|
|
}
|
|
|
|
|
|
|
|
.\dotnet publish `
|
|
|
|
--framework net46 `
|
|
|
|
--output $testBin `
|
2016-02-09 18:27:03 +00:00
|
|
|
$testDir | Out-Host
|
2015-11-25 01:48:58 +00:00
|
|
|
|
|
|
|
if($LastExitCode -ne 0)
|
|
|
|
{
|
|
|
|
throw "dotnet publish failed with exit code $LastExitCode."
|
|
|
|
}
|
|
|
|
|
2016-02-19 17:06:21 +00:00
|
|
|
if($env:RunInstallerTestsInDocker)
|
2015-11-25 01:48:58 +00:00
|
|
|
{
|
2016-02-19 17:06:21 +00:00
|
|
|
CopyInstaller $testBin
|
|
|
|
CopyTestXUnitRunner $testBin
|
|
|
|
|
|
|
|
Write-Host "Running installer tests in Windows Container"
|
2016-03-07 17:34:18 +00:00
|
|
|
|
2016-02-22 23:15:56 +00:00
|
|
|
# --net="none" works around a networking issue on the containers on the CI machines.
|
|
|
|
# Since our installer tests don't require the network, it is fine to shut it off.
|
2016-02-19 17:06:21 +00:00
|
|
|
$MsiFileName = [System.IO.Path]::GetFileName($inputMsi)
|
|
|
|
docker run `
|
2016-02-22 23:15:56 +00:00
|
|
|
--rm `
|
2016-02-19 17:06:21 +00:00
|
|
|
-v "$testBin\:D:" `
|
|
|
|
-e "CLI_MSI=D:\$MsiFileName" `
|
2016-02-22 23:15:56 +00:00
|
|
|
--net="none" `
|
2016-02-19 17:06:21 +00:00
|
|
|
windowsservercore `
|
|
|
|
D:\xunit.console.exe D:\$testName.dll | Out-Host
|
|
|
|
|
|
|
|
if($LastExitCode -ne 0)
|
|
|
|
{
|
|
|
|
throw "xunit runner failed with exit code $LastExitCode."
|
|
|
|
}
|
2015-11-25 01:48:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
finally {
|
|
|
|
popd
|
|
|
|
}
|
|
|
|
|
|
|
|
Exit 0
|