From f0a3f4e746763b5e142e3adac21263ed888f7f61 Mon Sep 17 00:00:00 2001 From: padartamas Date: Thu, 6 Jun 2024 23:36:46 +0200 Subject: [PATCH] Build & publish to local folder script --- .gitignore | 5 + .../MndpService.Core/MndpService.Core.csproj | 2 +- .../PublishProfiles/linux-x64.pubxml | 5 +- .../PublishProfiles/win-x64-full.pubxml | 3 - MndpTray/build.ps1 | 119 ++++++++++++++++++ 5 files changed, 126 insertions(+), 8 deletions(-) create mode 100644 MndpTray/build.ps1 diff --git a/.gitignore b/.gitignore index 3e759b7..5f7add3 100644 --- a/.gitignore +++ b/.gitignore @@ -328,3 +328,8 @@ ASALocalRun/ # MFractors (Xamarin productivity tool) working folder .mfractor/ + +# Build directories +**/build + + diff --git a/MndpTray/MndpService.Core/MndpService.Core.csproj b/MndpTray/MndpService.Core/MndpService.Core.csproj index 0350e7f..2874a55 100644 --- a/MndpTray/MndpService.Core/MndpService.Core.csproj +++ b/MndpTray/MndpService.Core/MndpService.Core.csproj @@ -1,7 +1,7 @@  net8.0 - Exe + Exe true true true diff --git a/MndpTray/MndpService.Core/Properties/PublishProfiles/linux-x64.pubxml b/MndpTray/MndpService.Core/Properties/PublishProfiles/linux-x64.pubxml index ed44598..56ab599 100644 --- a/MndpTray/MndpService.Core/Properties/PublishProfiles/linux-x64.pubxml +++ b/MndpTray/MndpService.Core/Properties/PublishProfiles/linux-x64.pubxml @@ -1,7 +1,4 @@  - Release @@ -11,7 +8,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121. <_TargetId>Folder net8.0 linux-x64 - true + false true \ No newline at end of file diff --git a/MndpTray/MndpTray.Core/Properties/PublishProfiles/win-x64-full.pubxml b/MndpTray/MndpTray.Core/Properties/PublishProfiles/win-x64-full.pubxml index 8ade9a6..b904d91 100644 --- a/MndpTray/MndpTray.Core/Properties/PublishProfiles/win-x64-full.pubxml +++ b/MndpTray/MndpTray.Core/Properties/PublishProfiles/win-x64-full.pubxml @@ -1,7 +1,4 @@  - Release diff --git a/MndpTray/build.ps1 b/MndpTray/build.ps1 new file mode 100644 index 0000000..605ad46 --- /dev/null +++ b/MndpTray/build.ps1 @@ -0,0 +1,119 @@ +# +# To enable script execution, run at admin powershell prompt +# 'set-executionpolicy remotesigned' +# + +$SolutionFolderPath=$PSScriptRoot +$BuildFolderPath="$SolutionFolderPath\Build" + +echo "SolutionFolderPath: $SolutionFolderPath"; +echo "BuildFolderPath: $BuildFolderPath"; + + +# +# Remove & Clean Output Folder +# + +if (Test-Path -LiteralPath $BuildFolderPath) +{ + Remove-Item -LiteralPath $BuildFolderPath -Verbose -Recurse -WhatIf +} +md -Force $BuildFolderPath + + + +# +# Publish Console +# + +$ProjectsConsole = @( + 'MndpService.Core' +) + +$ProfilesConsole = @( + 'win-x64' + 'win-x64-full' + 'linux-x64' + 'linux-x64-full' +) + + +foreach ( $Project in $ProjectsLinux ) +{ + echo "" + echo "Project: [$Project]" + echo "" + dotnet clean -c Release $SolutionFolderPath\$Project + dotnet build -c Release $SolutionFolderPath\$Project + + foreach ( $Profile in $ProfilesConsole ) + { + echo "" + echo "Profile: [$Profile]" + echo "" + + dotnet publish -c Release $SolutionFolderPath\$Project /p:PublishProfile=$Profile + } +} + + +# +# Copy output +# +foreach ( $Project in $ProjectsConsole ) +{ + echo "" + echo "Copy: [$Project]" + echo "" + + Copy-Item -Verbose -Path $SolutionFolderPath\$Project\bin\Release\net8.0\publish\win-x64\$Project.exe -Destination $BuildFolderPath\$Project.exe + Copy-Item -Verbose -Path $SolutionFolderPath\$Project\bin\Release\net8.0\publish\win-x64-full\$Project.exe -Destination $BuildFolderPath\$Project.Full.exe + Copy-Item -Verbose -Path $SolutionFolderPath\$Project\bin\Release\net8.0\publish\linux-x64\$Project -Destination $BuildFolderPath\$Project + Copy-Item -Verbose -Path $SolutionFolderPath\$Project\bin\Release\net8.0\publish\linux-x64-full\$Project -Destination $BuildFolderPath\$Project.Full +} + + +# +# Publish Windows +# + +$ProjectsWindows = @( + 'MndpTray.Core' +) + +$ProfilesWindows = @( + 'win-x64' + 'win-x64-full' +) + + +foreach ( $Project in $ProjectsWindows ) +{ + echo "" + echo "Project: [$Project]" + echo "" + dotnet clean -c Release $SolutionFolderPath\$Project + dotnet build -c Release $SolutionFolderPath\$Project + + foreach ( $Profile in $ProfilesWindows ) + { + echo "" + echo "Profile: [$Profile]" + echo "" + + dotnet publish -c Release $SolutionFolderPath\$Project /p:PublishProfile=$Profile + } +} + +# +# Copy output +# +foreach ( $Project in $ProjectsWindows ) +{ + echo "" + echo "Copy: [$Project]" + echo "" + + Copy-Item -Verbose -Path $SolutionFolderPath\$Project\bin\Release\net8.0-windows\publish\win-x64\$Project.exe -Destination $BuildFolderPath\$Project.exe + Copy-Item -Verbose -Path $SolutionFolderPath\$Project\bin\Release\net8.0-windows\publish\win-x64-full\$Project.exe -Destination $BuildFolderPath\$Project.Full.exe +}