From 50ed65987d81a7f4895f14a442111efff3112f11 Mon Sep 17 00:00:00 2001 From: denglihong2007 <98096191+denglihong2007@users.noreply.github.com> Date: Sat, 24 Jan 2026 18:14:30 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=8F=92=E4=BB=B6=E5=BC=80=E5=8F=91?= =?UTF-8?q?=E7=8E=AF=E5=A2=83=E5=88=9D=E5=A7=8B=E5=8C=96=E8=84=9A=E6=9C=AC?= =?UTF-8?q?=E5=87=BA=E9=94=99=20=20[skip=20cliff]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tools/plugin/build.ps1 | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/tools/plugin/build.ps1 b/tools/plugin/build.ps1 index 65f9f96..2c6826c 100644 --- a/tools/plugin/build.ps1 +++ b/tools/plugin/build.ps1 @@ -3,7 +3,7 @@ $devShellVar = [Environment]::GetEnvironmentVariable("VSINSTALLDIR") $msbuildPath = Get-Command MSBuild.exe -ErrorAction SilentlyContinue if (-not $devShellVar -or -not $msbuildPath) { - Write-Host "❌ 请在 Developer PowerShell for Visual Studio 2022 中运行此脚本。" -ForegroundColor Red + Write-Host "❌ 请在 Developer PowerShell for Visual Studio 中运行此脚本。" -ForegroundColor Red exit 1 } $scriptPath = $MyInvocation.MyCommand.Definition @@ -27,7 +27,7 @@ try { dotnet clean CRSim.csproj Write-Host "🔧 正在构建 CRSim,这可能需要 1-2 分钟。" -ForegroundColor Cyan - MSBuild.exe CRSim.csproj /t:Build /p:Configuration=Debug /v:minimal + MSBuild.exe CRSim.csproj /t:Build /p:Configuration=Debug /p:Platform=x64 /v:q /clp:ErrorsOnly } catch { Write-Host "🔥 构建失败" -ForegroundColor Red @@ -37,7 +37,21 @@ catch { Write-Host "🔧 正在设置开发环境变量…" -ForegroundColor Cyan -[Environment]::SetEnvironmentVariable("CRSim_DebugBinaryFile", [System.IO.Path]::GetFullPath("${crSimRoot}\bin\Debug\net9.0-windows10.0.19041.0\CRSim.exe"), 1) -[Environment]::SetEnvironmentVariable("CRSim_DebugBinaryDirectory", [System.IO.Path]::GetFullPath("${crSimRoot}\bin\Debug\net9.0-windows10.0.19041.0\"), 1) +$baseOutDir = Join-Path $crSimRoot "bin\x64\Debug" +$exeFile = Get-ChildItem -Path $baseOutDir -Filter "CRSim.exe" -recurse | + Sort-Object LastWriteTime -Descending | + Select-Object -First 1 -Write-Host "构建完成" -ForegroundColor Green +if ($null -eq $exeFile) { + Write-Host "❌ 找不到构建生成的 CRSim.exe,请检查项目配置。" -ForegroundColor Red + return +} + +$fullExePath = $exeFile.FullName +$binDirectory = $exeFile.DirectoryName + +[Environment]::SetEnvironmentVariable("CRSim_DebugBinaryFile", $fullExePath, 1) +[Environment]::SetEnvironmentVariable("CRSim_DebugBinaryDirectory", $binDirectory, 1) + +Write-Host "✅ 已自动定位路径: $binDirectory" -ForegroundColor Gray +Write-Host "✨ 构建完成" -ForegroundColor Green