1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-12-14 11:23:42 +02:00
Sonarr/build.ps1

93 lines
2.3 KiB
PowerShell
Raw Normal View History

param (
[switch]$runTests = $false
)
$msBuild = 'C:\Windows\Microsoft.NET\Framework64\v4.0.30319\msbuild.exe'
$outputFolder = '.\_output'
2013-05-12 04:32:03 +03:00
$testSearchPattern = '*.Test\bin\x86\Release'
$testPackageFolder = '.\_tests\'
Function Build()
{
$clean = $msbuild + " nzbdrone.sln /t:Clean /m"
2013-05-12 04:32:03 +03:00
$build = $msbuild + " nzbdrone.sln /p:Configuration=Release /p:Platform=x86 /t:Build /m"
if(Test-Path $outputFolder)
{
Remove-Item -Recurse -Force $outputFolder -ErrorAction Continue
}
Invoke-Expression $clean
Invoke-Expression $build
2013-05-12 04:32:03 +03:00
CleanFolder $outputFolder
}
2013-05-12 04:32:03 +03:00
Function CleanFolder($path)
{
Write-Host Removing XMLDoc files
2013-05-12 04:32:03 +03:00
get-childitem $path -File -Filter *.xml | foreach ($_) {remove-item $_.fullname}
Write-Host Removing FluentValidation.Resources files
get-childitem $path -File -Filter FluentValidation.resources.dll -recurse | foreach ($_) {remove-item $_.fullname}
get-childitem $path -File -Filter app.config | foreach ($_) {remove-item $_.fullname}
2013-05-12 04:32:03 +03:00
Write-Host Removing Empty folders
2013-05-16 07:55:15 +03: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 04:32:03 +03:00
}
}
2013-05-12 04:32:03 +03:00
Function PackageTests()
{
Write-Host Packagin Tests
if(Test-Path $testPackageFolder)
{
Remove-Item -Recurse -Force $testPackageFolder -ErrorAction Continue
}
Get-ChildItem -Recurse -Directory | Where-Object {$_.FullName -like $testSearchPattern} | foreach($_){
Copy-Item -Recurse ($_.FullName + "\*") $testPackageFolder -ErrorAction Ignore
}
CleanFolder $testPackageFolder
get-childitem $testPackageFolder -File -Filter *log.config | foreach ($_) {remove-item $_.fullname}
2013-05-12 04:32:03 +03:00
}
2013-05-16 03:33:27 +03:00
Function Nunit()
{
$testFiles
get-childitem $testPackageFolder -File -Filter *test.dll | foreach ($_) {
$testFiles = $testFiles + $_.FullName + " "
}
$nunitExe = '.\Libraries\nunit\nunit-console-x86.exe ' + $testFiles + ' /process:multiple /noxml'
Invoke-Expression $nunitExe
2013-05-16 03:33:27 +03:00
}
2013-05-16 07:55:15 +03:00
Function RunGrunt()
2013-05-16 03:33:27 +03:00
{
2013-05-16 07:55:15 +03:00
$npmInstall = 'npm install'
$gruntPackage = 'grunt package'
Invoke-Expression $npmInstall
Invoke-Expression $gruntPackage
2013-05-16 03:33:27 +03:00
}
Build
2013-05-16 07:55:15 +03:00
RunGrunt
2013-05-16 03:33:27 +03:00
PackageTests
if($runTests)
{
Nunit
}