diff --git a/src/dotnet_build_script.bat b/src/dotnet_build_script.bat new file mode 100644 index 0000000..7c4dff0 --- /dev/null +++ b/src/dotnet_build_script.bat @@ -0,0 +1,17 @@ +@echo off + +:: Set PowerShell script path +set SCRIPT_PATH="%~dp0dotnet_build_script.ps1" + +:: Check if PowerShell script exists +if not exist %SCRIPT_PATH% ( + echo PowerShell script not found: %SCRIPT_PATH% + exit /b 1 +) + +:: Execute PowerShell script +PowerShell -NoProfile -ExecutionPolicy Bypass -File %SCRIPT_PATH% + +:: Pause to keep the window open +echo. +pause \ No newline at end of file diff --git a/src/dotnet_build_script.ps1 b/src/dotnet_build_script.ps1 new file mode 100644 index 0000000..92e95d0 --- /dev/null +++ b/src/dotnet_build_script.ps1 @@ -0,0 +1,39 @@ +# Define project path +$projectPath = "./YourProject.csproj" + +# List of runtime identifiers for self-contained deployments +$runtimes = @( + "win-x64" +) + +# Define build configurations +$configurations = @( + "Release" +) + +# Output directory +$outputDir = "./build_outputs" + +# Clean output directory if exists, then recreate it +if (Test-Path -Path $outputDir) { + Remove-Item -Recurse -Force -Path $outputDir +} +New-Item -ItemType Directory -Path $outputDir + +# Build "normal" binaries (framework-dependent) +foreach ($config in $configurations) { + $normalBinOutput = "$outputDir/normal/$config" + dotnet publish $projectPath -c $config -o $normalBinOutput --self-contained false + Write-Output "Built normal bin for configuration: $config" +} + +# Build "self-contained" binaries for multiple runtimes +foreach ($config in $configurations) { + foreach ($runtime in $runtimes) { + $selfContainedOutput = "$outputDir/self-contained/$config/$runtime" + dotnet publish $projectPath -c $config -r $runtime --self-contained true -o $selfContainedOutput + Write-Output "Built self-contained bin for configuration: $config, runtime: $runtime" + } +} + +Write-Output "Build process completed!" \ No newline at end of file