Installer: detect all Visual Studio versions and install into each#34
Installer: detect all Visual Studio versions and install into each#34gustavobagno wants to merge 1 commit into
Conversation
InstallToVS previously matched only a hardcoded C:\...\Visual Studio\2022\... path from the dynamics:// registry handler (or the DynamicsVSTools env var), so it missed VS 2019, VS 2026 (v18), non-C: drives, and installed into a single instance. - Rewrite FindExtensionFolders to enumerate every VS install via vswhere (plus a filesystem fallback, the registry hint and the env override), validate each Extensions\<id>\AddinExtensions folder by the Microsoft.Dynamics.Framework.Tools marker, and copy into all matches. Add /silent for scripted runs. - Add Install.ps1: self-elevating, version-agnostic installer that downloads the release (or -Dev / -Source local build) and installs into every VS instance with the D365 dev tools; -ListOnly for a read-only dry run. - README: document the one-line install and the new auto-detection. - Rebuild InstallToVS.exe.
There was a problem hiding this comment.
Pull request overview
This PR improves the TRUDUtilsD365 installer experience by detecting all Visual Studio instances that have the Dynamics 365 F&O dev tools installed (across versions/editions/drives) and installing the add-in into each applicable instance, plus adding a one-line PowerShell installer.
Changes:
- Updated
InstallToVS.exelogic to discover and validate multiple D365 add-in targets (vswhere + filesystem + registry + env override), install into each, and return meaningful exit codes with an optional/silentmode. - Added
Install.ps1as a self-contained installer script supporting discovery, elevation, latest release/dev/local source installs, and list-only mode. - Documented the new recommended installation approach and auto-detection behavior in
README.md.
Reviewed changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| README.md | Adds recommended one-line installer instructions and notes multi-VS auto-detection behavior. |
| InstallToVS/Program.cs | Reworks target discovery/validation and installs into all matching VS instances with improved exit codes and /silent. |
| Install.ps1 | New installer script that discovers valid targets, downloads (or uses local) binaries, and installs across instances with optional elevation. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Thanks @gustavobagno . Can you describe what problem you are trying to resolve? |
Problem
InstallToVS.exelocates the VS add-in folder by matching a hardcoded path against thedynamics://registry handler:That breaks whenever the D365 dev tools are anywhere else:
...\Microsoft Visual Studio\18\...) never match.C:drive (e.g.D:\Microsoft Visual Studio\2019\Professional) never match.dynamics://last, which is often not the one you use.The
DynamicsVSToolsenvironment variable is the only workaround today, and it is unset on many machines (including the Unified Developer Experience cloud boxes).Change
InstallToVS/Program.csFindExtensionFolders()now returns all target folders, discovered by combining:vswhere -all -prerelease -products *— every VS installation root (any drive / edition / version);vswhereis absent);dynamics://registry hint;DynamicsVSToolsoverride.Every candidate
Extensions\<id>\AddinExtensionsfolder — including the env override — is validated by the presence of theMicrosoft.Dynamics.Framework.Tools*.dllmarker, so the add-in only lands where the D365 dev tools actually exist. It copies into every match, reports per-folder success/failure, resolves its source binaries from the installer's own directory (not the working directory), and returns a meaningful exit code (0all /2partial /1error). Added a/silentswitch for scripted runs. EmptyProgramFiles*values are guarded so they never degrade to relative paths.Install.ps1(new)A self-contained, self-elevating installer using the same discovery:
/releases/latest), themasterdev build (-Dev), or a local build (-Source <folder>);-ListOnlyprints the target folders without changing anything (read-only, no elevation);-Wait -PassThruand propagates the elevated run's exit code (and treats a cancelled UAC prompt as a clean non-zero exit) so unattended callers can detect success/failure;.dllis required; the.pdbis optional (a missing symbols file only warns);-NoPauseis honoured across elevation.README.mdDocuments the one-line install and the auto-detection behaviour.
InstallToVS.exeis rebuilt.Testing
On a box with VS 2019 (on
D:), VS 2022 and VS 2026 installed, where only 2022 and 2026 have the D365 dev tools:Install.ps1 -ListOnlyand the rebuiltInstallToVS.exeboth discover exactly the VS 2022 and VS 2026AddinExtensionsfolders and correctly exclude VS 2019 (no D365 marker).-UseBasicParsingdownloads and theConvertFrom-Json/Invoke-RestMethodcalls were verified under both Windows PowerShell 5.1 and PowerShell 7.6.InstallToVS.exebuilds clean with MSBuild (.NET Framework 4.6.1, no external dependencies).