diff options
| author | 魏曹先生 <1992414357@qq.com> | 2026-01-09 23:58:47 +0800 |
|---|---|---|
| committer | 魏曹先生 <1992414357@qq.com> | 2026-01-09 23:59:18 +0800 |
| commit | 75f7578d784a4e209da4b29a80d27940197d8945 (patch) | |
| tree | 5086f022beb3e56321940fc7d80e150b518e8ea3 /Pre-Build.ps1 | |
| parent | 6dedba9e3cedf6463f25460eba84111d6a0bd0dd (diff) | |
Rename build scripts to Pre-Build
Diffstat (limited to 'Pre-Build.ps1')
| -rw-r--r-- | Pre-Build.ps1 | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/Pre-Build.ps1 b/Pre-Build.ps1 new file mode 100644 index 0000000..d8705a2 --- /dev/null +++ b/Pre-Build.ps1 @@ -0,0 +1,61 @@ +# Set current working directory to the script's directory +Set-Location -Path $PSScriptRoot + +# Define the path to the target CLI executable +$cliPath = ".\.Temp\Debug\JustEnoughVCS.exe" + +# Check if the target CLI file already exists +if (-not (Test-Path $cliPath)) { + # If the file does not exist, define the relative path to the command-line project directory + $commandLineDir = ".\..\CommandLine" + + # Check if the command-line project directory exists + if (-not (Test-Path $commandLineDir)) { + # If the directory does not exist, output an error and exit the script + Write-Error "Error: $commandLineDir Not Found!" + exit 1 + } + + # Define the path to the pre-built CLI executable + $jvExePath = "$commandLineDir\.temp\deploy\bin\jv.exe" + + # Check if the pre-built CLI file exists + if (Test-Path $jvExePath) { + # If the pre-built file exists, ensure the target directory exists + $null = New-Item -ItemType Directory -Path (Split-Path $cliPath) -Force + # Copy the pre-built file to the target location + Copy-Item -Path $jvExePath -Destination $cliPath -Force + # Output a completion notification + Write-Host "CLI copied to $cliPath" + } + else { + # If the pre-built file does not exist, define the path to the deployment script + $deployScriptPath = "$commandLineDir\deploy.ps1" + + # Check if the deployment script exists + if (-not (Test-Path $deployScriptPath)) { + # If the deployment script does not exist, output an error and exit + Write-Error "Error: $deployScriptPath Not Found!" + exit 1 + } + + # Output a notification that building is starting + Write-Host "Building CLI from deploy.ps1..." + # Execute the deployment script to build the CLI + & $deployScriptPath + + # Check if the CLI file is generated after building + if (-not (Test-Path $jvExePath)) { + # If the file still does not exist after building, output an error and exit + Write-Error "Error: $jvExePath Not Found after deployment!" + exit 1 + } + + # Ensure the target directory exists + $null = New-Item -ItemType Directory -Path (Split-Path $cliPath) -Force + # Copy the newly built file to the target location + Copy-Item -Path $jvExePath -Destination $cliPath -Force + # Output a notification that building and copying are complete + Write-Host "CLI built and copied to $cliPath" + } +} |
