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