2016-01-06 02:27:16 -08: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.
#
. " $PSScriptRoot \..\common\_common.ps1 "
2016-01-12 08:46:33 -08:00
$TestPackagesPath = " $RepoRoot \artifacts\tests\package-command-test\packages "
2016-01-06 02:27:16 -08:00
2016-01-10 23:06:02 -08:00
if ( ( Test-Path $TestPackagesPath ) -eq 0 )
{
mkdir $TestPackagesPath ;
}
2016-01-06 02:27:16 -08:00
" v1 " , " v2 " |
foreach {
2016-01-10 21:44:30 -08:00
dotnet pack " $RepoRoot \test\PackagedCommands\Commands\dotnet-hello\ $_ \dotnet-hello "
2016-01-10 23:06:02 -08:00
cp " $RepoRoot \test\PackagedCommands\Commands\dotnet-hello\ $_ \dotnet-hello\bin\Debug\*.nupkg " -Destination $TestPackagesPath
2016-01-06 02:27:16 -08:00
if ( ! $ ? ) {
error " Command failed: dotnet pack "
Exit 1
}
}
# workaround for dotnet-restore from the root failing for these tests since their dependencies aren't built yet
dir " $RepoRoot \test\PackagedCommands\Consumers " | where { $_ . PsIsContainer } |
foreach {
pushd " $RepoRoot \test\PackagedCommands\Consumers\ $_ "
copy project . json . template project . json
popd
}
#restore test projects
pushd " $RepoRoot \test\PackagedCommands\Consumers "
2016-01-12 16:36:31 -08:00
dotnet restore -s " $TestPackagesPath "
2016-01-06 02:27:16 -08:00
if ( ! $ ? ) {
error " Command failed: dotnet restore "
Exit 1
}
popd
#compile apps
dir " $RepoRoot \test\PackagedCommands\Consumers " | where { $_ . PsIsContainer } | where { $_ . Name . Contains ( " Direct " ) } |
foreach {
pushd " $RepoRoot \test\PackagedCommands\Consumers\ $_ "
dotnet compile
popd
}
#run test
dir " $RepoRoot \test\PackagedCommands\Consumers " | where { $_ . PsIsContainer } | where { $_ . Name . Contains ( " AppWith " ) } |
foreach {
$testName = " test\PackagedCommands\Consumers\ $_ "
pushd " $RepoRoot \ $testName "
$outputArray = dotnet hello | Out-String
2016-01-09 18:04:13 -08:00
$output = [ string ] :: Join ( '\n' , $outputArray ) . Trim ( " `r " , " `n " )
2016-01-06 02:27:16 -08:00
del " project.json "
if ( $output -ne " hello " ) {
error " Test Failed: $testName \dotnet hello "
error " printed $output "
Exit 1
}
info " Test passed: $testName "
popd
}
2016-01-12 08:46:33 -08:00
Exit 0