2013-03-28 17:12:40 -07:00
|
|
|
$msBuild = 'C:\Windows\Microsoft.NET\Framework64\v4.0.30319\msbuild.exe'
|
|
|
|
$outputFolder = '.\_output'
|
2013-08-23 17:15:23 -07:00
|
|
|
$outputFolderMono = '.\_output_mono'
|
2014-02-24 17:06:41 -08:00
|
|
|
$outputFolderOsx = '.\_output_osx'
|
2013-08-18 16:31:13 -07:00
|
|
|
$testPackageFolder = '.\_tests\'
|
2013-08-18 17:04:48 -07:00
|
|
|
$testSearchPattern = '*.Test\bin\x86\Release'
|
2013-11-21 08:13:40 -08:00
|
|
|
$sourceFolder = '.\src'
|
2014-01-27 14:38:45 -08:00
|
|
|
$updateFolder = $outputFolder + '\NzbDrone.Update'
|
2014-04-27 23:34:29 -07:00
|
|
|
$updateFolderMono = $outputFolderMono + '\NzbDrone.Update'
|
2013-03-28 17:12:40 -07:00
|
|
|
|
|
|
|
Function Build()
|
|
|
|
{
|
2013-11-13 12:38:57 -08:00
|
|
|
Write-Host "##teamcity[progressStart 'Build']"
|
|
|
|
|
2013-10-02 18:01:32 -07:00
|
|
|
$clean = $msbuild + " src\nzbdrone.sln /t:Clean /m"
|
|
|
|
$build = $msbuild + " src\nzbdrone.sln /p:Configuration=Release /p:Platform=x86 /t:Build /m"
|
2013-07-05 16:12:52 -07:00
|
|
|
|
2013-03-28 17:12:40 -07:00
|
|
|
if(Test-Path $outputFolder)
|
|
|
|
{
|
|
|
|
Remove-Item -Recurse -Force $outputFolder -ErrorAction Continue
|
|
|
|
}
|
|
|
|
|
|
|
|
Invoke-Expression $clean
|
2013-07-05 16:12:52 -07:00
|
|
|
CheckExitCode
|
|
|
|
|
2013-03-28 17:12:40 -07:00
|
|
|
Invoke-Expression $build
|
2013-07-05 16:12:52 -07:00
|
|
|
CheckExitCode
|
|
|
|
|
2013-05-11 18:32:03 -07:00
|
|
|
CleanFolder $outputFolder
|
2013-08-05 15:49:41 -07:00
|
|
|
|
|
|
|
AddJsonNet
|
2013-11-13 12:38:57 -08:00
|
|
|
|
2014-01-14 11:21:20 -08:00
|
|
|
Write-Host "Removing Mono.Posix.dll"
|
|
|
|
Remove-Item "$outputFolder\Mono.Posix.dll"
|
|
|
|
|
2013-11-13 12:38:57 -08:00
|
|
|
Write-Host "##teamcity[progressFinish 'Build']"
|
2013-03-28 17:12:40 -07:00
|
|
|
}
|
|
|
|
|
2014-08-25 19:30:57 -07:00
|
|
|
Function CleanFolder($path, $keepConfigFiles)
|
2013-03-28 17:12:40 -07:00
|
|
|
{
|
|
|
|
Write-Host Removing XMLDoc files
|
2014-08-11 12:41:02 -07:00
|
|
|
get-childitem $path -File -Filter *.xml -Recurse | foreach ($_) {
|
|
|
|
|
|
|
|
$filename = $_.FullName
|
|
|
|
$exeFilename = $filename -replace "xml", "exe"
|
|
|
|
$dllFilename = $filename -replace "xml", "dll"
|
|
|
|
|
|
|
|
if (Test-Path $exeFilename) {
|
|
|
|
remove-item $_.fullname
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Test-Path $dllFilename) {
|
|
|
|
remove-item $_.fullname
|
|
|
|
}
|
|
|
|
}
|
2013-05-11 18:32:03 -07:00
|
|
|
|
2014-01-05 22:20:08 -08:00
|
|
|
get-childitem $path -File -Filter *.transform -Recurse | foreach ($_) {remove-item $_.fullname}
|
2013-08-23 17:15:23 -07:00
|
|
|
|
2014-08-25 19:30:57 -07:00
|
|
|
if($keepConfigFiles -ne $true)
|
|
|
|
{
|
|
|
|
get-childitem $path -File -Filter *.dll.config -Recurse | foreach ($_) {remove-item $_.fullname}
|
|
|
|
}
|
|
|
|
|
2013-05-11 18:32:03 -07:00
|
|
|
Write-Host Removing FluentValidation.Resources files
|
|
|
|
get-childitem $path -File -Filter FluentValidation.resources.dll -recurse | foreach ($_) {remove-item $_.fullname}
|
2013-05-11 22:38:00 -07:00
|
|
|
|
2014-01-05 22:20:08 -08:00
|
|
|
get-childitem $path -File -Filter app.config -Recurse | foreach ($_) {remove-item $_.fullname}
|
2013-11-23 17:42:22 -08:00
|
|
|
|
|
|
|
Write-Host Removing .less files
|
|
|
|
get-childitem $path -File -Filter *.less -Recurse | foreach ($_) {remove-item $_.fullname}
|
2014-10-18 10:05:24 -07:00
|
|
|
|
|
|
|
Write-Host Removing vshost files
|
|
|
|
get-childitem $path -File -Filter *.vshost.exe -Recurse | foreach ($_) {remove-item $_.fullname}
|
2013-08-23 17:15:23 -07:00
|
|
|
|
2014-10-18 09:58:49 -07:00
|
|
|
if(Test-Path $$path\NuGet)
|
|
|
|
{
|
|
|
|
Write-Host Removing NuGet
|
|
|
|
Remove-Item -Recurse -Force "$path\NuGet"
|
|
|
|
}
|
|
|
|
|
2013-05-11 18:32:03 -07:00
|
|
|
Write-Host Removing Empty folders
|
2013-05-15 21:55:15 -07: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-11 18:32:03 -07:00
|
|
|
}
|
2013-03-28 17:12:40 -07:00
|
|
|
}
|
|
|
|
|
2013-08-23 17:15:23 -07:00
|
|
|
Function PackageMono()
|
|
|
|
{
|
2013-11-13 12:38:57 -08:00
|
|
|
Write-Host "##teamcity[progressStart 'Creating Mono Package']"
|
|
|
|
|
2013-08-23 17:15:23 -07:00
|
|
|
if(Test-Path $outputFolderMono)
|
|
|
|
{
|
|
|
|
Remove-Item -Recurse -Force $outputFolderMono -ErrorAction Continue
|
|
|
|
}
|
|
|
|
|
|
|
|
Copy-Item $outputFolder $outputFolderMono -recurse
|
|
|
|
|
2013-12-26 14:14:11 -08:00
|
|
|
Write-Host Creating MDBs
|
|
|
|
get-childitem $outputFolderMono -File -Include @("*.exe", "*.dll") -Exclude @("MediaInfo.dll", "sqlite3.dll") -Recurse | foreach ($_) {
|
|
|
|
Write-Host "Creating .mdb for $_"
|
|
|
|
& "tools\pdb2mdb\pdb2mdb.exe" $_.fullname
|
|
|
|
}
|
|
|
|
|
2013-08-23 17:15:23 -07:00
|
|
|
Write-Host Removing PDBs
|
|
|
|
get-childitem $outputFolderMono -File -Filter *.pdb -Recurse | foreach ($_) {remove-item $_.fullname}
|
|
|
|
|
|
|
|
Write-Host Removing Service helpers
|
2014-01-05 22:20:08 -08:00
|
|
|
get-childitem $outputFolderMono -File -Filter ServiceUninstall.* -Recurse | foreach ($_) {remove-item $_.fullname}
|
|
|
|
get-childitem $outputFolderMono -File -Filter ServiceInstall.* -Recurse | foreach ($_) {remove-item $_.fullname}
|
2013-08-23 17:15:23 -07:00
|
|
|
|
2013-10-02 18:01:32 -07:00
|
|
|
Write-Host Removing native windows binaries Sqlite, MediaInfo
|
2014-01-05 22:20:08 -08:00
|
|
|
get-childitem $outputFolderMono -File -Filter sqlite3.* -Recurse | foreach ($_) {remove-item $_.fullname}
|
|
|
|
get-childitem $outputFolderMono -File -Filter MediaInfo.* -Recurse | foreach ($_) {remove-item $_.fullname}
|
2013-08-23 17:15:23 -07:00
|
|
|
|
2013-11-21 08:13:40 -08:00
|
|
|
Write-Host "Adding MediaInfoDotNet.dll.config (for dllmap)"
|
|
|
|
Copy-Item "$sourceFolder\MediaInfoDotNet.dll.config" $outputFolderMono
|
|
|
|
|
2013-08-23 17:15:23 -07:00
|
|
|
Write-Host Renaming NzbDrone.Console.exe to NzbDrone.exe
|
2014-01-05 22:20:08 -08:00
|
|
|
Get-ChildItem $outputFolderMono -File -Filter "NzbDrone.exe*" -Recurse | foreach ($_) {remove-item $_.fullname}
|
2013-12-26 14:14:11 -08:00
|
|
|
|
2014-01-05 22:20:08 -08:00
|
|
|
Write-Host Removing NzbDrone.Windows
|
|
|
|
get-childitem $outputFolderMono -File -Filter NzbDrone.Windows.* -Recurse | foreach ($_) {remove-item $_.fullname}
|
|
|
|
|
|
|
|
Get-ChildItem $outputFolderMono -File -Filter "NzbDrone.Console.exe*" -Recurse | foreach ($_) {
|
2013-12-26 14:14:11 -08:00
|
|
|
$newName = $_.fullname -Replace ".Console",""
|
|
|
|
|
|
|
|
Rename-Item $_.fullname $newName
|
|
|
|
}
|
|
|
|
|
2014-04-27 23:34:29 -07:00
|
|
|
Write-Host Adding NzbDrone.Mono to UpdatePackage
|
|
|
|
Copy-Item $outputFolderMono\* $updateFolderMono -Filter NzbDrone.Mono.*
|
|
|
|
|
2013-11-13 12:38:57 -08:00
|
|
|
Write-Host "##teamcity[progressFinish 'Creating Mono Package']"
|
2013-08-23 17:15:23 -07:00
|
|
|
}
|
|
|
|
|
2014-02-24 17:06:41 -08:00
|
|
|
Function PackageOsx()
|
|
|
|
{
|
|
|
|
Write-Host "##teamcity[progressStart 'Creating OS X Package']"
|
|
|
|
|
|
|
|
if(Test-Path $outputFolderOsx)
|
|
|
|
{
|
2014-03-09 14:23:48 -07:00
|
|
|
Remove-Item -Recurse -Force $outputFolderOsx -ErrorAction Continue
|
2014-02-24 17:06:41 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
Copy-Item $outputFolderMono $outputFolderOsx -recurse
|
|
|
|
|
|
|
|
Write-Host "Adding sqlite dylibs"
|
|
|
|
Copy-Item "$sourceFolder\Libraries\sqlite\*.dylib" "$outputFolderOsx"
|
|
|
|
|
2014-04-04 08:14:23 -07:00
|
|
|
Write-Host "Adding MediaInfo dylib"
|
|
|
|
Copy-Item "$sourceFolder\Libraries\MediaInfo\*.dylib" "$outputFolderOsx"
|
|
|
|
|
2014-02-24 17:06:41 -08:00
|
|
|
Write-Host "##teamcity[progressFinish 'Creating OS X Package']"
|
|
|
|
}
|
|
|
|
|
2013-08-05 15:49:41 -07:00
|
|
|
Function AddJsonNet()
|
|
|
|
{
|
2014-01-05 22:20:08 -08:00
|
|
|
get-childitem $outputFolder -File -Filter Newtonsoft.Json.* -Recurse | foreach ($_) {remove-item $_.fullname}
|
2014-08-24 19:58:35 -07:00
|
|
|
Copy-Item .\src\packages\Newtonsoft.Json.*.*\lib\net35\*.dll -Destination $outputFolder
|
|
|
|
Copy-Item .\src\packages\Newtonsoft.Json.*.*\lib\net35\*.dll -Destination $outputFolder\NzbDrone.Update
|
2013-08-05 15:49:41 -07:00
|
|
|
}
|
|
|
|
|
2013-05-11 18:32:03 -07:00
|
|
|
Function PackageTests()
|
|
|
|
{
|
2013-11-13 12:38:57 -08:00
|
|
|
|
2013-07-05 16:12:52 -07:00
|
|
|
Write-Host Packaging Tests
|
2013-11-21 08:13:40 -08:00
|
|
|
Write-Host "##teamcity[progressStart 'Creating Test Package']"
|
2013-08-18 16:31:13 -07:00
|
|
|
|
2013-08-05 16:11:37 -07:00
|
|
|
if(Test-Path $testPackageFolder)
|
2013-05-11 18:32:03 -07:00
|
|
|
{
|
|
|
|
Remove-Item -Recurse -Force $testPackageFolder -ErrorAction Continue
|
|
|
|
}
|
|
|
|
|
2014-01-05 22:20:08 -08:00
|
|
|
Get-ChildItem -Recurse -Directory | Where-Object {$_.FullName -like $testSearchPattern} | foreach($_){
|
2013-05-11 18:32:03 -07:00
|
|
|
Copy-Item -Recurse ($_.FullName + "\*") $testPackageFolder -ErrorAction Ignore
|
|
|
|
}
|
|
|
|
|
2013-10-02 18:01:32 -07:00
|
|
|
.\src\.nuget\NuGet.exe install NUnit.Runners -Version 2.6.1 -Output $testPackageFolder
|
2013-05-11 22:38:00 -07:00
|
|
|
|
2013-11-21 08:13:40 -08:00
|
|
|
Copy-Item $outputFolder\*.dll -Destination $testPackageFolder -Force
|
|
|
|
Copy-Item $outputFolder\*.pdb -Destination $testPackageFolder -Force
|
2014-08-09 01:51:19 -07:00
|
|
|
Copy-Item .\*.sh -Destination $testPackageFolder -Force
|
2014-10-16 23:40:09 -07:00
|
|
|
|
|
|
|
Write-Host Creating MDBs for tests
|
|
|
|
get-childitem $testPackageFolder -File -Include @("*.exe", "*.dll") -Exclude @("MediaInfo.dll", "sqlite3.dll") -Recurse | foreach ($_) {
|
|
|
|
Write-Host "Creating .mdb for $_"
|
|
|
|
& "tools\pdb2mdb\pdb2mdb.exe" $_.fullname
|
|
|
|
}
|
2013-08-18 16:41:34 -07:00
|
|
|
|
2013-08-05 16:11:37 -07:00
|
|
|
get-childitem $testPackageFolder -File -Filter *log.config | foreach ($_) {remove-item $_.fullname}
|
2013-08-18 17:04:48 -07:00
|
|
|
|
2014-08-25 19:30:57 -07:00
|
|
|
CleanFolder $testPackageFolder $true
|
2013-11-13 12:38:57 -08:00
|
|
|
|
2013-11-21 08:13:40 -08:00
|
|
|
Write-Host "Adding MediaInfoDotNet.dll.config (for dllmap)"
|
|
|
|
Copy-Item "$sourceFolder\MediaInfoDotNet.dll.config" -Destination $testPackageFolder -Force
|
|
|
|
|
|
|
|
Write-Host "##teamcity[progressFinish 'Creating Test Package']"
|
2013-05-11 18:32:03 -07:00
|
|
|
}
|
2013-03-28 17:12:40 -07:00
|
|
|
|
2014-10-18 10:05:24 -07:00
|
|
|
Function RunGulp()
|
2013-05-15 17:33:27 -07:00
|
|
|
{
|
2014-08-28 14:40:18 -07:00
|
|
|
Write-Host "##teamcity[progressStart 'Running Gulp']"
|
|
|
|
$gulpPath = '.\node_modules\gulp\bin\gulp'
|
2013-05-19 17:30:02 -07:00
|
|
|
Invoke-Expression 'npm install'
|
2013-07-05 16:12:52 -07:00
|
|
|
CheckExitCode
|
2013-05-16 13:49:16 -07:00
|
|
|
|
2014-08-28 14:40:18 -07:00
|
|
|
Invoke-Expression ('node ' + $gulpPath + ' build') -ErrorAction Continue -Verbose
|
2013-07-05 16:12:52 -07:00
|
|
|
CheckExitCode
|
2013-11-13 12:38:57 -08:00
|
|
|
|
2013-11-20 22:26:18 -08:00
|
|
|
Remove-Item $outputFolder\UI\build.txt -ErrorAction Continue
|
|
|
|
|
2014-08-28 14:40:18 -07:00
|
|
|
Write-Host "##teamcity[progressFinish 'Running Gulp']"
|
2013-07-05 16:12:52 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
Function CheckExitCode()
|
|
|
|
{
|
|
|
|
if ($lastexitcode -ne 0)
|
|
|
|
{
|
|
|
|
Write-Host $errorMessage
|
|
|
|
exit 1
|
|
|
|
}
|
2013-05-15 17:33:27 -07:00
|
|
|
}
|
|
|
|
|
2014-01-05 22:20:08 -08:00
|
|
|
Function CleanupWindowsPackage()
|
|
|
|
{
|
|
|
|
Write-Host Removing NzbDrone.Mono
|
|
|
|
get-childitem $outputFolder -File -Filter NzbDrone.Mono.* -Recurse | foreach ($_) {remove-item $_.fullname}
|
2014-01-27 14:38:45 -08:00
|
|
|
|
|
|
|
Write-Host Adding NzbDrone.Windows to UpdatePackage
|
|
|
|
Copy-Item $outputFolder\* $updateFolder -Filter NzbDrone.Windows.*
|
2014-01-05 22:20:08 -08:00
|
|
|
}
|
|
|
|
|
2013-05-15 17:33:27 -07:00
|
|
|
Build
|
2014-10-18 10:05:24 -07:00
|
|
|
RunGulp
|
2014-08-11 12:46:23 -07:00
|
|
|
PackageMono
|
|
|
|
PackageOsx
|
|
|
|
PackageTests
|
|
|
|
CleanupWindowsPackage
|