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
- Install SQL Server Management Studio 22 (any edition)
- Install Visual Studio 2022 or later with the Desktop development with C++ workload
- 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:
native_toolchain_ccallsvswhere.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,
vswherereturns SSMS instead of Visual Studio, because SSMS reports a version number of22.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:
Steps to reproduce
native_toolchain_c(e.g. viawin32) (for example by using build_runner)Expected behavior
A Visual Studio installation containing
Microsoft.VisualStudio.Component.VC.Tools.x86.x64is 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
-latestflag invswheresorts purely byinstallationVersion. 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-latestselection even though it is not a compiler host.Proposed fix
Add
-requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64to thevswhereinvocation. 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:
native/pkgs/native_toolchain_c/lib/src/native_toolchain/msvc.dart
Lines 259 to 276 in a49feb0
Workaround
Until fixed: uninstall SSMS 22, or manually set the
CC/compiler environment variables to bypassvswheredetection.Environment
native_toolchain_c(viawin32hook)vswhere.exefromC:\Program Files (x86)\Microsoft Visual Studio\Installer\Possibly related: