2015-07-04 12:10:11 +00:00
|
|
|
#! /bin/bash
|
2016-03-28 18:45:06 +00:00
|
|
|
msBuild='/c/Program Files (x86)/MSBuild/14.0/Bin'
|
2015-07-04 12:10:11 +00:00
|
|
|
outputFolder='./_output'
|
|
|
|
outputFolderMono='./_output_mono'
|
|
|
|
outputFolderOsx='./_output_osx'
|
|
|
|
outputFolderOsxApp='./_output_osx_app'
|
|
|
|
testPackageFolder='./_tests/'
|
2016-01-15 08:27:59 +00:00
|
|
|
testSearchPattern='*.Test/bin/x86/Release'
|
2015-07-04 12:10:11 +00:00
|
|
|
sourceFolder='./src'
|
2016-01-17 00:39:45 +00:00
|
|
|
slnFile=$sourceFolder/NzbDrone.sln
|
2015-07-04 12:10:11 +00:00
|
|
|
updateFolder=$outputFolder/NzbDrone.Update
|
|
|
|
updateFolderMono=$outputFolderMono/NzbDrone.Update
|
|
|
|
|
2016-01-17 00:17:36 +00:00
|
|
|
nuget='tools/nuget/nuget.exe';
|
2015-07-04 12:10:11 +00:00
|
|
|
CheckExitCode()
|
|
|
|
{
|
|
|
|
"$@"
|
|
|
|
local status=$?
|
|
|
|
if [ $status -ne 0 ]; then
|
|
|
|
echo "error with $1" >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
return $status
|
|
|
|
}
|
|
|
|
|
|
|
|
CleanFolder()
|
|
|
|
{
|
|
|
|
local path=$1
|
|
|
|
local keepConfigFiles=$2
|
|
|
|
|
|
|
|
|
|
|
|
find $path -name "*.transform" -exec rm "{}" \;
|
|
|
|
|
|
|
|
if [ $keepConfigFiles != true ] ; then
|
|
|
|
find $path -name "*.dll.config" -exec rm "{}" \;
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Removing FluentValidation.Resources files"
|
|
|
|
find $path -name "FluentValidation.resources.dll" -exec rm "{}" \;
|
|
|
|
find $path -name "App.config" -exec rm "{}" \;
|
|
|
|
|
|
|
|
echo "Removing .less files"
|
|
|
|
find $path -name "*.less" -exec rm "{}" \;
|
|
|
|
|
|
|
|
echo "Removing vshost files"
|
|
|
|
find $path -name "*.vshost.exe" -exec rm "{}" \;
|
|
|
|
|
2016-01-16 05:49:09 +00:00
|
|
|
echo "Removing dylib files"
|
|
|
|
find $path -name "*.dylib" -exec rm "{}" \;
|
|
|
|
|
2015-07-04 12:10:11 +00:00
|
|
|
echo "Removing Empty folders"
|
|
|
|
find $path -depth -empty -type d -exec rm -r "{}" \;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
AddJsonNet()
|
|
|
|
{
|
|
|
|
rm $outputFolder/Newtonsoft.Json.*
|
|
|
|
cp $sourceFolder/packages/Newtonsoft.Json.*/lib/net35/*.dll $outputFolder
|
|
|
|
cp $sourceFolder/packages/Newtonsoft.Json.*/lib/net35/*.dll $outputFolder/NzbDrone.Update
|
|
|
|
}
|
|
|
|
|
|
|
|
BuildWithMSBuild()
|
|
|
|
{
|
|
|
|
export PATH=$msBuild:$PATH
|
2016-01-17 00:36:40 +00:00
|
|
|
CheckExitCode MSBuild.exe $slnFile //t:Clean //m
|
|
|
|
$nuget restore $slnFile
|
|
|
|
CheckExitCode MSBuild.exe $slnFile //p:Configuration=Release //p:Platform=x86 //t:Build //m //p:AllowedReferenceRelatedFileExtensions=.pdb
|
2015-07-04 12:10:11 +00:00
|
|
|
}
|
|
|
|
|
2018-02-12 16:31:18 +00:00
|
|
|
RestoreNuget()
|
2015-07-04 12:10:11 +00:00
|
|
|
{
|
|
|
|
export MONO_IOMAP=case
|
2016-01-17 00:36:40 +00:00
|
|
|
mono $nuget restore $slnFile
|
2018-02-12 16:31:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
CleanWithXbuild()
|
|
|
|
{
|
|
|
|
export MONO_IOMAP=case
|
|
|
|
CheckExitCode xbuild /t:Clean $slnFile
|
|
|
|
}
|
|
|
|
|
|
|
|
BuildWithXbuild()
|
|
|
|
{
|
|
|
|
export MONO_IOMAP=case
|
2016-01-27 14:11:29 +00:00
|
|
|
CheckExitCode xbuild /p:Configuration=Release /p:Platform=x86 /t:Build /p:AllowedReferenceRelatedFileExtensions=.pdb $slnFile
|
2015-07-04 12:10:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Build()
|
|
|
|
{
|
|
|
|
echo "##teamcity[progressStart 'Build']"
|
|
|
|
|
|
|
|
rm -rf $outputFolder
|
|
|
|
|
|
|
|
if [ $runtime = "dotnet" ] ; then
|
|
|
|
BuildWithMSBuild
|
|
|
|
else
|
2018-02-12 16:31:18 +00:00
|
|
|
CleanWithXbuild
|
|
|
|
RestoreNuget
|
2015-07-04 12:10:11 +00:00
|
|
|
BuildWithXbuild
|
|
|
|
fi
|
2016-01-16 06:06:33 +00:00
|
|
|
|
2015-07-04 12:10:11 +00:00
|
|
|
CleanFolder $outputFolder false
|
2016-01-16 06:06:33 +00:00
|
|
|
|
2015-07-04 12:10:11 +00:00
|
|
|
AddJsonNet
|
|
|
|
|
|
|
|
echo "Removing Mono.Posix.dll"
|
|
|
|
rm $outputFolder/Mono.Posix.dll
|
|
|
|
|
|
|
|
echo "##teamcity[progressFinish 'Build']"
|
|
|
|
}
|
|
|
|
|
|
|
|
RunGulp()
|
|
|
|
{
|
2016-01-16 06:06:33 +00:00
|
|
|
echo "##teamcity[progressStart 'npm install']"
|
2016-03-28 18:37:16 +00:00
|
|
|
npm-cache install npm || CheckExitCode npm install
|
2016-01-16 06:06:33 +00:00
|
|
|
echo "##teamcity[progressFinish 'npm install']"
|
2015-07-04 12:10:11 +00:00
|
|
|
|
2016-03-28 18:45:06 +00:00
|
|
|
echo "##teamcity[progressStart 'Running gulp']"
|
2015-11-09 23:35:20 +00:00
|
|
|
CheckExitCode npm run build
|
2016-03-28 18:45:06 +00:00
|
|
|
echo "##teamcity[progressFinish 'Running gulp']"
|
2015-07-04 12:10:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
CreateMdbs()
|
|
|
|
{
|
|
|
|
local path=$1
|
|
|
|
if [ $runtime = "dotnet" ] ; then
|
2016-01-16 05:49:09 +00:00
|
|
|
local pdbFiles=( $(find $path -name "*.pdb") )
|
|
|
|
for filename in "${pdbFiles[@]}"
|
|
|
|
do
|
|
|
|
if [ -e ${filename%.pdb}.dll ] ; then
|
|
|
|
tools/pdb2mdb/pdb2mdb.exe ${filename%.pdb}.dll
|
|
|
|
fi
|
|
|
|
if [ -e ${filename%.pdb}.exe ] ; then
|
|
|
|
tools/pdb2mdb/pdb2mdb.exe ${filename%.pdb}.exe
|
|
|
|
fi
|
|
|
|
done
|
2015-07-04 12:10:11 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
PackageMono()
|
|
|
|
{
|
|
|
|
echo "##teamcity[progressStart 'Creating Mono Package']"
|
|
|
|
rm -rf $outputFolderMono
|
|
|
|
cp -r $outputFolder $outputFolderMono
|
|
|
|
|
|
|
|
echo "Creating MDBs"
|
|
|
|
CreateMdbs $outputFolderMono
|
|
|
|
|
|
|
|
echo "Removing PDBs"
|
|
|
|
find $outputFolderMono -name "*.pdb" -exec rm "{}" \;
|
|
|
|
|
|
|
|
echo "Removing Service helpers"
|
|
|
|
rm -f $outputFolderMono/ServiceUninstall.*
|
|
|
|
rm -f $outputFolderMono/ServiceInstall.*
|
|
|
|
|
|
|
|
echo "Removing native windows binaries Sqlite, MediaInfo"
|
|
|
|
rm -f $outputFolderMono/sqlite3.*
|
|
|
|
rm -f $outputFolderMono/MediaInfo.*
|
|
|
|
|
|
|
|
echo "Adding NzbDrone.Core.dll.config (for dllmap)"
|
|
|
|
cp $sourceFolder/NzbDrone.Core/NzbDrone.Core.dll.config $outputFolderMono
|
|
|
|
|
|
|
|
echo "Adding CurlSharp.dll.config (for dllmap)"
|
|
|
|
cp $sourceFolder/NzbDrone.Common/CurlSharp.dll.config $outputFolderMono
|
|
|
|
|
|
|
|
echo "Renaming NzbDrone.Console.exe to NzbDrone.exe"
|
2017-01-06 12:13:22 +00:00
|
|
|
rm $outputFolderMono/Radarr.exe*
|
|
|
|
for file in $outputFolderMono/Radarr.Console.exe*; do
|
2015-07-04 12:10:11 +00:00
|
|
|
mv "$file" "${file//.Console/}"
|
|
|
|
done
|
|
|
|
|
|
|
|
echo "Removing NzbDrone.Windows"
|
|
|
|
rm $outputFolderMono/NzbDrone.Windows.*
|
|
|
|
|
|
|
|
echo "Adding NzbDrone.Mono to UpdatePackage"
|
|
|
|
cp $outputFolderMono/NzbDrone.Mono.* $updateFolderMono
|
2016-01-16 06:06:33 +00:00
|
|
|
|
|
|
|
echo "##teamcity[progressFinish 'Creating Mono Package']"
|
2015-07-04 12:10:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
PackageOsx()
|
|
|
|
{
|
|
|
|
echo "##teamcity[progressStart 'Creating OS X Package']"
|
|
|
|
rm -rf $outputFolderOsx
|
|
|
|
cp -r $outputFolderMono $outputFolderOsx
|
|
|
|
|
|
|
|
echo "Adding sqlite dylibs"
|
|
|
|
cp $sourceFolder/Libraries/Sqlite/*.dylib $outputFolderOsx
|
|
|
|
|
|
|
|
echo "Adding MediaInfo dylib"
|
|
|
|
cp $sourceFolder/Libraries/MediaInfo/*.dylib $outputFolderOsx
|
|
|
|
|
|
|
|
echo "Adding Startup script"
|
2017-04-26 16:44:57 +00:00
|
|
|
cp ./osx/Radarr $outputFolderOsx
|
2015-07-04 12:10:11 +00:00
|
|
|
|
|
|
|
echo "##teamcity[progressFinish 'Creating OS X Package']"
|
|
|
|
}
|
|
|
|
|
|
|
|
PackageOsxApp()
|
|
|
|
{
|
|
|
|
echo "##teamcity[progressStart 'Creating OS X App Package']"
|
|
|
|
rm -rf $outputFolderOsxApp
|
|
|
|
mkdir $outputFolderOsxApp
|
|
|
|
|
2017-01-04 14:05:14 +00:00
|
|
|
cp -r ./osx/Radarr.app $outputFolderOsxApp
|
|
|
|
cp -r $outputFolderOsx $outputFolderOsxApp/Radarr.app/Contents/MacOS
|
2015-07-04 12:10:11 +00:00
|
|
|
|
|
|
|
echo "##teamcity[progressFinish 'Creating OS X App Package']"
|
|
|
|
}
|
|
|
|
|
|
|
|
PackageTests()
|
|
|
|
{
|
|
|
|
echo "Packaging Tests"
|
|
|
|
echo "##teamcity[progressStart 'Creating Test Package']"
|
|
|
|
rm -rf $testPackageFolder
|
|
|
|
mkdir $testPackageFolder
|
|
|
|
|
2016-01-15 08:27:59 +00:00
|
|
|
find $sourceFolder -path $testSearchPattern -exec cp -r -u -T "{}" $testPackageFolder \;
|
2015-07-04 12:10:11 +00:00
|
|
|
|
|
|
|
if [ $runtime = "dotnet" ] ; then
|
2017-04-12 15:03:53 +00:00
|
|
|
$nuget install NUnit.Runners -Version 3.2.1 -Output $testPackageFolder
|
2015-07-04 12:10:11 +00:00
|
|
|
else
|
2017-04-12 15:03:53 +00:00
|
|
|
mono $nuget install NUnit.Runners -Version 3.2.1 -Output $testPackageFolder
|
2015-07-04 12:10:11 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
cp $outputFolder/*.dll $testPackageFolder
|
|
|
|
cp ./*.sh $testPackageFolder
|
|
|
|
|
|
|
|
echo "Creating MDBs for tests"
|
|
|
|
CreateMdbs $testPackageFolder
|
|
|
|
|
|
|
|
rm -f $testPackageFolder/*.log.config
|
|
|
|
|
|
|
|
CleanFolder $testPackageFolder true
|
|
|
|
|
|
|
|
echo "Adding NzbDrone.Core.dll.config (for dllmap)"
|
|
|
|
cp $sourceFolder/NzbDrone.Core/NzbDrone.Core.dll.config $testPackageFolder
|
|
|
|
|
|
|
|
echo "Adding CurlSharp.dll.config (for dllmap)"
|
|
|
|
cp $sourceFolder/NzbDrone.Common/CurlSharp.dll.config $testPackageFolder
|
|
|
|
|
2015-08-01 12:54:20 +00:00
|
|
|
echo "Copying CurlSharp libraries"
|
|
|
|
cp $sourceFolder/ExternalModules/CurlSharp/libs/i386/* $testPackageFolder
|
|
|
|
|
2015-07-04 12:10:11 +00:00
|
|
|
echo "##teamcity[progressFinish 'Creating Test Package']"
|
|
|
|
}
|
|
|
|
|
|
|
|
CleanupWindowsPackage()
|
|
|
|
{
|
|
|
|
echo "Removing NzbDrone.Mono"
|
|
|
|
rm -f $outputFolder/NzbDrone.Mono.*
|
|
|
|
|
|
|
|
echo "Adding NzbDrone.Windows to UpdatePackage"
|
|
|
|
cp $outputFolder/NzbDrone.Windows.* $updateFolder
|
|
|
|
}
|
|
|
|
|
|
|
|
# Use mono or .net depending on OS
|
|
|
|
case "$(uname -s)" in
|
|
|
|
CYGWIN*|MINGW32*|MINGW64*|MSYS*)
|
|
|
|
# on windows, use dotnet
|
|
|
|
runtime="dotnet"
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
# otherwise use mono
|
|
|
|
runtime="mono"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2018-02-12 16:31:18 +00:00
|
|
|
if [ $# -eq 0 ]
|
|
|
|
then
|
|
|
|
Build
|
|
|
|
RunGulp
|
|
|
|
PackageMono
|
|
|
|
PackageOsx
|
|
|
|
PackageOsxApp
|
|
|
|
PackageTests
|
|
|
|
CleanupWindowsPackage
|
|
|
|
fi
|
|
|
|
|
2018-02-12 16:37:11 +00:00
|
|
|
if [ "$1" = "CleanXbuild" ]
|
2018-02-12 16:31:18 +00:00
|
|
|
then rm -rf $outputFolder
|
|
|
|
CleanWithXbuild
|
2018-02-12 16:37:11 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$1" = "NugetMono" ]
|
|
|
|
then rm -rf $outputFolder
|
2018-02-12 16:31:18 +00:00
|
|
|
RestoreNuget
|
|
|
|
fi
|
|
|
|
|
2018-02-12 16:37:11 +00:00
|
|
|
if [ "$1" = "Build" ]
|
2018-02-12 16:31:18 +00:00
|
|
|
then BuildWithXbuild
|
|
|
|
CleanFolder $outputFolder false
|
|
|
|
AddJsonNet
|
|
|
|
rm $outputFolder/Mono.Posix.dll
|
|
|
|
fi
|
|
|
|
|
2018-02-12 16:37:11 +00:00
|
|
|
if [ "$1" = "Gulp" ]
|
2018-02-12 16:31:18 +00:00
|
|
|
then RunGulp
|
|
|
|
fi
|
|
|
|
|
2018-02-12 16:37:11 +00:00
|
|
|
if [ "$1" = "Package" ]
|
2018-02-12 16:31:18 +00:00
|
|
|
then PackageMono
|
|
|
|
PackageOsx
|
|
|
|
PackageOsxApp
|
|
|
|
PackageTests
|
|
|
|
CleanupWindowsPackage
|
|
|
|
fi
|