Skip to content

Installer: detect all Visual Studio versions and install into each#34

Open
gustavobagno wants to merge 1 commit into
TrudAX:masterfrom
gustavobagno:installer-detect-all-vs
Open

Installer: detect all Visual Studio versions and install into each#34
gustavobagno wants to merge 1 commit into
TrudAX:masterfrom
gustavobagno:installer-detect-all-vs

Conversation

@gustavobagno

Copy link
Copy Markdown

Problem

InstallToVS.exe locates the VS add-in folder by matching a hardcoded path against the dynamics:// registry handler:

C:\\Program Files\\Microsoft Visual Studio\\2022\\(Community|Enterprise|Professional)\\Common7\\IDE\\Extensions\\[^\\]+

That breaks whenever the D365 dev tools are anywhere else:

  • VS 2019 and VS 2026 (...\Microsoft Visual Studio\18\...) never match.
  • Installs on a non-C: drive (e.g. D:\Microsoft Visual Studio\2019\Professional) never match.
  • Only the single instance named by the registry handler is targeted, so with several VS versions side by side the others are skipped. The handler also points at whichever VS registered dynamics:// last, which is often not the one you use.

The DynamicsVSTools environment variable is the only workaround today, and it is unset on many machines (including the Unified Developer Experience cloud boxes).

Change

InstallToVS/Program.cs

FindExtensionFolders() now returns all target folders, discovered by combining:

  1. vswhere -all -prerelease -products * — every VS installation root (any drive / edition / version);
  2. a filesystem scan of the standard VS roots (fallback when vswhere is absent);
  3. the dynamics:// registry hint;
  4. the DynamicsVSTools override.

Every candidate Extensions\<id>\AddinExtensions folder — including the env override — is validated by the presence of the Microsoft.Dynamics.Framework.Tools*.dll marker, 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 (0 all / 2 partial / 1 error). Added a /silent switch for scripted runs. Empty ProgramFiles* values are guarded so they never degrade to relative paths.

Install.ps1 (new)

A self-contained, self-elevating installer using the same discovery:

  • installs the latest release (/releases/latest), the master dev build (-Dev), or a local build (-Source <folder>);
  • -ListOnly prints the target folders without changing anything (read-only, no elevation);
  • self-elevation uses -Wait -PassThru and 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;
  • the .dll is required; the .pdb is optional (a missing symbols file only warns);
  • -NoPause is honoured across elevation.

README.md

Documents the one-line install and the auto-detection behaviour.

InstallToVS.exe is 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 -ListOnly and the rebuilt InstallToVS.exe both discover exactly the VS 2022 and VS 2026 AddinExtensions folders and correctly exclude VS 2019 (no D365 marker).
  • The exe was run from an unrelated working directory to confirm it resolves its binaries from its own folder, and returns a non-zero exit code when no target is installed.
  • Discovery, the -UseBasicParsing downloads and the ConvertFrom-Json/Invoke-RestMethod calls were verified under both Windows PowerShell 5.1 and PowerShell 7.6.
  • InstallToVS.exe builds clean with MSBuild (.NET Framework 4.6.1, no external dependencies).

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.
Copilot AI review requested due to automatic review settings July 8, 2026 03:42

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.

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.exe logic 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 /silent mode.
  • Added Install.ps1 as 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.

Comment thread Install.ps1
Comment thread README.md
Comment thread Install.ps1
@TrudAX

TrudAX commented Jul 8, 2026

Copy link
Copy Markdown
Owner

Thanks @gustavobagno . Can you describe what problem you are trying to resolve?
VS2019 will not work with the current tooling; not sure about VS2026. Probably you need to recompile it in VS2026; in this case, the installer is not needed
I suggest you describe your particular problem and created a simple PowerShell script to resolve it, I plan to remove this .exe file anyway

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants