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
|
|
|
|
|
|
|
function Test-Administrator
|
|
|
|
{
|
|
|
|
$user = [Security.Principal.WindowsIdentity]::GetCurrent();
|
|
|
|
(New-Object Security.Principal.WindowsPrincipal $user).IsInRole([Security.Principal.WindowsBuiltinRole]::Administrator)
|
|
|
|
}
|
|
|
|
|
|
|
|
Write-Host "Running tests for MSI installer at $inputMsi.."
|
|
|
|
|
|
|
|
if(!(Test-Path $inputMsi))
|
|
|
|
{
|
|
|
|
throw "$inputMsi not found"
|
|
|
|
}
|
|
|
|
|
|
|
|
$env:CLI_MSI=$inputMsi
|
2016-02-09 18:27:03 +00:00
|
|
|
$testDir="$PSScriptRoot\Dotnet.Cli.Msi.Tests"
|
2015-11-25 01:48:58 +00:00
|
|
|
$testBin="$RepoRoot\artifacts\tests\Dotnet.Cli.Msi.Tests"
|
|
|
|
$xunitRunner="$env:USERPROFILE\.dnx\packages\xunit.runner.console\2.1.0\tools\xunit.console.exe"
|
|
|
|
|
|
|
|
pushd "$Stage2Dir\bin"
|
|
|
|
|
|
|
|
try {
|
|
|
|
.\dotnet restore `
|
|
|
|
--runtime win-anycpu `
|
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 `
|
|
|
|
--runtime win-anycpu `
|
|
|
|
--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."
|
|
|
|
}
|
|
|
|
<#
|
|
|
|
if(-Not (Test-Administrator))
|
|
|
|
{
|
|
|
|
Write-Host -ForegroundColor Yellow "Current script testmsi.ps1 is not run as admin."
|
|
|
|
Write-Host -ForegroundColor Yellow "Executing MSI tests require admin privileges."
|
|
|
|
Write-Host -ForegroundColor Yellow "Failing silently."
|
|
|
|
Exit 0
|
|
|
|
}
|
|
|
|
|
|
|
|
& $xunitRunner $testBin\Dotnet.Cli.Msi.Tests.exe | Out-Host
|
|
|
|
|
|
|
|
if($LastExitCode -ne 0)
|
|
|
|
{
|
|
|
|
throw "xunit runner failed with exit code $LastExitCode."
|
|
|
|
}
|
|
|
|
#>
|
|
|
|
}
|
|
|
|
finally {
|
|
|
|
popd
|
|
|
|
}
|
|
|
|
|
|
|
|
Exit 0
|