Skip to content

Find Visual Studio with vswhere in build and deploy scripts - #4

Merged
Gvo87 merged 2 commits into
mainfrom
update-openai-models
Oct 16, 2026
Merged

Gvo87 merged 2 commits into
mainfrom
update-openai-models

Conversation

@Gvo87

@Gvo87 Gvo87 commented Oct 16, 2026 •

Copy link
Copy Markdown
Owner

Why

build.bat and deploy.bat looked for Visual Studio 2022 only at fixed Community/Professional/Enterprise paths and always passed /p:PlatformToolset=v143. On a machine with Visual Studio 2026 (v145) they failed with either "Visual Studio 2022 not found" or MSB8020. MSB8020 also happens when a VS 2022 install without the C++ workload sits next to VS 2026, because the old script picked that install. deploy.bat also used taskkill /f, which could lose unsaved work in Notepad++.

What changed

build.bat

  • Finds the newest Visual Studio (any edition, or Build Tools) that has the C++ x64 tools, using vswhere -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64, then calls its VsDevCmd.bat. It prints a clear error if none is found.
  • Keeps the project's PlatformToolset (v145) when that toolset is installed. Otherwise it passes the newest installed toolset, for example v143 on VS 2022.
  • Runs from the script's own folder, so it also works when started as Administrator (cwd is System32 then). It exits 0 or 1, and /nopause skips the pauses so other scripts can call it.

deploy.bat

  • Checks for admin rights first, so a run without them stops before building or touching Notepad++.
  • Calls build.bat /nopause instead of keeping its own copy of the Visual Studio logic.
  • Asks Notepad++ to close normally (taskkill without /f), so unsaved files are handled as usual: Notepad++ asks whether to save them, or, with session snapshot on, keeps them in its backup. It waits up to 20 s, then lets you retry after closing Notepad++ yourself, or cancel. Cancelling copies nothing.

README.md: the build prerequisites and script description now match.

Testing

  • build.bat on a machine with VS 2026 Community (plus a VS 2022 Professional that has no C++ tools) picks VS 2026 and v145, and builds x64\Release\LLMAssistant.dll from scratch with 0 warnings.
  • Fallback: with the project set to v143, the script reports that v143 is missing, builds with v145, and the build succeeds.
  • No matching Visual Studio, started from System32: clear error, exit code 1.
  • Closing Notepad++: a mock covered not running, closes, cancel, and retry. Real process detection was checked read-only.
  • Closing a real Notepad++ (separate -multiInst instance with its own -settingsDir) with an unsaved edit: with session snapshot off, it stayed open and showed its Save dialog, and the file on disk was unchanged. With snapshot on, the Notepad++ default, it closed without asking and kept the edit in its backup and session for the next start.
  • deploy.bat without admin rights stops at the admin check. Run as Administrator, it deployed a DLL byte-identical to the build (SHA-256 match).

Notes for reviewers

  • CI (build-and-release.yml) is unchanged. It still passes /p:PlatformToolset=v143 on windows-latest (VS 2022), and LLMAssistant.vcxproj stays at v145.
  • When you answer Y to "start Notepad++ now?" at the end of deploy.bat, Notepad++ still starts with admin rights, as it did before.

🤖 Generated with Claude Code

build.bat now finds the newest Visual Studio with the C++ x64 tools
using vswhere, instead of looking for VS 2022 at fixed paths. It keeps
the project's platform toolset (v145) when it is installed and falls
back to the newest installed toolset otherwise, such as v143 on VS 2022.
A /nopause flag lets other scripts call it.

deploy.bat checks for admin rights before doing anything and reuses
build.bat. It asks Notepad++ to close normally instead of running
taskkill /f, so unsaved files get a save prompt, and it won't copy the
DLL while Notepad++ is still open.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Gvo87
Gvo87 requested a balanced review from Copilot October 16, 2026 08:18
@Gvo87 Gvo87 added the AI Created with AI assistance label Oct 16, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Closing Notepad++ with unsaved documents needs human validation on Windows beyond the reported mock tests.

0 open findings

What changed in this PR

Updates Windows build and deployment scripts to discover compatible Visual Studio installations and close Notepad++ without forced termination.

Changes:

  • Detects Visual Studio with vswhere and selects an available platform toolset.
  • Reuses the build script during deployment, checks administrator rights, and adds shutdown retry/cancel handling.
  • Updates build prerequisites and deployment documentation.
File Description
README.md Documents toolset selection and deployment behavior.
deploy.bat Reuses builds and adds safer shutdown handling.
build.bat Discovers Visual Studio and supports toolset fallback and noninteractive use.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Tested deploy's graceful close against a real Notepad++ instance. With
session snapshot off it keeps running and shows its Save dialog; with
snapshot on (Notepad++'s default) it exits without asking and keeps the
unsaved edit in its backup. The README promised a save prompt in every
case, so it now describes both.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Gvo87
Gvo87 merged commit 6343b62 into main Oct 16, 2026
1 check passed
@Gvo87 Gvo87 mentioned this pull request Oct 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI Created with AI assistance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants