Build-JellyFin.ps1 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. [CmdletBinding()]
  2. param(
  3. [switch]$InstallFFMPEG,
  4. [string]$InstallLocation = "$Env:AppData\JellyFin-Server\",
  5. [ValidateSet('Debug','Release')][string]$BuildType = 'Release',
  6. [ValidateSet('Quiet','Minimal', 'Normal')][string]$DotNetVerbosity = 'Minimal',
  7. [ValidateSet('win','win7', 'win8','win81','win10')][string]$WindowsVersion = 'win',
  8. [ValidateSet('x64','x86', 'arm', 'arm64')][string]$Architecture = 'x64'
  9. )
  10. function Build-JellyFin {
  11. if($Architecture -eq 'arm64'){
  12. if($WindowsVersion -ne 'win10'){
  13. Write-Error "arm64 only supported with Windows10 Version"
  14. exit
  15. }
  16. }
  17. if($Architecture -eq 'arm'){
  18. if($WindowsVersion -notin @('win10','win81','win8')){
  19. Write-Error "arm only supported with Windows 8 or higher"
  20. exit
  21. }
  22. }
  23. dotnet publish -c $BuildType -r "$windowsversion-$Architecture" .\MediaBrowser.sln -o $InstallLocation -v $DotNetVerbosity
  24. }
  25. function Install-FFMPEG {
  26. param(
  27. [string]$InstallLocation,
  28. [string]$Architecture
  29. )
  30. Write-Verbose "Checking Architecture"
  31. if($Architecture -notin @('x86','x64')){
  32. Write-Warning "No builds available for your selected architecture of $Architecture"
  33. Write-Warning "FFMPEG will not be installed"
  34. }elseif($Architecture -eq 'x64'){
  35. Write-Verbose "Downloading 64 bit FFMPEG"
  36. Invoke-WebRequest -Uri https://ffmpeg.zeranoe.com/builds/win64/static/ffmpeg-4.1-win64-static.zip -UseBasicParsing -OutFile $env:TEMP\fmmpeg.zip | Write-Verbose
  37. }else{
  38. Write-Verbose "Downloading 32 bit FFMPEG"
  39. Invoke-WebRequest -Uri https://ffmpeg.zeranoe.com/builds/win32/static/ffmpeg-4.1-win32-static.zip -UseBasicParsing -OutFile $env:TEMP\fmmpeg.zip | Write-Verbose
  40. }
  41. Expand-Archive $env:TEMP\fmmpeg.zip -DestinationPath $env:TEMP\ffmpeg\ | Write-Verbose
  42. if($Architecture -eq 'x64'){
  43. Write-Verbose "Copying Binaries to Jellyfin location"
  44. Get-ChildItem "$env:temp\ffmpeg\ffmpeg-4.1-win64-static\bin" | ForEach-Object {
  45. Copy-Item $_.FullName -Destination $installLocation | Write-Verbose
  46. }
  47. }else{
  48. Write-Verbose "Copying Binaries to Jellyfin location"
  49. Get-ChildItem "$env:temp\ffmpeg\ffmpeg-4.1-win32-static\bin" | ForEach-Object {
  50. Copy-Item $_.FullName -Destination $installLocation | Write-Verbose
  51. }
  52. }
  53. Remove-Item $env:TEMP\ffmpeg\ -Recurse -Force -ErrorAction Continue | Write-Verbose
  54. Remove-Item $env:TEMP\fmmpeg.zip -Force -ErrorAction Continue | Write-Verbose
  55. }
  56. Write-Verbose "Starting Build Process: Selected Environment is $WindowsVersion-$Architecture"
  57. Build-JellyFin
  58. if($InstallFFMPEG.IsPresent -or ($InstallFFMPEG -eq $true)){
  59. Write-Verbose "Starting FFMPEG Install"
  60. Install-FFMPEG $InstallLocation $Architecture
  61. }
  62. Write-Verbose "Finished"