Skip to content

native_toolchain_c fails when SQL Server Management Studio is installed — vswhere -latest returns SSMS instead of Visual Studio #3327

@Chaos02

Description

@Chaos02

native_toolchain_c calls vswhere.exe -format json -utf8 -latest -products * to locate a Visual Studio installation with a C++ compiler.
However, when SQL Server Management Studio (SSMS) 22 is installed, vswhere returns SSMS instead of Visual Studio, because SSMS reports a version number of 22.x — which is numerically higher than Visual Studio 2022 (17.x) or even Visual Studio 2026 (18.x).

Since SSMS does not contain a C/C++ compiler, the build fails with:

No compiler configured on host 'windows_x64' with target 'windows_x64'.

Steps to reproduce

  1. Install SQL Server Management Studio 22 (any edition)
  2. Install Visual Studio 2022 or later with the Desktop development with C++ workload
  3. Run any Flutter project that depends on native_toolchain_c (e.g. via win32) (for example by using build_runner)

Expected behavior

A Visual Studio installation containing Microsoft.VisualStudio.Component.VC.Tools.x86.x64 is detected and used.

Actual behavior

vswhere -latest -products * returns SSMS 22 (22.5.11709.299) — which has the highest version number on the system but contains no C++ toolchain:

{
  "installationName": "SSMS/22.5.0+11709.299",
  "installationPath": "C:\\Program Files\\Microsoft SQL Server Management Studio 22\\Release",
  "installationVersion": "22.5.11709.299",
  "productId": "Microsoft.VisualStudio.Product.Ssms",
  "displayName": "SQL Server Management Studio 22"
}

Root cause

The -latest flag in vswhere sorts purely by installationVersion. SSMS uses a version scheme (22.x) that sorts higher than any current Visual Studio release (17.x, 18.x), causing it to win the -latest selection even though it is not a compiler host.

Proposed fix

Add -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 to the vswhere invocation. This filters results to installations that actually contain the x86/x64 C++ build tools, regardless of version ordering. Verified output with this flag:

{
  "installationName": "VisualStudio/18.5.1+11716.220",
  "installationPath": "C:\\Program Files\\Microsoft Visual Studio\\18\\Community",
  "installationVersion": "18.5.11716.220",
  "productId": "Microsoft.VisualStudio.Product.Community",
  "displayName": "Visual Studio Community 2026"
}

The corrected call would be:

vswhere.exe -format json -utf8 -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64

class VisualStudioResolver implements ToolResolver {
@override
Future<List<ToolInstance>> resolve(ToolResolvingContext context) async {
final vswhereInstances = await vswhere.defaultResolver!.resolve(context);
final logger = context.logger;
final result = <ToolInstance>[];
for (final vswhereInstance in vswhereInstances.take(1)) {
final vswhereResult = await runProcess(
executable: vswhereInstance.uri,
arguments: ['-format', 'json', '-utf8', '-latest', '-products', '*'],
logger: logger,
);
final instances = parseVswhere(vswhereResult.stdout, logger);
result.addAll(instances);
}
return result;
}

Workaround

Until fixed: uninstall SSMS 22, or manually set the CC/compiler environment variables to bypass vswhere detection.

Environment

  • native_toolchain_c (via win32 hook)
  • Windows 11
  • SSMS 22.5.0 installed
  • Visual Studio Community 2026 (18.5.1) with C++ workload installed
  • vswhere.exe from C:\Program Files (x86)\Microsoft Visual Studio\Installer\

Possibly related:

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions