CMake Error on Windows: could not find any instance of Visual Studio
My flet build windows was working. Then I installed Visual Studio 2026 with full C++ Desktop workload. I confirmed that CMake was included in my component selection.
Once I removed VS 2022 to save space, this broke my flet build. I got a CMake error. Snippet from output:
CMake Error at CMakeLists.txt:3 (project):
Generator
Visual Studio 16 2019
could not find any instance of Visual Studio.
Unable to generate build files
I tried installing VS Build Tools 2022, choosing C++ Desktop workload, but that didn't cut it. Same error, even after a reboot.
So I begrudgingly put VS 2022 back on my machine, with just the C++ Desktop workload. Restarted my machine. Flet build is still broken! Same error.
For what it's worth, I completely deleted my build folder before each build.
Any ideas?
Try deleting $HOME\flutter directory?
@FeodorFitsner tried deleting %userprofile%\flutter, but alas I got the same error on the build (after it re-downloaded and re-installed Flutter).
Update: It looks like Flutter has since added support for Visual Studio 2026. VS 2026 breaks old Flutter's VS version selector by making it fall through to the default version of 2019. So as of now, I can't build Flet Windows projects! Don't want to revert to VS 2022 just to fix this.
Looks like you guys are planning to upgrade Flutter version. Any way to hack it in the meantime? Thanks.
We will absolutely upgrade Flutter to 3.39 when it's out, to support VS 2026.
Confirmed I can see VS 2026 support added in flutter-3.39-candidate.0 branch of Flutter.
Even on master the support still seems to be broken:
I have re-created windows packages with flutter create --platforms windows. Then building for windows with flutter build windows fails with the following message:
CMake Error: Error: generator : Visual Studio 18 2026
Does not match the generator used previously: Visual Studio 17 2022
Either remove the CMakeCache.txt file and CMakeFiles directory or choose a different binary directory.
Building Windows application... 50ms
Unable to generate build files
IMHO, the fix for this issue should be hotfixed into stable as users cannot install old Visual Studio versions unless they have an corresponding Visual Code subscription.
Closing in favor of #5825