2013-05-12 07:38:00 +02:00
|
|
|
param (
|
|
|
|
[switch]$runTests = $false
|
|
|
|
)
|
|
|
|
|
2013-03-29 01:12:40 +01:00
|
|
|
$msBuild = 'C:\Windows\Microsoft.NET\Framework64\v4.0.30319\msbuild.exe'
|
|
|
|
$outputFolder = '.\_output'
|
2013-05-12 03:32:03 +02:00
|
|
|
$testSearchPattern = '*.Test\bin\x86\Release'
|
|
|
|
$testPackageFolder = '.\_tests\'
|
2013-03-29 01:12:40 +01:00
|
|
|
|
|
|
|
Function Build()
|
|
|
|
{
|
|
|
|
$clean = $msbuild + " nzbdrone.sln /t:Clean /m"
|
2013-05-12 03:32:03 +02:00
|
|
|
$build = $msbuild + " nzbdrone.sln /p:Configuration=Release /p:Platform=x86 /t:Build /m"
|
2013-07-06 01:12:52 +02:00
|
|
|
|
|
|
|
|
2013-03-29 01:12:40 +01:00
|
|
|
|
|
|
|
if(Test-Path $outputFolder)
|
|
|
|
{
|
|
|
|
Remove-Item -Recurse -Force $outputFolder -ErrorAction Continue
|
|
|
|
}
|
|
|
|
|
|
|
|
Invoke-Expression $clean
|
2013-07-06 01:12:52 +02:00
|
|
|
CheckExitCode
|
|
|
|
|
2013-03-29 01:12:40 +01:00
|
|
|
Invoke-Expression $build
|
2013-07-06 01:12:52 +02:00
|
|
|
CheckExitCode
|
|
|
|
|
2013-05-12 03:32:03 +02:00
|
|
|
CleanFolder $outputFolder
|
2013-08-06 00:49:41 +02:00
|
|
|
|
|
|
|
AddJsonNet
|
2013-03-29 01:12:40 +01:00
|
|
|
}
|
|
|
|
|
2013-05-12 03:32:03 +02:00
|
|
|
Function CleanFolder($path)
|
2013-03-29 01:12:40 +01:00
|
|
|
{
|
|
|
|
Write-Host Removing XMLDoc files
|
2013-05-20 02:01:20 +02:00
|
|
|
get-childitem $path -File -Filter *.xml -Recurse | foreach ($_) {remove-item $_.fullname}
|
2013-05-12 03:32:03 +02:00
|
|
|
|
2013-07-25 21:18:14 +02:00
|
|
|
get-childitem $path -File -Filter *.transform -Recurse | foreach ($_) {remove-item $_.fullname}
|
|
|
|
|
2013-08-06 00:49:41 +02:00
|
|
|
get-childitem $path -File -Filter Newtonsoft.Json.* -Recurse | foreach ($_) {remove-item $_.fullname}
|
|
|
|
|
2013-05-12 03:32:03 +02:00
|
|
|
Write-Host Removing FluentValidation.Resources files
|
|
|
|
get-childitem $path -File -Filter FluentValidation.resources.dll -recurse | foreach ($_) {remove-item $_.fullname}
|
2013-05-12 07:38:00 +02:00
|
|
|
|
2013-05-20 02:01:20 +02:00
|
|
|
get-childitem $path -File -Filter app.config -Recurse | foreach ($_) {remove-item $_.fullname}
|
2013-05-12 03:32:03 +02:00
|
|
|
|
|
|
|
Write-Host Removing Empty folders
|
2013-05-16 06:55:15 +02:00
|
|
|
while (Get-ChildItem $path -recurse | where {!@(Get-ChildItem -force $_.fullname)} | Test-Path)
|
|
|
|
{
|
|
|
|
Get-ChildItem $path -Directory -recurse | where {!@(Get-ChildItem -force $_.fullname)} | Remove-Item
|
2013-05-12 03:32:03 +02:00
|
|
|
}
|
2013-03-29 01:12:40 +01:00
|
|
|
}
|
|
|
|
|
2013-08-06 00:49:41 +02:00
|
|
|
|
|
|
|
Function AddJsonNet()
|
|
|
|
{
|
2013-08-06 01:11:37 +02:00
|
|
|
Copy-Item .\packages\Newtonsoft.Json.5.*\lib\net35\*.* -Destination $outputFolder
|
2013-08-06 00:49:41 +02:00
|
|
|
}
|
|
|
|
|
2013-05-12 03:32:03 +02:00
|
|
|
Function PackageTests()
|
|
|
|
{
|
2013-07-06 01:12:52 +02:00
|
|
|
Write-Host Packaging Tests
|
2013-05-12 03:32:03 +02:00
|
|
|
|
2013-08-06 01:11:37 +02:00
|
|
|
if(Test-Path $testPackageFolder)
|
2013-05-12 03:32:03 +02:00
|
|
|
{
|
|
|
|
Remove-Item -Recurse -Force $testPackageFolder -ErrorAction Continue
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Get-ChildItem -Recurse -Directory | Where-Object {$_.FullName -like $testSearchPattern} | foreach($_){
|
|
|
|
Copy-Item -Recurse ($_.FullName + "\*") $testPackageFolder -ErrorAction Ignore
|
|
|
|
}
|
|
|
|
|
2013-08-06 01:11:37 +02:00
|
|
|
|
2013-05-12 03:32:03 +02:00
|
|
|
CleanFolder $testPackageFolder
|
2013-05-12 07:38:00 +02:00
|
|
|
|
2013-08-06 01:11:37 +02:00
|
|
|
Copy-Item $outputFolder\*.dll -Destination $testPackageFolder -Force
|
|
|
|
Copy-Item $outputFolder\*.pdb -Destination $testPackageFolder -Force
|
2013-05-12 07:38:00 +02:00
|
|
|
|
2013-08-06 01:11:37 +02:00
|
|
|
get-childitem $testPackageFolder -File -Filter *log.config | foreach ($_) {remove-item $_.fullname}
|
2013-05-12 03:32:03 +02:00
|
|
|
}
|
2013-03-29 01:12:40 +01:00
|
|
|
|
2013-05-16 02:33:27 +02:00
|
|
|
Function Nunit()
|
2013-05-12 07:38:00 +02:00
|
|
|
{
|
|
|
|
$testFiles
|
|
|
|
|
|
|
|
get-childitem $testPackageFolder -File -Filter *test.dll | foreach ($_) {
|
|
|
|
$testFiles = $testFiles + $_.FullName + " "
|
|
|
|
}
|
|
|
|
|
2013-08-06 01:11:37 +02:00
|
|
|
$nunitExe = '.\Libraries\nunit\nunit-console-x86.exe ' + $testFiles + ' /process:multiple /noxml'
|
|
|
|
Invoke-Expression $nunitExe
|
|
|
|
CheckExitCode
|
2013-05-16 02:33:27 +02:00
|
|
|
}
|
|
|
|
|
2013-05-16 06:55:15 +02:00
|
|
|
Function RunGrunt()
|
2013-05-16 02:33:27 +02:00
|
|
|
{
|
2013-05-16 22:49:16 +02:00
|
|
|
$gruntPath = [environment]::getfolderpath("applicationdata") + '\npm\node_modules\grunt-cli\bin\grunt'
|
2013-05-20 02:30:02 +02:00
|
|
|
Invoke-Expression 'npm install'
|
2013-07-06 01:12:52 +02:00
|
|
|
CheckExitCode
|
2013-05-16 22:49:16 +02:00
|
|
|
|
2013-05-20 02:30:02 +02:00
|
|
|
Invoke-Expression ('node ' + $gruntPath + ' package')
|
2013-07-06 01:12:52 +02:00
|
|
|
CheckExitCode
|
|
|
|
}
|
|
|
|
|
|
|
|
Function CheckExitCode()
|
|
|
|
{
|
|
|
|
if ($lastexitcode -ne 0)
|
|
|
|
{
|
|
|
|
Write-Host $errorMessage
|
|
|
|
exit 1
|
|
|
|
}
|
2013-05-16 02:33:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
Build
|
2013-08-06 07:59:06 +02:00
|
|
|
RunGrunt
|
2013-05-16 02:33:27 +02:00
|
|
|
PackageTests
|
|
|
|
|
|
|
|
if($runTests)
|
|
|
|
{
|
|
|
|
Nunit
|
2013-07-06 01:12:52 +02:00
|
|
|
}
|