From 80304a31d2ad74f587f51f44d6d991c1e49a7e7f Mon Sep 17 00:00:00 2001 From: Lazaro Martinez Date: Sun, 5 May 2024 07:27:19 +0200 Subject: [PATCH 1/2] Add publish script and build docs. --- README.md | 15 ++++++++++++++- Scripts/Build.ps1 | 34 ++++++++++++++++++++++++++++++++++ YoutubeApp.sln | 13 ++++++++++++- 3 files changed, 60 insertions(+), 2 deletions(-) create mode 100644 Scripts/Build.ps1 diff --git a/README.md b/README.md index a614eae..a319995 100644 --- a/README.md +++ b/README.md @@ -32,9 +32,22 @@ An open-source YouTube video downloader that allows you to easily download video - Microsoft Windows 7+ (x64) - [.NET 8.0 Desktop Runtime](https://aka.ms/dotnet-core-applaunch?framework=Microsoft.NETCore.App&framework_version=8.0.0&arch=x64&rid=win-x64&gui=true) - [Releases](https://github.com/legend2ks/YoutubeDownloader/releases) + +## Building from source code + +Clone the repository and the git submodule: +`git clone --recursive https://github.com/legend2ks/YoutubeDownloader` + +Download these project dependencies next to the "`YoutubeApp.exe`" main app, +create a folder named "utils" and get these 3 files from the internet: +- "aria2c.exe" from https://github.com/aria2/aria2/releases (look for the releases file download `aria2-1.37.0-win-64bit-build1.zip`). +- "yt-dlp.exe" from https://github.com/yt-dlp/yt-dlp/releases (look for the `yt-dlp.exe` file) +- "ffmpeg.exe" from https://github.com/BtbN/FFmpeg-Builds/releases (for example the `ffmpeg-master-latest-win64-gpl.zip` and extract the `ffmpeg.exe`) + + + ## Roadmap * [x] Channels section diff --git a/Scripts/Build.ps1 b/Scripts/Build.ps1 new file mode 100644 index 0000000..4835b56 --- /dev/null +++ b/Scripts/Build.ps1 @@ -0,0 +1,34 @@ + +cd .. +$publishFolder = "Publish" +$publishFolderApp = "$publishFolder/app" + +# Cleanup: +Write-Host -F Blue "Cleaning up folders: '$publishFolderApp' and '$publishFolderDotnetTool'..." +if (test-path $publishFolderApp ) { Remove-Item "$publishFolderApp/*" -Force -Recurse; Write-Host -F Yellow "Removed folder: $publishFolderApp" } +Write-Host -F Blue "Starting compilation..." + +# COMPILE AS EXE: +# https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-publish +Write-Host -F Blue "Publishing app..." +dotnet publish "YoutubeApp/YoutubeApp.csproj" -c "Release" -o $publishFolderApp /p:DebugType=None -p:PublishSingleFile=true --self-contained false # -r "win-x64" +Write-Host -F Green "Publishing app DONE!" + +$version = (Get-Item "$publishFolderApp/YoutubeApp.exe").VersionInfo.FileVersion + +mkdir "$publishFolderApp/utils" -Force +# TODO: download: +# - "aria2c.exe" from https://github.com/aria2/aria2/releases (look for the releases file download `aria2-1.37.0-win-64bit-build1.zip`). +# - "yt-dlp.exe" from https://github.com/yt-dlp/yt-dlp/releases (look for the `yt-dlp.exe` file) +# - "ffmpeg.exe" from https://github.com/BtbN/FFmpeg-Builds/releases (for example the `ffmpeg-master-latest-win64-gpl.zip` and extract the `ffmpeg.exe`) + + + +$destinationZip = "$publishFolder/YoutubeApp-v$version.zip" +Write-Host -F Blue "Compressing binaries into: '$destinationZip'..." +# https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.archive/compress-archive?view=powershell-7.3 +Compress-Archive -Path "$publishFolderApp/*" -DestinationPath $destinationZip -Force + +Start $publishFolder + +Write-Host -F Green "Finished Build!" diff --git a/YoutubeApp.sln b/YoutubeApp.sln index 08713b6..0ebccc8 100644 --- a/YoutubeApp.sln +++ b/YoutubeApp.sln @@ -5,10 +5,21 @@ VisualStudioVersion = 17.4.33122.133 MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "YoutubeApp", "YoutubeApp\YoutubeApp.csproj", "{D8731E42-5487-4304-8CBB-5DB68DDF6A32}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "YoutubeApp.Tests", "YoutubeApp.Tests\YoutubeApp.Tests.csproj", "{FBE41C3C-DA78-4D32-8185-82A1231C2000}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "YoutubeApp.Tests", "YoutubeApp.Tests\YoutubeApp.Tests.csproj", "{FBE41C3C-DA78-4D32-8185-82A1231C2000}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MessageBox.Avalonia", "MessageBox.Avalonia\src\MessageBox.Avalonia\MessageBox.Avalonia.csproj", "{B8D18D54-ECC6-49BF-B897-BDDB1BFD8092}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{76C039DA-C7C7-414F-9B6D-983F5341C4AE}" + ProjectSection(SolutionItems) = preProject + LICENSE = LICENSE + README.md = README.md + EndProjectSection +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Scripts", "Scripts", "{75801BB8-7117-4172-B48B-AB700F5B36AF}" + ProjectSection(SolutionItems) = preProject + Scripts\Build.ps1 = Scripts\Build.ps1 + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU From 4170cb07c0410513a4a363fc037c49e057950208 Mon Sep 17 00:00:00 2001 From: legend2k Date: Tue, 7 May 2024 01:51:23 +0330 Subject: [PATCH 2/2] Some minor changes --- README.md | 23 +++++++++++++++-------- Scripts/Build.ps1 | 36 +++++++++++++++++++++--------------- 2 files changed, 36 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index a319995..512e28a 100644 --- a/README.md +++ b/README.md @@ -34,19 +34,26 @@ An open-source YouTube video downloader that allows you to easily download video [Releases](https://github.com/legend2ks/YoutubeDownloader/releases) - ## Building from source code -Clone the repository and the git submodule: -`git clone --recursive https://github.com/legend2ks/YoutubeDownloader` +Clone the repository (including submodules): -Download these project dependencies next to the "`YoutubeApp.exe`" main app, -create a folder named "utils" and get these 3 files from the internet: -- "aria2c.exe" from https://github.com/aria2/aria2/releases (look for the releases file download `aria2-1.37.0-win-64bit-build1.zip`). -- "yt-dlp.exe" from https://github.com/yt-dlp/yt-dlp/releases (look for the `yt-dlp.exe` file) -- "ffmpeg.exe" from https://github.com/BtbN/FFmpeg-Builds/releases (for example the `ffmpeg-master-latest-win64-gpl.zip` and extract the `ffmpeg.exe`) +``` +git clone --recursive https://github.com/legend2ks/YoutubeDownloader +``` + +Build the project using the build script, or: +``` +cd YoutubeDownloader +dotnet publish "YoutubeApp/YoutubeApp.csproj" -c "Release" -o "Publish/app" -p:DebugType=None -p:PublishSingleFile=true --self-contained false +``` +Download these project dependencies and put them in `Publish/app/utils`: + +- "aria2c.exe" from https://github.com/aria2/aria2/releases (look for the releases file download `aria2-1.37.0-win-64bit-build1.zip`). +- "yt-dlp.exe" from https://github.com/yt-dlp/yt-dlp/releases (look for the `yt-dlp.exe` file) +- "ffmpeg.exe" from https://github.com/BtbN/FFmpeg-Builds/releases (for example the `ffmpeg-master-latest-win64-lgpl.zip` and extract the `ffmpeg.exe`) ## Roadmap diff --git a/Scripts/Build.ps1 b/Scripts/Build.ps1 index 4835b56..8635734 100644 --- a/Scripts/Build.ps1 +++ b/Scripts/Build.ps1 @@ -1,33 +1,39 @@ - cd .. $publishFolder = "Publish" $publishFolderApp = "$publishFolder/app" # Cleanup: -Write-Host -F Blue "Cleaning up folders: '$publishFolderApp' and '$publishFolderDotnetTool'..." -if (test-path $publishFolderApp ) { Remove-Item "$publishFolderApp/*" -Force -Recurse; Write-Host -F Yellow "Removed folder: $publishFolderApp" } -Write-Host -F Blue "Starting compilation..." - -# COMPILE AS EXE: +Write-Host -F Blue "Cleaning up folder: '$publishFolderApp'" +if (test-path $publishFolderApp) +{ + Remove-Item "$publishFolderApp/*" -Force -Recurse + Write-Host -F Yellow "Removed folder: $publishFolderApp" +} + +# Build as .exe: # https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-publish Write-Host -F Blue "Publishing app..." -dotnet publish "YoutubeApp/YoutubeApp.csproj" -c "Release" -o $publishFolderApp /p:DebugType=None -p:PublishSingleFile=true --self-contained false # -r "win-x64" +dotnet publish "YoutubeApp/YoutubeApp.csproj" -c "Release" -o $publishFolderApp -p:DebugType=None -p:PublishSingleFile=true --self-contained false # -r "win-x64" +if ($LASTEXITCODE -ne 0) +{ + Write-Host -F Red "Publishing app FAILED!" + exit -1 +} Write-Host -F Green "Publishing app DONE!" -$version = (Get-Item "$publishFolderApp/YoutubeApp.exe").VersionInfo.FileVersion - mkdir "$publishFolderApp/utils" -Force + # TODO: download: # - "aria2c.exe" from https://github.com/aria2/aria2/releases (look for the releases file download `aria2-1.37.0-win-64bit-build1.zip`). # - "yt-dlp.exe" from https://github.com/yt-dlp/yt-dlp/releases (look for the `yt-dlp.exe` file) -# - "ffmpeg.exe" from https://github.com/BtbN/FFmpeg-Builds/releases (for example the `ffmpeg-master-latest-win64-gpl.zip` and extract the `ffmpeg.exe`) - - +# - "ffmpeg.exe" from https://github.com/BtbN/FFmpeg-Builds/releases (for example the `ffmpeg-master-latest-win64-lgpl.zip` and extract the `ffmpeg.exe`) -$destinationZip = "$publishFolder/YoutubeApp-v$version.zip" -Write-Host -F Blue "Compressing binaries into: '$destinationZip'..." +# TODO: compress: +# $version = (Get-Item "$publishFolderApp/YoutubeApp.exe").VersionInfo.FileVersion +# $destinationZip = "$publishFolder/YoutubeApp-v$version.zip" +# Write-Host -F Blue "Compressing binaries into: '$destinationZip'..." # https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.archive/compress-archive?view=powershell-7.3 -Compress-Archive -Path "$publishFolderApp/*" -DestinationPath $destinationZip -Force +# Compress-Archive -Path "$publishFolderApp/*" -DestinationPath $destinationZip -Force Start $publishFolder