2020-01-26 14:37:54 +08:00
|
|
|
if (!$args[0])
|
|
|
|
{
|
|
|
|
throw "Must supply dotnet version argument"
|
|
|
|
}
|
|
|
|
|
|
|
|
$dotnet = Get-Command dotnet | Select-Object -First 1 | ForEach-Object { $_.Path }
|
|
|
|
Write-Host "Found '$dotnet'"
|
|
|
|
|
2021-11-23 18:03:56 +08:00
|
|
|
if($args.count -eq 1)
|
2020-09-16 00:36:09 +08:00
|
|
|
{
|
2021-11-23 18:03:56 +08:00
|
|
|
$version = & $dotnet --version | Out-String | ForEach-Object { $_.Trim() }
|
|
|
|
Write-Host "Version $version"
|
|
|
|
if (-not ($version.StartsWith($args[0].ToString())))
|
|
|
|
{
|
|
|
|
Write-Host "PATH='$env:PATH'"
|
|
|
|
throw "Unexpected version"
|
|
|
|
}
|
2020-09-16 00:36:09 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if ($args[1])
|
|
|
|
{
|
|
|
|
# SDKs are listed on multiple lines with the path afterwards in square brackets
|
2021-02-04 17:31:39 +08:00
|
|
|
$versions = & $dotnet --list-sdks | ForEach-Object { $_.SubString(0, $_.IndexOf('[')).Trim() }
|
|
|
|
Write-Host "Installed versions: $versions"
|
2021-11-23 18:03:56 +08:00
|
|
|
$InstalledVersionCount = 0
|
|
|
|
foreach($arg in $args){
|
|
|
|
foreach ($version in $versions)
|
2021-02-04 18:26:18 +08:00
|
|
|
{
|
2021-11-23 18:03:56 +08:00
|
|
|
if ($version.StartsWith($arg.ToString()))
|
|
|
|
{
|
|
|
|
$InstalledVersionCount++
|
|
|
|
}
|
2021-02-04 17:31:39 +08:00
|
|
|
}
|
2021-11-23 18:03:56 +08:00
|
|
|
}
|
|
|
|
if ( $InstalledVersionCount -ne $args.Count)
|
2020-09-16 00:36:09 +08:00
|
|
|
{
|
2021-02-04 17:18:06 +08:00
|
|
|
Write-Host "PATH='$env:PATH'"
|
2020-09-16 00:36:09 +08:00
|
|
|
throw "Unexpected version"
|
|
|
|
}
|
|
|
|
}
|
2020-01-26 14:37:54 +08: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-16 00:36:09 +08:00
|
|
|
$sample_output = "$(dotnet test __tests__/sample-csproj/ --no-build)"
|
2020-01-26 14:37:54 +08:00
|
|
|
Write-Host "Sample output: $sample_output"
|
2020-09-16 00:36:09 +08: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"
|
|
|
|
}
|
|
|
|
}
|
2021-11-23 18:03:56 +08:00
|
|
|
if ($args[2])
|
|
|
|
{
|
|
|
|
if ($sample_output -notlike "*Test Run Successful.*Test Run Successful.*Test Run Successful.*")
|
|
|
|
{
|
|
|
|
throw "Unexpected output"
|
|
|
|
}
|
|
|
|
}
|
2020-09-16 00:36:09 +08:00
|
|
|
else
|
2020-01-26 14:37:54 +08:00
|
|
|
{
|
2020-09-16 00:36:09 +08:00
|
|
|
if ($sample_output -notlike "*Test Run Successful.*")
|
|
|
|
{
|
|
|
|
throw "Unexpected output"
|
|
|
|
}
|
2020-01-26 14:37:54 +08:00
|
|
|
}
|