diff --git a/.github/utils/build.ps1 b/.github/utils/build.ps1 new file mode 100644 index 0000000..07c0d97 --- /dev/null +++ b/.github/utils/build.ps1 @@ -0,0 +1,50 @@ +param( + [string]$SolutionPath = "SduNetCheckTool.sln", + [string]$Configuration = "Debug", + [string]$Platform = "x64", + [string]$RuntimeIdentifier = "win-x64" +) + +# 函数用于检测是否安装了需要的工具和依赖 +function CheckPrerequisites { + Write-Host "Checking prerequisites for build..." + + # 检测 MSBuild + if (-not (Get-Command -Name "msbuild" -ErrorAction SilentlyContinue)) { + Write-Host "MSBuild is not installed or not in PATH. Please install MSBuild." -ForegroundColor Red + exit 1 + } + + Write-Host "Prerequisites check passed for build." +} + +# 函数用于构建项目 +function BuildProject { + # 使用 MSBuild 进行 WPF 应用程序的恢复 + $restoreArgs = "/t:Restore /p:Configuration=$Configuration /p:Platform=$Platform /p:RuntimeIdentifier=$RuntimeIdentifier" + $restoreCommand = "msbuild $SolutionPath $restoreArgs" + + Write-Host "`n Restoring WPF project... `n" -ForegroundColor Cyan + Write-Host "$ $restoreCommand `n" + Invoke-Expression $restoreCommand + + + # 构建 wapproj 项目 + $buildArgs = "/p:Configuration=$Configuration /p:Platform=$Platform /p:RuntimIdentifier=$RuntimeIdentifier /p:UapAppxPackageBuildMode=StoreUpload /p:AppxBundle=Never /p:GenerateAppInstallerFile=False /p:AppxPackageSigningEnabled=False" + $buildCommand = "msbuild $SolutionPath $buildArgs" + Write-Host "`n Building WPF project... `n" -ForegroundColor Cyan + Write-Host "$ $buildCommand `n" + Invoke-Expression $buildCommand + +} + + +# 检查先决条件 +CheckPrerequisites + +# 构建项目 +BuildProject + +Write-Host "Build completed." + +Write-Host "Build result: SDUNetCheckTool.GUI\bin\$Platform\$Configuration\SDUNetCheckTool.GUI.exe" diff --git a/.github/utils/enigmavbconsole.exe b/.github/utils/enigmavbconsole.exe deleted file mode 100644 index 811c3c8..0000000 Binary files a/.github/utils/enigmavbconsole.exe and /dev/null differ diff --git a/.github/utils/pack.js b/.github/utils/pack.js deleted file mode 100644 index 5512815..0000000 --- a/.github/utils/pack.js +++ /dev/null @@ -1,30 +0,0 @@ -var fs = require('fs'); -var child_process = require('child_process'); -var generateEvb = require('generate-evb'); - -// Change the following paths to the actual paths used in your project -var evbCliPath = 'enigmavbconsole.exe'; -var projectName = 'SDUNetCheckTool.evb'; -var inputExe = '../../SduNetCheckTool.GUI/bin/x64/Release/SduNetCheckTool.GUI.exe'; -var outputExe = '../../build/SduNetCheckTool.GUI_boxed.exe'; -var path2Pack = '../../SduNetCheckTool.GUI/bin/x64/Release'; - -generateEvb(projectName, inputExe, outputExe, path2Pack); - -child_process.execFile(evbCliPath, [projectName], function (err, stdout, stderr) { - var success = false; - if (!err) { - // Sanity check (change this to what works for you): - // Check if the output file exists and if it's bigger than the input file - if (fs.existsSync(outputExe)) { - success = fs.statSync(outputExe).size > fs.statSync(inputExe).size; - } - - if (!success) { - err = new Error('Failed to pack EVB project!\nEVB stdout:\n' + stdout + '\nEVB stderr:\n' + stderr); - } - } - if (err) { - throw err; - } -}); diff --git a/.github/utils/package-lock.json b/.github/utils/package-lock.json deleted file mode 100644 index c61a792..0000000 --- a/.github/utils/package-lock.json +++ /dev/null @@ -1,52 +0,0 @@ -{ - "name": "utils", - "lockfileVersion": 3, - "requires": true, - "packages": { - "": { - "devDependencies": { - "generate-evb": "git+ssh://git@github.com:Jenway/generate-evb" - } - }, - "node_modules/generate-evb": { - "version": "1.0.3", - "resolved": "git+ssh://git@github.com/Jenway/generate-evb.git#cdbf91ee64d02c6339b8c7cb5980e9b114695916", - "dev": true, - "license": "MIT", - "dependencies": { - "graceful-fs": "^4.2.3", - "merge-options": "^1.0.1" - }, - "engines": { - "node": ">=6" - } - }, - "node_modules/graceful-fs": { - "version": "4.2.11", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz", - "integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==", - "dev": true - }, - "node_modules/is-plain-obj": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-1.1.0.tgz", - "integrity": "sha512-yvkRyxmFKEOQ4pNXCmJG5AEQNlXJS5LaONXo5/cLdTZdWvsZ1ioJEonLGAosKlMWE8lwUy/bJzMjcw8az73+Fg==", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/merge-options": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/merge-options/-/merge-options-1.0.1.tgz", - "integrity": "sha512-iuPV41VWKWBIOpBsjoxjDZw8/GbSfZ2mk7N1453bwMrfzdrIk7EzBd+8UVR6rkw67th7xnk9Dytl3J+lHPdxvg==", - "dev": true, - "dependencies": { - "is-plain-obj": "^1.1" - }, - "engines": { - "node": ">=4" - } - } - } -} diff --git a/.github/utils/package.json b/.github/utils/package.json deleted file mode 100644 index c2c186c..0000000 --- a/.github/utils/package.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "devDependencies": { - "generate-evb": "git+ssh://git@github.com:Jenway/generate-evb" - } -} \ No newline at end of file diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4e262ce..3c7c198 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -22,51 +22,41 @@ jobs: env: # artifacts 命名 [名字]-[build-number]-[commit-hash] artifactName: SduNetCheckTool-build.${{github.run_number}}-${{ github.sha }} - appPackagesArchive: SduNetCheckTool-build.${{github.run_number}}-${{ github.sha }}.zip appPackagesExecutable: SduNetCheckTool-build.${{github.run_number}}-${{ github.sha }}.exe solutionPath: SduNetCheckTool.sln - coreProjectDirectory: SduNetCheckTool.Core guiProjectDirectory: SduNetCheckTool.GUI - coreProjectPath: SduNetCheckTool.Core\SduNetCheckTool.Core.csproj - guiProjectPath: SduNetCheckTool.GUI\SduNetCheckTool.GUI.csproj + Platform: x64 Configuration: Release - appPackagesDirectory: bin\x64\Release + RuntimeIdentifier: win-x64 + # appPackagesDirectory: bin\x64\Release + appPackagesDirectory: bin\$env:Platform\$env:Configuration steps: - uses: actions/checkout@v4 - - uses: actions/setup-node@v4 + - uses: actions/setup-dotnet@v4 with: - node-version: 18 + dotnet-version: '3.1.x' - name: Setup MSBuild.exe uses: microsoft/setup-msbuild@v2 + + - name: Add Costura.Fody + run: dotnet add .\SduNetCheckTool.GUI\SduNetCheckTool.GUI.csproj package Costura.Fody - - name: Restore the Wpf application - run: msbuild ${{ env.solutionPath }} /t:Restore /p:Configuration=Release /p:Platform=x64 /p:RuntimeIdentifier=win-x64 - - - name: Build wapproj - run: msbuild ${{ env.solutionPath }} /p:Configuration=${{env.Configuration}} /p:Platform=x64 /p:RuntimIdentifier=win /p:UapAppxPackageBuildMode=StoreUpload /p:AppxBundle=Never /p:GenerateAppInstallerFile=False /p:AppxPackageSigningEnabled=False + - name: Restore and build the Wpf application + run: ./.github/utils/build.ps1 -SolutionPath ${{ env.solutionPath }} -Configuration ${{ env.Configuration }} -Platform ${{ env.Platform }} -RuntimeIdentifier ${{ env.RuntimeIdentifier }} - - name: Create archive + - name: Rename file run: | mkdir build - Compress-Archive -Path ${{ env.guiProjectDirectory }}\${{ env.appPackagesDirectory }}\* -DestinationPath build\${{ env.appPackagesArchive }} - - - name: Pack into single file executable - run: | - cd .\.github\utils\ - npm install - node pack.js - cd - - Move-Item build\SduNetCheckTool.GUI_boxed.exe build\${{ env.appPackagesExecutable }} + Compress-Archive -Path ${{ env.guiProjectDirectory }}\${{ env.appPackagesDirectory }}\app.publish\SduNetCheckTool.GUI.exe -DestinationPath build\${{ env.appPackagesExecutable }} - name: 'Upload Artifact' uses: actions/upload-artifact@v4 with: name: ${{ env.artifactName }} path: | - build/${{ env.appPackagesArchive }} build/${{ env.appPackagesExecutable }} retention-days: 15 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index cf8e32d..3c534c7 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -31,14 +31,12 @@ jobs: - name: Display Artifact run: | ls -l - mv ${{ env.artifact_name }}.zip SduNetCheckTool-${{ github.ref_name }}.zip mv ${{ env.artifact_name }}.exe SduNetCheckTool-${{ github.ref_name }}.exe - name: Create Release uses: softprops/action-gh-release@v1 with: files: | - SduNetCheckTool-${{ github.ref_name }}.zip SduNetCheckTool-${{ github.ref_name }}.exe LICENSE.txt tag_name: ${{ github.ref_name }}