From 7ab89b67c573717257bdf545786540c8f563d26b Mon Sep 17 00:00:00 2001 From: ChsBuffer <33744752+chsbuffer@users.noreply.github.com> Date: Wed, 31 Mar 2021 18:45:21 +0800 Subject: [PATCH] Update BUILD.ps1 --- .github/workflows/ci.yml | 6 ++++-- .github/workflows/release.yml | 2 +- BUILD.ps1 | 36 ++++++++++++++++++++++++++++++++--- PUBLISH.ps1 | 16 ---------------- 4 files changed, 38 insertions(+), 22 deletions(-) delete mode 100644 PUBLISH.ps1 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 803305df..96a7451b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,6 +8,8 @@ jobs: build: name: Build runs-on: windows-latest + env: + OutputPath: Netch\bin\Publish\Debug steps: - name: Setup MSBuild uses: microsoft/setup-msbuild@v1.0.2 @@ -19,7 +21,7 @@ jobs: - name: Build Solution shell: pwsh - run: .\BUILD.ps1 + run: .\BUILD.ps1 Debug -o ${{ env.OutputPath }} - name: Upload Artifact continue-on-error: true @@ -27,4 +29,4 @@ jobs: uses: actions/upload-artifact@v2 with: name: Netch - path: Netch\bin\x64\Release \ No newline at end of file + path: ${{ env.OutputPath }} \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 6aa156d8..d124da44 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -18,7 +18,7 @@ jobs: - name: Build Solution shell: pwsh - run: .\PUBLISH.ps1 + run: .\BUILD.ps1 - name: Package if: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') }} diff --git a/BUILD.ps1 b/BUILD.ps1 index d382de92..50adc1cb 100644 --- a/BUILD.ps1 +++ b/BUILD.ps1 @@ -1,8 +1,38 @@ -Write-Host 'Building' +param ( + [Alias('c')] + [Parameter()] + [ValidateSet('Debug', 'Release')] + [string] + $Configuration = 'Release', -dotnet build ` - -c "Release" ` + [Alias('o')] + [Parameter()] + [ValidateNotNullOrEmpty()] + [string] + $OutputPath = 'Netch\bin\Publish\', + + [Parameter()] + [bool] + $SelfContained = $False, + + [Parameter()] + [bool] + $PublishReadyToRun = $False +) + +$PublishSingleFile = $True + +Write-Host "Building $Configuration to $OutputPath" + +dotnet publish ` + -c $Configuration ` + -r "win-x64" ` -p:Platform="x64" ` + -p:PublishSingleFile=$PublishSingleFile ` + -p:SelfContained=$SelfContained ` + -p:PublishTrimmed=$SelfContained ` + -p:PublishReadyToRun=$PublishReadyToRun ` + -o $OutputPath ` Netch\Netch.csproj if ($LASTEXITCODE) { exit $LASTEXITCODE } diff --git a/PUBLISH.ps1 b/PUBLISH.ps1 deleted file mode 100644 index b1796e4e..00000000 --- a/PUBLISH.ps1 +++ /dev/null @@ -1,16 +0,0 @@ -Write-Host 'Building' - -dotnet publish ` - -c "Release" ` - -r "win-x64" ` - -p:Platform="x64" ` - -p:PublishSingleFile=true ` - -p:SelfContained=false ` - -p:PublishTrimmed=false ` - -p:PublishReadyToRun=false ` - -o Netch\bin\Publish\ ` - Netch\Netch.csproj - -if ($LASTEXITCODE) { exit $LASTEXITCODE } - -Write-Host 'Build done'