mirror of
https://github.com/vczh-libraries/Release.git
synced 2026-03-23 07:42:52 +08:00
Update prompt
This commit is contained in:
14
.github/Scripts/copilotBuild.ps1
vendored
14
.github/Scripts/copilotBuild.ps1
vendored
@@ -1,3 +1,15 @@
|
||||
param(
|
||||
[string]$Configuration = "Debug",
|
||||
[string]$Platform = "x64"
|
||||
)
|
||||
|
||||
if (($Configuration -ne "Debug") -and ($Configuration -ne "Release")) {
|
||||
throw "Invalid configuration: $Configuration. Allowed values are Debug or Release."
|
||||
}
|
||||
if (($Platform -ne "x64") -and ($Platform -ne "Win32")) {
|
||||
throw "Invalid platform: $Platform. Allowed values are x64 or Win32."
|
||||
}
|
||||
|
||||
. $PSScriptRoot\copilotShared.ps1
|
||||
|
||||
# Remove log files
|
||||
@@ -17,8 +29,6 @@ if ($vsdevcmd -eq $null) {
|
||||
}
|
||||
|
||||
# Execute msbuild with output to both console and log file
|
||||
$Configuration = "Debug"
|
||||
$Platform = "x64"
|
||||
$msbuild_arguments = "MSBUILD `"$solutionFile`" /m:8 $rebuildControl /p:Configuration=`"$Configuration`";Platform=`"$Platform`""
|
||||
$cmd_arguments = "`"`"$vsdevcmd`" & $msbuild_arguments"
|
||||
|
||||
|
||||
49
.github/Scripts/copilotExecute.ps1
vendored
49
.github/Scripts/copilotExecute.ps1
vendored
@@ -1,14 +1,36 @@
|
||||
param(
|
||||
[Parameter(Mandatory=$true)]
|
||||
[string]$Executable
|
||||
[string]$Mode,
|
||||
[Parameter(Mandatory=$true)]
|
||||
[string]$Executable,
|
||||
[string]$Configuration = $null,
|
||||
[string]$Platform = $null
|
||||
)
|
||||
|
||||
if (($Mode -ne "CLI") -and ($Mode -ne "UnitTest")) {
|
||||
throw "Invalid mode: $Mode. Allowed values are CLI or UnitTest."
|
||||
}
|
||||
|
||||
if (($Configuration -ne $null) -ne ($Platform -ne $null)) {
|
||||
throw "Configuration and Platform parameters should be set or unset at the same time."
|
||||
}
|
||||
if ($Configuration -ne $null) {
|
||||
if (($Configuration -ne "Debug") -and ($Configuration -ne "Release")) {
|
||||
throw "Invalid configuration: $Configuration. Allowed values are Debug or Release."
|
||||
}
|
||||
if (($Platform -ne "x64") -and ($Platform -ne "Win32")) {
|
||||
throw "Invalid platform: $Platform. Allowed values are x64 or Win32."
|
||||
}
|
||||
}
|
||||
|
||||
. $PSScriptRoot\copilotShared.ps1
|
||||
|
||||
# Remove log files
|
||||
$logFile = "$PSScriptRoot\Execute.log"
|
||||
$logFileUnfinished = "$logFile.unfinished"
|
||||
Remove-Item -Path $logFile, $logFileUnfinished -Force -ErrorAction SilentlyContinue
|
||||
if ($Mode -eq "UnitTest") {
|
||||
# Remove log files
|
||||
$logFile = "$PSScriptRoot\Execute.log"
|
||||
$logFileUnfinished = "$logFile.unfinished"
|
||||
Remove-Item -Path $logFile, $logFileUnfinished -Force -ErrorAction SilentlyContinue
|
||||
}
|
||||
|
||||
# Ensure the executable name has .exe extension
|
||||
if ($Executable.EndsWith(".exe")) {
|
||||
@@ -20,14 +42,23 @@ $executableName = $Executable + ".exe"
|
||||
$solutionFolder = GetSolutionDir
|
||||
|
||||
# Find the file with the latest modification time
|
||||
$latestFile = GetLatestModifiedExecutable $solutionFolder $executableName
|
||||
if ($Configuration -ne $null) {
|
||||
$latestFile = GetLatestModifiedExecutable $solutionFolder $executableName
|
||||
} else {
|
||||
$latestFile = GetSpecifiedExecutable $solutionFolder $executableName $Configuration $Platform
|
||||
}
|
||||
Write-Host "Selected $executableName`: $($latestFile.Path) (Modified: $($latestFile.LastWriteTime))"
|
||||
|
||||
# Try to read debug arguments from the corresponding .vcxproj.user file
|
||||
$debugArgs = GetDebugArgs $solutionFolder $latestFile $Executable
|
||||
|
||||
# Execute the selected executable with debug arguments and save output to log file
|
||||
$commandLine = "`"$($latestFile.Path)`" /C $debugArgs"
|
||||
& { $commandLine; & cmd.exe /S /C $commandLine 2>&1 } | Tee-Object -FilePath $logFileUnfinished
|
||||
Rename-Item -Path $logFileUnfinished -NewName $logFile -Force
|
||||
if ($Mode -eq "UnitTest") {
|
||||
$commandLine = "`"$($latestFile.Path)`" /C $debugArgs"
|
||||
& { $commandLine; & cmd.exe /S /C $commandLine 2>&1 } | Tee-Object -FilePath $logFileUnfinished
|
||||
Rename-Item -Path $logFileUnfinished -NewName $logFile -Force
|
||||
} else {
|
||||
$commandLine = "`"$($latestFile.Path)`" $debugArgs"
|
||||
& { $commandLine; & cmd.exe /S /C $commandLine 2>&1 }
|
||||
}
|
||||
exit $LASTEXITCODE
|
||||
|
||||
31
.github/Scripts/copilotShared.ps1
vendored
31
.github/Scripts/copilotShared.ps1
vendored
@@ -28,14 +28,37 @@ function GetSolutionDir {
|
||||
return $solutionFolder
|
||||
}
|
||||
|
||||
function GetLatestModifiedExecutable($solutionFolder, $executableName) {
|
||||
# Define configuration to path mappings
|
||||
$configToPathMap = @{
|
||||
function GetExecutableMap($solutionFolder, $executableName) {
|
||||
return @{
|
||||
"Debug|Win32" = "$solutionFolder\Debug\$executableName"
|
||||
"Release|Win32" = "$solutionFolder\Release\$executableName"
|
||||
"Debug|x64" = "$solutionFolder\x64\Debug\$executableName"
|
||||
"Release|x64" = "$solutionFolder\x64\Release\$executableName"
|
||||
}
|
||||
}
|
||||
|
||||
function GetSpecifiedExecutable($solutionFolder, $executableName, $configuration, $platform) {
|
||||
# Define configuration to path mappings
|
||||
$configToPathMap = GetExecutableMap $solutionFolder $executableName
|
||||
|
||||
# Find existing files and get their modification times with configuration info
|
||||
$path = $configToPathMap["$configuration|$platform"];
|
||||
|
||||
if (Test-Path $path) {
|
||||
$fileInfo = Get-Item $path
|
||||
return [PSCustomObject]@{
|
||||
Path = $path
|
||||
Configuration = $config
|
||||
LastWriteTime = $fileInfo.LastWriteTime
|
||||
}
|
||||
} else {
|
||||
throw "No $executableName for $configuration|$platform does not exist, please make sure the build was successful."
|
||||
}
|
||||
}
|
||||
|
||||
function GetLatestModifiedExecutable($solutionFolder, $executableName) {
|
||||
# Define configuration to path mappings
|
||||
$configToPathMap = GetExecutableMap $solutionFolder $executableName
|
||||
|
||||
# Find existing files and get their modification times with configuration info
|
||||
$existingFiles = @()
|
||||
@@ -52,7 +75,7 @@ function GetLatestModifiedExecutable($solutionFolder, $executableName) {
|
||||
}
|
||||
|
||||
if ($existingFiles.Count -eq 0) {
|
||||
throw "No $executableName files found in any of the expected locations."
|
||||
throw "No $executableName files found in any of the expected locations, please make sure the build was successful."
|
||||
}
|
||||
|
||||
return $existingFiles | Sort-Object LastWriteTime -Descending | Select-Object -First 1
|
||||
|
||||
Reference in New Issue
Block a user