This repository has been archived by the owner on Feb 29, 2024. It is now read-only.
forked from SDUQD-SNA/SduNetCheckTool
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from Jenway/dev
修改了 CI
- Loading branch information
Showing
4 changed files
with
110 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,62 @@ | ||
var fs = require('fs'); | ||
var child_process = require('child_process'); | ||
var generateEvb = require('generate-evb'); | ||
import { existsSync, statSync } from 'fs'; | ||
import { execFile } from 'child_process'; | ||
import generateEvb from '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'; | ||
// Function to parse command line arguments | ||
function parseArgs() { | ||
const args = process.argv.slice(2); | ||
const options = { | ||
evbCliPath: 'enigmavbconsole.exe', | ||
projectName: 'SDUNetCheckTool.evb', | ||
inputExe: 'SduNetCheckTool.GUI/bin/x64/Release/SduNetCheckTool.GUI.exe', | ||
outputExe: 'build/SduNetCheckTool.GUI_boxed.exe', | ||
path2Pack: 'SduNetCheckTool.GUI/bin/x64/Release' | ||
}; | ||
|
||
generateEvb(projectName, inputExe, outputExe, path2Pack); | ||
args.forEach((arg, index) => { | ||
switch (arg) { | ||
case '-evbCliPath': | ||
options.evbCliPath = args[index + 1]; | ||
break; | ||
case '-projectName': | ||
options.projectName = args[index + 1]; | ||
break; | ||
case '-inputExe': | ||
options.inputExe = args[index + 1]; | ||
break; | ||
case '-outputExe': | ||
options.outputExe = args[index + 1]; | ||
break; | ||
case '-path2Pack': | ||
options.path2Pack = args[index + 1]; | ||
break; | ||
default: | ||
break; | ||
} | ||
}); | ||
|
||
return options; | ||
} | ||
|
||
// Parse command line arguments | ||
const options = parseArgs(); | ||
|
||
child_process.execFile(evbCliPath, [projectName], function (err, stdout, stderr) { | ||
var success = false; | ||
// Generate EVB | ||
generateEvb(options.projectName, options.inputExe, options.outputExe, options.path2Pack); | ||
|
||
// Execute EVB CLI | ||
execFile(options.evbCliPath, [options.projectName], function (err, stdout, stderr) { | ||
let 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; | ||
// Sanity check: Check if the output file exists and if it's bigger than the input file | ||
if (existsSync(options.outputExe)) { | ||
success = statSync(options.outputExe).size > statSync(options.inputExe).size; | ||
} | ||
|
||
if (!success) { | ||
err = new Error('Failed to pack EVB project!\nEVB stdout:\n' + stdout + '\nEVB stderr:\n' + stderr); | ||
err = new Error(`Failed to pack EVB project!\nEVB stdout:\n${stdout}\nEVB stderr:\n${stderr}`); | ||
} | ||
} | ||
if (err) { | ||
throw err; | ||
throw err; | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
{ | ||
"type": "module", | ||
"devDependencies": { | ||
"generate-evb": "git+ssh://[email protected]:Jenway/generate-evb" | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters