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(
|
2016-06-28 01:26:57 +00:00
|
|
|
[string]$InputMsi,
|
2017-08-15 00:42:07 +00:00
|
|
|
[string]$DotnetDir,
|
|
|
|
[string]$TestDir
|
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
|
|
|
}
|
|
|
|
|
2017-05-26 22:46:56 +00:00
|
|
|
Write-Output "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"
|
2016-11-16 02:12:19 +00:00
|
|
|
$testProj="$PSScriptRoot\$testName\$testName.csproj"
|
2017-08-15 00:42:07 +00:00
|
|
|
$testBin="$TestDir\$testName"
|
2015-11-25 01:48:58 +00:00
|
|
|
|
2016-06-28 01:26:57 +00:00
|
|
|
pushd "$DotnetDir"
|
2015-11-25 01:48:58 +00:00
|
|
|
|
|
|
|
try {
|
|
|
|
.\dotnet restore `
|
2016-11-16 02:12:19 +00:00
|
|
|
$testProj | Out-Host
|
2015-11-25 01:48:58 +00:00
|
|
|
|
|
|
|
if($LastExitCode -ne 0)
|
|
|
|
{
|
|
|
|
throw "dotnet restore failed with exit code $LastExitCode."
|
|
|
|
}
|
|
|
|
|
|
|
|
.\dotnet publish `
|
|
|
|
--framework net46 `
|
|
|
|
--output $testBin `
|
2016-11-16 02:12:19 +00:00
|
|
|
$testProj | 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
|
|
|
|
|
2017-05-26 22:46:56 +00:00
|
|
|
Write-Output "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
|