2019-01-15 16:34:39 +00:00
|
|
|
[CmdletBinding()]
|
2019-01-10 18:45:21 +00:00
|
|
|
param(
|
2019-07-06 01:41:33 +00:00
|
|
|
[switch]$MakeNSIS,
|
2019-09-09 21:40:51 +00:00
|
|
|
[switch]$InstallNSIS,
|
2019-01-10 18:45:21 +00:00
|
|
|
[switch]$InstallFFMPEG,
|
|
|
|
[switch]$InstallNSSM,
|
2019-09-09 21:40:51 +00:00
|
|
|
[switch]$SkipJellyfinBuild,
|
2019-01-10 18:45:21 +00:00
|
|
|
[switch]$GenerateZip,
|
2019-09-09 21:40:51 +00:00
|
|
|
[string]$InstallLocation = "./dist/jellyfin-win-nsis",
|
|
|
|
[string]$UXLocation = "../jellyfin-ux",
|
2019-11-01 05:25:45 +00:00
|
|
|
[switch]$InstallTrayApp,
|
2019-01-10 18:45:21 +00:00
|
|
|
[ValidateSet('Debug','Release')][string]$BuildType = 'Release',
|
|
|
|
[ValidateSet('Quiet','Minimal', 'Normal')][string]$DotNetVerbosity = 'Minimal',
|
|
|
|
[ValidateSet('win','win7', 'win8','win81','win10')][string]$WindowsVersion = 'win',
|
|
|
|
[ValidateSet('x64','x86', 'arm', 'arm64')][string]$Architecture = 'x64'
|
|
|
|
)
|
|
|
|
|
2020-01-15 11:17:42 +00:00
|
|
|
$ProgressPreference = 'SilentlyContinue' # Speedup all downloads by hiding progress bars.
|
|
|
|
|
2019-01-10 18:45:21 +00:00
|
|
|
#PowershellCore and *nix check to make determine which temp dir to use.
|
|
|
|
if(($PSVersionTable.PSEdition -eq 'Core') -and (-not $IsWindows)){
|
|
|
|
$TempDir = mktemp -d
|
|
|
|
}else{
|
|
|
|
$TempDir = $env:Temp
|
|
|
|
}
|
2019-09-09 21:40:51 +00:00
|
|
|
#Create staging dir
|
|
|
|
New-Item -ItemType Directory -Force -Path $InstallLocation
|
|
|
|
$ResolvedInstallLocation = Resolve-Path $InstallLocation
|
|
|
|
$ResolvedUXLocation = Resolve-Path $UXLocation
|
2019-01-10 18:45:21 +00:00
|
|
|
|
|
|
|
function Build-JellyFin {
|
|
|
|
if(($Architecture -eq 'arm64') -and ($WindowsVersion -ne 'win10')){
|
|
|
|
Write-Error "arm64 only supported with Windows10 Version"
|
|
|
|
exit
|
|
|
|
}
|
|
|
|
if(($Architecture -eq 'arm') -and ($WindowsVersion -notin @('win10','win81','win8'))){
|
|
|
|
Write-Error "arm only supported with Windows 8 or higher"
|
|
|
|
exit
|
|
|
|
}
|
2019-04-06 17:40:19 +00:00
|
|
|
Write-Verbose "windowsversion-Architecture: $windowsversion-$Architecture"
|
2019-09-09 21:40:51 +00:00
|
|
|
Write-Verbose "InstallLocation: $ResolvedInstallLocation"
|
2019-04-06 17:40:19 +00:00
|
|
|
Write-Verbose "DotNetVerbosity: $DotNetVerbosity"
|
2019-09-09 21:40:51 +00:00
|
|
|
dotnet publish --self-contained -c $BuildType --output $ResolvedInstallLocation -v $DotNetVerbosity -p:GenerateDocumentationFile=false -p:DebugSymbols=false -p:DebugType=none --runtime `"$windowsversion-$Architecture`" Jellyfin.Server
|
2019-01-10 18:45:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function Install-FFMPEG {
|
|
|
|
param(
|
2019-09-09 21:40:51 +00:00
|
|
|
[string]$ResolvedInstallLocation,
|
2020-01-16 10:47:54 +00:00
|
|
|
[string]$Architecture,
|
2020-07-17 06:40:27 +00:00
|
|
|
[string]$FFMPEGVersionX86 = "ffmpeg-4.3-win32-shared"
|
2019-01-10 18:45:21 +00:00
|
|
|
)
|
|
|
|
Write-Verbose "Checking Architecture"
|
|
|
|
if($Architecture -notin @('x86','x64')){
|
|
|
|
Write-Warning "No builds available for your selected architecture of $Architecture"
|
2019-01-15 16:34:39 +00:00
|
|
|
Write-Warning "FFMPEG will not be installed"
|
2019-01-10 18:45:21 +00:00
|
|
|
}elseif($Architecture -eq 'x64'){
|
|
|
|
Write-Verbose "Downloading 64 bit FFMPEG"
|
2019-10-06 20:03:44 +00:00
|
|
|
Invoke-WebRequest -Uri https://repo.jellyfin.org/releases/server/windows/ffmpeg/jellyfin-ffmpeg.zip -UseBasicParsing -OutFile "$tempdir/ffmpeg.zip" | Write-Verbose
|
2019-01-10 18:45:21 +00:00
|
|
|
}else{
|
|
|
|
Write-Verbose "Downloading 32 bit FFMPEG"
|
2020-01-16 09:57:19 +00:00
|
|
|
Invoke-WebRequest -Uri https://ffmpeg.zeranoe.com/builds/win32/shared/$FFMPEGVersionX86.zip -UseBasicParsing -OutFile "$tempdir/ffmpeg.zip" | Write-Verbose
|
2019-01-10 18:45:21 +00:00
|
|
|
}
|
2019-01-15 16:34:39 +00:00
|
|
|
|
2019-09-09 21:40:51 +00:00
|
|
|
Expand-Archive "$tempdir/ffmpeg.zip" -DestinationPath "$tempdir/ffmpeg/" -Force | Write-Verbose
|
2019-01-10 18:45:21 +00:00
|
|
|
if($Architecture -eq 'x64'){
|
|
|
|
Write-Verbose "Copying Binaries to Jellyfin location"
|
2019-10-06 20:26:17 +00:00
|
|
|
Get-ChildItem "$tempdir/ffmpeg" | ForEach-Object {
|
2019-01-10 18:45:21 +00:00
|
|
|
Copy-Item $_.FullName -Destination $installLocation | Write-Verbose
|
|
|
|
}
|
|
|
|
}else{
|
|
|
|
Write-Verbose "Copying Binaries to Jellyfin location"
|
2020-01-16 09:57:19 +00:00
|
|
|
Get-ChildItem "$tempdir/ffmpeg/$FFMPEGVersionX86/bin" | ForEach-Object {
|
2019-01-10 18:45:21 +00:00
|
|
|
Copy-Item $_.FullName -Destination $installLocation | Write-Verbose
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Remove-Item "$tempdir/ffmpeg/" -Recurse -Force -ErrorAction Continue | Write-Verbose
|
2019-09-09 21:40:51 +00:00
|
|
|
Remove-Item "$tempdir/ffmpeg.zip" -Force -ErrorAction Continue | Write-Verbose
|
2019-01-10 18:45:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function Install-NSSM {
|
|
|
|
param(
|
2019-09-09 21:40:51 +00:00
|
|
|
[string]$ResolvedInstallLocation,
|
2019-01-10 18:45:21 +00:00
|
|
|
[string]$Architecture
|
|
|
|
)
|
|
|
|
Write-Verbose "Checking Architecture"
|
|
|
|
if($Architecture -notin @('x86','x64')){
|
|
|
|
Write-Warning "No builds available for your selected architecture of $Architecture"
|
2019-01-15 16:34:39 +00:00
|
|
|
Write-Warning "NSSM will not be installed"
|
2019-01-10 18:45:21 +00:00
|
|
|
}else{
|
|
|
|
Write-Verbose "Downloading NSSM"
|
2019-10-29 05:07:01 +00:00
|
|
|
# [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
|
|
|
|
# Temporary workaround, file is hosted in an azure blob with a custom domain in front for brevity
|
|
|
|
Invoke-WebRequest -Uri http://files.evilt.win/nssm/nssm-2.24-101-g897c7ad.zip -UseBasicParsing -OutFile "$tempdir/nssm.zip" | Write-Verbose
|
2019-01-10 18:45:21 +00:00
|
|
|
}
|
2019-01-15 16:34:39 +00:00
|
|
|
|
2019-09-09 21:40:51 +00:00
|
|
|
Expand-Archive "$tempdir/nssm.zip" -DestinationPath "$tempdir/nssm/" -Force | Write-Verbose
|
2019-01-10 18:45:21 +00:00
|
|
|
if($Architecture -eq 'x64'){
|
|
|
|
Write-Verbose "Copying Binaries to Jellyfin location"
|
|
|
|
Get-ChildItem "$tempdir/nssm/nssm-2.24-101-g897c7ad/win64" | ForEach-Object {
|
|
|
|
Copy-Item $_.FullName -Destination $installLocation | Write-Verbose
|
|
|
|
}
|
|
|
|
}else{
|
|
|
|
Write-Verbose "Copying Binaries to Jellyfin location"
|
|
|
|
Get-ChildItem "$tempdir/nssm/nssm-2.24-101-g897c7ad/win32" | ForEach-Object {
|
|
|
|
Copy-Item $_.FullName -Destination $installLocation | Write-Verbose
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Remove-Item "$tempdir/nssm/" -Recurse -Force -ErrorAction Continue | Write-Verbose
|
|
|
|
Remove-Item "$tempdir/nssm.zip" -Force -ErrorAction Continue | Write-Verbose
|
|
|
|
}
|
|
|
|
|
2019-07-06 01:41:33 +00:00
|
|
|
function Make-NSIS {
|
|
|
|
param(
|
2019-09-09 21:40:51 +00:00
|
|
|
[string]$ResolvedInstallLocation
|
2019-07-06 01:41:33 +00:00
|
|
|
)
|
2019-09-09 21:40:51 +00:00
|
|
|
|
|
|
|
$env:InstallLocation = $ResolvedInstallLocation
|
|
|
|
if($InstallNSIS.IsPresent -or ($InstallNSIS -eq $true)){
|
|
|
|
& "$tempdir/nsis/nsis-3.04/makensis.exe" /D$Architecture /DUXPATH=$ResolvedUXLocation ".\deployment\windows\jellyfin.nsi"
|
|
|
|
} else {
|
|
|
|
& "makensis" /D$Architecture /DUXPATH=$ResolvedUXLocation ".\deployment\windows\jellyfin.nsi"
|
|
|
|
}
|
|
|
|
Copy-Item .\deployment\windows\jellyfin_*.exe $ResolvedInstallLocation\..\
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function Install-NSIS {
|
|
|
|
Write-Verbose "Downloading NSIS"
|
|
|
|
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
|
|
|
|
Invoke-WebRequest -Uri https://nchc.dl.sourceforge.net/project/nsis/NSIS%203/3.04/nsis-3.04.zip -UseBasicParsing -OutFile "$tempdir/nsis.zip" | Write-Verbose
|
2019-07-06 01:41:33 +00:00
|
|
|
|
2019-07-06 02:16:34 +00:00
|
|
|
Expand-Archive "$tempdir/nsis.zip" -DestinationPath "$tempdir/nsis/" -Force | Write-Verbose
|
2019-09-09 21:40:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function Cleanup-NSIS {
|
2019-07-06 01:41:33 +00:00
|
|
|
Remove-Item "$tempdir/nsis/" -Recurse -Force -ErrorAction Continue | Write-Verbose
|
|
|
|
Remove-Item "$tempdir/nsis.zip" -Force -ErrorAction Continue | Write-Verbose
|
|
|
|
}
|
2019-10-30 22:16:31 +00:00
|
|
|
|
|
|
|
function Install-TrayApp {
|
|
|
|
param(
|
|
|
|
[string]$ResolvedInstallLocation,
|
|
|
|
[string]$Architecture
|
|
|
|
)
|
|
|
|
Write-Verbose "Checking Architecture"
|
|
|
|
if($Architecture -ne 'x64'){
|
|
|
|
Write-Warning "No builds available for your selected architecture of $Architecture"
|
|
|
|
Write-Warning "The tray app will not be available."
|
|
|
|
}else{
|
|
|
|
Write-Verbose "Downloading Tray App and copying to Jellyfin location"
|
|
|
|
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
|
2019-11-03 07:51:29 +00:00
|
|
|
Invoke-WebRequest -Uri https://github.com/jellyfin/jellyfin-windows-tray/releases/latest/download/JellyfinTray.exe -UseBasicParsing -OutFile "$installLocation/JellyfinTray.exe" | Write-Verbose
|
2019-10-30 22:16:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-09 21:40:51 +00:00
|
|
|
if(-not $SkipJellyfinBuild.IsPresent -and -not ($InstallNSIS -eq $true)){
|
|
|
|
Write-Verbose "Starting Build Process: Selected Environment is $WindowsVersion-$Architecture"
|
|
|
|
Build-JellyFin
|
|
|
|
}
|
2019-01-10 18:45:21 +00:00
|
|
|
if($InstallFFMPEG.IsPresent -or ($InstallFFMPEG -eq $true)){
|
|
|
|
Write-Verbose "Starting FFMPEG Install"
|
2019-09-09 21:40:51 +00:00
|
|
|
Install-FFMPEG $ResolvedInstallLocation $Architecture
|
2019-01-10 18:45:21 +00:00
|
|
|
}
|
|
|
|
if($InstallNSSM.IsPresent -or ($InstallNSSM -eq $true)){
|
|
|
|
Write-Verbose "Starting NSSM Install"
|
2019-09-09 21:40:51 +00:00
|
|
|
Install-NSSM $ResolvedInstallLocation $Architecture
|
|
|
|
}
|
2019-10-30 22:16:31 +00:00
|
|
|
if($InstallTrayApp.IsPresent -or ($InstallTrayApp -eq $true)){
|
|
|
|
Write-Verbose "Downloading Windows Tray App"
|
|
|
|
Install-TrayApp $ResolvedInstallLocation $Architecture
|
|
|
|
}
|
2019-09-09 21:40:51 +00:00
|
|
|
#Copy-Item .\deployment\windows\install-jellyfin.ps1 $ResolvedInstallLocation\install-jellyfin.ps1
|
|
|
|
#Copy-Item .\deployment\windows\install.bat $ResolvedInstallLocation\install.bat
|
|
|
|
Copy-Item .\LICENSE $ResolvedInstallLocation\LICENSE
|
|
|
|
if($InstallNSIS.IsPresent -or ($InstallNSIS -eq $true)){
|
|
|
|
Write-Verbose "Installing NSIS"
|
|
|
|
Install-NSIS
|
2019-01-10 18:45:21 +00:00
|
|
|
}
|
2019-07-06 01:41:33 +00:00
|
|
|
if($MakeNSIS.IsPresent -or ($MakeNSIS -eq $true)){
|
|
|
|
Write-Verbose "Starting NSIS Package creation"
|
2019-09-09 21:40:51 +00:00
|
|
|
Make-NSIS $ResolvedInstallLocation
|
|
|
|
}
|
|
|
|
if($InstallNSIS.IsPresent -or ($InstallNSIS -eq $true)){
|
|
|
|
Write-Verbose "Cleanup NSIS"
|
|
|
|
Cleanup-NSIS
|
2019-07-06 01:41:33 +00:00
|
|
|
}
|
2019-01-10 18:45:21 +00:00
|
|
|
if($GenerateZip.IsPresent -or ($GenerateZip -eq $true)){
|
2019-09-09 21:40:51 +00:00
|
|
|
Compress-Archive -Path $ResolvedInstallLocation -DestinationPath "$ResolvedInstallLocation/jellyfin.zip" -Force
|
2019-01-10 18:45:21 +00:00
|
|
|
}
|
|
|
|
Write-Verbose "Finished"
|