2020-01-26 13:37:54 +07:00
|
|
|
if (!$args[0])
|
|
|
|
{
|
|
|
|
throw "Must supply dotnet version argument"
|
|
|
|
}
|
|
|
|
|
2020-09-03 01:11:56 +07:00
|
|
|
if (-Not (Test-Path "../nuget.config"))
|
|
|
|
{
|
|
|
|
throw "nuget file not generated correctly"
|
|
|
|
}
|
|
|
|
|
2020-01-26 13:37:54 +07:00
|
|
|
$dotnet = Get-Command dotnet | Select-Object -First 1 | ForEach-Object { $_.Path }
|
|
|
|
Write-Host "Found '$dotnet'"
|
|
|
|
|
|
|
|
$version = & $dotnet --version | Out-String | ForEach-Object { $_.Trim() }
|
|
|
|
Write-Host "Version $version"
|
2020-09-15 23:36:09 +07:00
|
|
|
if ($version -ne $args[0])
|
|
|
|
{
|
|
|
|
Write-Host "PATH='$env:path'"
|
|
|
|
throw "Unexpected version"
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($args[1])
|
|
|
|
{
|
|
|
|
# SDKs are listed on multiple lines with the path afterwards in square brackets
|
|
|
|
$version = & $dotnet --list-sdks | ForEach-Object { $_.SubString(0, $_.IndexOf('[')).Trim() }
|
|
|
|
Write-Host "Version $version"
|
|
|
|
if (-not ($version -contains $args[1]))
|
|
|
|
{
|
|
|
|
Write-Host "PATH='$env:path'"
|
|
|
|
throw "Unexpected version"
|
|
|
|
}
|
|
|
|
}
|
2020-01-26 13:37:54 +07:00
|
|
|
|
|
|
|
Write-Host "Building sample csproj"
|
|
|
|
& $dotnet build __tests__/sample-csproj/ --no-cache
|
|
|
|
if ($LASTEXITCODE -ne 0)
|
|
|
|
{
|
|
|
|
throw "Unexpected exit code $LASTEXITCODE"
|
|
|
|
}
|
|
|
|
|
|
|
|
Write-Host "Testing compiled app"
|
2020-09-15 23:36:09 +07:00
|
|
|
$sample_output = "$(dotnet test __tests__/sample-csproj/ --no-build)"
|
2020-01-26 13:37:54 +07:00
|
|
|
Write-Host "Sample output: $sample_output"
|
2020-09-15 23:36:09 +07:00
|
|
|
# For Side-by-Side installs we want to run the tests twice, for a single install the tests will run once
|
|
|
|
if ($args[1])
|
|
|
|
{
|
|
|
|
if ($sample_output -notlike "*Test Run Successful.*Test Run Successful.*")
|
|
|
|
{
|
|
|
|
throw "Unexpected output"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2020-01-26 13:37:54 +07:00
|
|
|
{
|
2020-09-15 23:36:09 +07:00
|
|
|
if ($sample_output -notlike "*Test Run Successful.*")
|
|
|
|
{
|
|
|
|
throw "Unexpected output"
|
|
|
|
}
|
2020-01-26 13:37:54 +07:00
|
|
|
}
|