1
0
Форкнуть 0

Adding and updating powershell scripts to build and test

This commit is contained in:
kartang 2016-05-05 17:59:17 -07:00
Родитель 734613f550
Коммит ddd4d47ea7
2 изменённых файлов: 103 добавлений и 57 удалений

Просмотреть файл

@ -3,11 +3,12 @@ $VerbosePreference = "Continue";
$TestProjects = @(
'.\test\Microsoft.ApplicationInsights.AspNetCore.Tests',
'.\test\Mvc6Framework45.FunctionalTests',
'.\test\WebApiShimFw46.FunctionalTests'
'.\test\MVCFramework45.FunctionalTests',
'.\test\WebApiShimFw46.FunctionalTests',
'.\test\EmptyApp.FunctionalTests'
)
Function Execute-DnxProcess {
Function Execute-DotnetProcess {
Param (
[Parameter(Mandatory=$True)]
[String]$RuntimePath,
@ -18,7 +19,7 @@ Function Execute-DnxProcess {
)
$pinfo = New-Object System.Diagnostics.ProcessStartInfo;
$pinfo.FileName = $dnxPath;
$pinfo.FileName = $dotnetPath;
$pinfo.RedirectStandardOutput = $true;
$pinfo.UseShellExecute = $false;
$pinfo.Arguments = $arguments;
@ -38,63 +39,29 @@ Function Execute-DnxProcess {
};
}
Function Get-DnxRuntimePaths {
[String]$runtimesRoot = [System.Environment]::ExpandEnvironmentVariables(
'%USERPROFILE%\.dnx\runtimes');
Write-Verbose "Start discovering DNX runtimes, rutimeRoot:$runtimesRoot";
[string[]]$results = @();
# lists folders only
Get-ChildItem $runtimesRoot | ?{ $_.PSIsContainer } |%{
$runtimePath = """$runtimesRoot\$($_.Name)\bin\dnx.exe""";
Write-Verbose "DNX runtime path discovered, path:$runtimePath";
$results += $runtimePath;
};
Write-Verbose "Stop discovering DNX runtimes";
Return $results;
}
[PSObject[]]$global:failed = @();
$global:WorkingDirectory = (pwd).Path;
$dnxRuntimePaths = Get-DnxRuntimePaths;
$dotnetPath = "C:\Program Files\dotnet\dotnet.exe";
If ($dnxRuntimePaths.Count -ne 4){
Throw "Unexpected number of DNX runtimes were discovered, $($dnxRuntimePaths.Count)";
}
$dnxRuntimePaths |% {
$dnxPath = $_;
$TestProjects |% {
[String]$arguments = "test";
[String]$currentWorkingDirectory = Join-Path $global:WorkingDirectory -ChildPath $_;
Write-Host "=========================================================";
Write-Host "== Executing tests";
Write-Host "== Working Folder: $currentWorkingDirectory";
Write-Host "== Runtime:$dnxPath";
Write-Host "== Args:$arguments";
Write-Host "=========================================================";
$executeResult = Execute-DnxProcess `
-RuntimePath $dnxPath `
-Arguments $arguments `
-WorkingDirectory $currentWorkingDirectory;
Write-Host "Test process executed, ExitCode:$($executeResult.ExitCode)";
Write-Host "Output:";
Write-Host $executeResult.Output;
If ($executeResult.ExitCode -ne 0) {
$global:failed += $executeResult;
}
$TestProjects |% {
[String]$arguments = "test";
[String]$currentWorkingDirectory = Join-Path $global:WorkingDirectory -ChildPath $_;
Write-Host "=========================================================";
Write-Host "== Executing tests";
Write-Host "== Working Folder: $currentWorkingDirectory";
Write-Host "== Runtime:$dotnetPath";
Write-Host "== Args:$arguments";
Write-Host "=========================================================";
$executeResult = Execute-DotnetProcess `
-RuntimePath $dotnetPath `
-Arguments $arguments `
-WorkingDirectory $currentWorkingDirectory;
Write-Host "Test process executed, ExitCode:$($executeResult.ExitCode)";
Write-Host "Output:";
Write-Host $executeResult.Output;
If ($executeResult.ExitCode -ne 0) {
$global:failed += $executeResult;
}
}

79
build.ps1 Normal file
Просмотреть файл

@ -0,0 +1,79 @@
#enable verbose mode
$VerbosePreference = "Continue";
$Projects = @(
'.\src\Microsoft.ApplicationInsights.AspNetCore',
'.\test\Microsoft.ApplicationInsights.AspNetCore.Tests',
'.\test\MVCFramework45.FunctionalTests',
'.\test\WebApiShimFw46.FunctionalTests',
'.\test\EmptyApp.FunctionalTests'
)
$Commands = @(
'restore',
'build',
'-v pack'
)
Function Execute-DotnetProcess {
Param (
[Parameter(Mandatory=$True)]
[String]$RuntimePath,
[Parameter(Mandatory=$True)]
[String]$Arguments,
[Parameter(Mandatory=$True)]
[String]$WorkingDirectory
)
$pinfo = New-Object System.Diagnostics.ProcessStartInfo;
$pinfo.FileName = $dotnetPath;
$pinfo.RedirectStandardOutput = $true;
$pinfo.UseShellExecute = $false;
$pinfo.Arguments = $arguments;
$pinfo.WorkingDirectory = $WorkingDirectory;
$p = New-Object System.Diagnostics.Process;
$p.StartInfo = $pinfo;
$p.Start() | Out-Null;
$p.WaitForExit();
Return New-Object PSObject -Property @{
RuntimePath = [String]$RuntimePath;
Arguments = [String]$Arguments;
WorkingDirectory = [String]$WorkingDirectory;
Output = [String]$p.StandardOutput.ReadToEnd();
ExitCode = [int]$p.ExitCode;
};
}
[PSObject[]]$global:failed = @();
$global:WorkingDirectory = (pwd).Path;
$dotnetPath = "C:\Program Files\dotnet\dotnet.exe";
$Projects |% {
[String]$currentWorkingDirectory = Join-Path $global:WorkingDirectory -ChildPath $_;
$Commands |% {
$command = $_;
Write-Host "=========================================================";
Write-Host "== Executing tests";
Write-Host "== Working Folder: $currentWorkingDirectory";
Write-Host "== Runtime:$dotnetPath";
Write-Host "== Args:$command";
Write-Host "=========================================================";
$executeResult = Execute-DotnetProcess `
-RuntimePath $dotnetPath `
-Arguments $arguments `
-WorkingDirectory $currentWorkingDirectory;
Write-Host "Test process executed, ExitCode:$($executeResult.ExitCode)";
Write-Host "Output:";
Write-Host $executeResult.Output;
If ($executeResult.ExitCode -ne 0) {
$global:failed += $executeResult;
}
}
}
If ($global:failed.Count -gt 0) {
Throw "Test execution failed";
}