Repository: flutter
Issue: [Windows] error MSB8036: The Windows SDK version 10.0.19041.0 was not found
Labels: tool,platform-windows,a: desktop,a: build,P2,team-windows,triaged-windows

I was trying to build a default app ( tap counting app) that comes with flutter for windows desktop.
**NOTE: Build success for Android and Web.**
**Edited: Tried creating a hello world windows console application through Visual Studio that didn't run.**

## Steps to Reproduce
<!-- Please tell us exactly how to reproduce the problem you are running into. -->

1. ran `flutter create test_app`
2. ran `flutter run -d windows` on the project folder
Here is the result from running:
```
Launching lib\main.dart on Windows in debug mode...
CMake Error at CMakeLists.txt:2 (project):
  Failed to run MSBuild command:

    E:/Program Files/Microsoft Visual Studio/2022/Community/MSBuild/Current/Bin/amd64/MSBuild.exe

  to get the value of VCTargetsPath:

    Microsoft (R) Build Engine version 17.1.0+ae57d105c for .NET Framework
    Copyright (C) Microsoft Corporation. All rights reserved.

    Build started 25/03/2022 11:02:14.
    Project "E:\project\test_app\build\windows\CMakeFiles\3.22.22022201-MSVC_2\VCTargetsPath.vcxproj" on node 1 (default targets).
    E:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.Cpp.WindowsSDK.targets(46,5): error MSB8036: The Windows SDK version 10.0.19041.0 was not found. Install the required version of Windows SDK or change the SDK version in the project property pages or by right-clicking the solution and selecting "Retarget solution". [E:\project\test_app\build\windows\CMakeFiles\3.22.22022201-MSVC_2\VCTargetsPath.vcxproj]
    Done Building Project "E:\project\test_app\build\windows\CMakeFiles\3.22.22022201-MSVC_2\VCTargetsPath.vcxproj" (default targets) -- FAILED.

    Build FAILED.

    "E:\project\test_app\build\windows\CMakeFiles\3.22.22022201-MSVC_2\VCTargetsPath.vcxproj" (default target) (1) ->
    (_CheckWindowsSDKInstalled target) ->
      E:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.Cpp.WindowsSDK.targets(46,5): error MSB8036: The Windows SDK version 10.0.19041.0 was not found. Install the required version of Windows SDK or change the SDK version in the project property pages or by right-clicking the solution and selecting "Retarget solution". [E:\project\test_app\build\windows\CMakeFiles\3.22.22022201-MSVC_2\VCTargetsPath.vcxproj]

        0 Warning(s)
        1 Error(s)

    Time Elapsed 00:00:04.73


  Exit code: 1

Building Windows application...                                         
Exception: Unable to generate build files

```
<details>
<summary>`flutter run --verbose -d windows`</summary>

```
[  +58 ms] executing: [E:\software\flutter/] git -c log.showSignature=false log -n 1 --pretty=format:%H
[ +420 ms] Exit code 0 from: git -c log.showSignature=false log -n 1 --pretty=format:%H
[   +1 ms] 7e9793dee1b85a243edd0e06cb1658e98b077561
[        ] executing: [E:\software\flutter/] git tag --points-at 7e9793dee1b85a243edd0e06cb1658e98b077561
[  +42 ms] Exit code 0 from: git tag --points-at 7e9793dee1b85a243edd0e06cb1658e98b077561
[        ] 2.10.3
[   +7 ms] executing: [E:\software\flutter/] git rev-parse --abbrev-ref --symbolic @{u}
[  +32 ms] Exit code 0 from: git rev-parse --abbrev-ref --symbolic @{u}
[        ] origin/stable
[        ] executing: [E:\software\flutter/] git ls-remote --get-url origin
[  +27 ms] Exit code 0 from: git ls-remote --get-url origin
[        ] https://github.com/flutter/flutter.git
[ +102 ms] executing: [E:\software\flutter/] git rev-parse --abbrev-ref HEAD
[  +32 ms] Exit code 0 from: git rev-parse --abbrev-ref HEAD
[        ] stable
[  +61 ms] Artifact Instance of 'AndroidGenSnapshotArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'AndroidInternalBuildArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'IOSEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterWebSdk' is not required, skipping update.
[  +10 ms] Artifact Instance of 'WindowsEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'WindowsUwpEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'MacOSEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'LinuxEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'LinuxFuchsiaSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'MacOSFuchsiaSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterRunnerSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterRunnerDebugSymbols' is not required, skipping update.
[  +71 ms] Artifact Instance of 'AndroidGenSnapshotArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'AndroidInternalBuildArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'IOSEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterWebSdk' is not required, skipping update.
[   +4 ms] Artifact Instance of 'WindowsUwpEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'MacOSEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'LinuxEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'LinuxFuchsiaSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'MacOSFuchsiaSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterRunnerSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterRunnerDebugSymbols' is not required, skipping update.
[ +124 ms] Skipping pub get: version match.
[  +72 ms] Generating E:\project\test_app\android\app\src\main\java\io\flutter\plugins\GeneratedPluginRegistrant.java
[  +92 ms] Initializing file store
[  +11 ms] Skipping target: gen_localizations
[   +6 ms] gen_dart_plugin_registrant: Starting due to {InvalidatedReasonKind.inputChanged: The following inputs have updated contents: E:\project\test_app\.dart_tool\package_config_subset}
[  +27 ms] gen_dart_plugin_registrant: Complete
[   +3 ms] Skipping target: _composite
[   +2 ms] complete
[   +6 ms] Launching lib\main.dart on Windows in debug mode...
[   +6 ms] E:\software\flutter\bin\cache\dart-sdk\bin\dart.exe --disable-dart-dev E:\software\flutter\bin\cache\artifacts\engine\windows-x64\frontend_server.dart.snapshot --sdk-root
E:\software\flutter\bin\cache\artifacts\engine\common\flutter_patched_sdk/ --incremental --target=flutter --debugger-module-names --experimental-emit-debug-metadata -DFLUTTER_WEB_AUTO_DETECT=true --output-dill
C:\Users\rosha\AppData\Local\Temp\flutter_tools.41575f38\flutter_tool.c249e1fa\app.dill --packages E:\project\test_app\.dart_tool\package_config.json -Ddart.vm.profile=false -Ddart.vm.product=false --enable-asserts       
--track-widget-creation --filesystem-scheme org-dartlang-root --initialize-from-dill build\c075001b96339384a97db4862b8ab8db.cache.dill.track.dill --enable-experiment=alternative-invalidation-strategy
[  +31 ms] executing: C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe -format json -products * -utf8 -latest -version 16 -requires Microsoft.VisualStudio.Workload.NativeDesktop
Microsoft.VisualStudio.Component.VC.Tools.x86.x64 Microsoft.VisualStudio.Component.VC.CMake.Project
[  +56 ms] Exit code 0 from: C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe -format json -products * -utf8 -latest -version 16 -requires Microsoft.VisualStudio.Workload.NativeDesktop
Microsoft.VisualStudio.Component.VC.Tools.x86.x64 Microsoft.VisualStudio.Component.VC.CMake.Project
[   +1 ms] [
             {
               "instanceId": "9b7a1128",
               "installDate": "2022-03-24T00:24:45Z",
               "installationName": "VisualStudio/17.1.2+32319.34",
               "installationPath": "E:\\Program Files\\Microsoft Visual Studio\\2022\\Community",
               "installationVersion": "17.1.32319.34",
               "productId": "Microsoft.VisualStudio.Product.Community",
               "productPath": "E:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\Common7\\IDE\\devenv.exe",
               "state": 4294967295,
               "isComplete": true,
               "isLaunchable": true,
               "isPrerelease": false,
               "isRebootRequired": false,
               "displayName": "Visual Studio Community 2022",
               "description": "Powerful IDE, free for students, open-source contributors, and individuals",
               "channelId": "VisualStudio.17.Release",
               "channelUri": "https://aka.ms/vs/17/release/channel",
               "enginePath": "C:\\Program Files (x86)\\Microsoft Visual Studio\\Installer\\resources\\app\\ServiceHub\\Services\\Microsoft.VisualStudio.Setup.Service",
               "installedChannelUri": "https://aka.ms/vs/17/release/channel",
               "releaseNotes": "https://docs.microsoft.com/en-us/visualstudio/releases/2022/release-notes-v17.1#17.1.2",
               "thirdPartyNotices": "https://go.microsoft.com/fwlink/?LinkId=661288",
               "updateDate": "2022-03-24T00:24:45.0772403Z",
               "catalog": {
                 "buildBranch": "d17.1",
                 "buildVersion": "17.1.32319.34",
                 "id": "VisualStudio/17.1.2+32319.34",
                 "localBuild": "build-lab",
                 "manifestName": "VisualStudio",
                 "manifestType": "installer",
                 "productDisplayVersion": "17.1.2",
                 "productLine": "Dev17",
                 "productLineVersion": "2022",
                 "productMilestone": "RTW",
                 "productMilestoneIsPreRelease": "False",
                 "productName": "Visual Studio",
                 "productPatchVersion": "2",
                 "productPreReleaseMilestoneSuffix": "1.0",
                 "productSemanticVersion": "17.1.2+32319.34",
                 "requiredEngineVersion": "3.1.2196.8931"
               },
               "properties": {
                 "campaignId": "2030",
                 "channelManifestId": "VisualStudio.17.Release/17.1.2+32319.34",
                 "nickname": "",
                 "setupEngineFilePath": "C:\\Program Files (x86)\\Microsoft Visual Studio\\Installer\\setup.exe"
               }
             }
           ]
[   +5 ms] Building Windows application...
[  +19 ms] <- compile package:test_app/main.dart
[   +1 ms] executing: E:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe -S E:\project\test_app\windows -B build\windows -G Visual Studio 17 2022      
[  +61 ms] -- Selecting Windows SDK version 10.0.19041.0 to target Windows 10.0.22000.
[+4953 ms] CMake Error at CMakeLists.txt:2 (project):
[   +2 ms]   Failed to run MSBuild command:
[        ]     E:/Program Files/Microsoft Visual Studio/2022/Community/MSBuild/Current/Bin/amd64/MSBuild.exe
[        ]   to get the value of VCTargetsPath:
[        ]     Microsoft (R) Build Engine version 17.1.0+ae57d105c for .NET Framework
[        ]     Copyright (C) Microsoft Corporation. All rights reserved.
[        ]     Build started 25/03/2022 10:53:38.
[        ]     Project "E:\project\test_app\build\windows\CMakeFiles\3.22.22022201-MSVC_2\VCTargetsPath.vcxproj" on node 1 (default targets).
[        ]     E:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.Cpp.WindowsSDK.targets(46,5): error MSB8036: The Windows SDK version 10.0.19041.0 was not found. Install the      
required version of Windows SDK or change the SDK version in the project property pages or by right-clicking the solution and selecting "Retarget solution".
[E:\project\test_app\build\windows\CMakeFiles\3.22.22022201-MSVC_2\VCTargetsPath.vcxproj]
[   +1 ms]     Done Building Project "E:\project\test_app\build\windows\CMakeFiles\3.22.22022201-MSVC_2\VCTargetsPath.vcxproj" (default targets) -- FAILED.
[        ]     Build FAILED.
[        ]     "E:\project\test_app\build\windows\CMakeFiles\3.22.22022201-MSVC_2\VCTargetsPath.vcxproj" (default target) (1) ->
[        ]     (_CheckWindowsSDKInstalled target) -> 
[        ]       E:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.Cpp.WindowsSDK.targets(46,5): error MSB8036: The Windows SDK version 10.0.19041.0 was not found. Install the    
required version of Windows SDK or change the SDK version in the project property pages or by right-clicking the solution and selecting "Retarget solution".
[E:\project\test_app\build\windows\CMakeFiles\3.22.22022201-MSVC_2\VCTargetsPath.vcxproj]
[   +2 ms]         0 Warning(s)
[        ]         1 Error(s)
[        ]     Time Elapsed 00:00:04.73
[        ]   Exit code: 1
[        ] -- Configuring incomplete, errors occurred!
[        ] See also "E:/project/test_app/build/windows/CMakeFiles/CMakeOutput.log".
[  +12 ms] Building Windows application... (completed in 5.1s)
[+1232 ms] Exception: Unable to generate build files
[   +1 ms] "flutter run" took 6,870ms.
[   +4 ms]
           #0      throwToolExit (package:flutter_tools/src/base/common.dart:10:3)
           #1      RunCommand.runCommand (package:flutter_tools/src/commands/run.dart:687:9)
           <asynchronous suspension>
           #2      FlutterCommand.run.<anonymous closure> (package:flutter_tools/src/runner/flutter_command.dart:1161:27)
           <asynchronous suspension>
           #3      AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
           <asynchronous suspension>
           #4      CommandRunner.runCommand (package:args/command_runner.dart:209:13)
           <asynchronous suspension>
           #5      FlutterCommandRunner.runCommand.<anonymous closure> (package:flutter_tools/src/runner/flutter_command_runner.dart:281:9)
           <asynchronous suspension>
           #6      AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
           <asynchronous suspension>
           #7      FlutterCommandRunner.runCommand (package:flutter_tools/src/runner/flutter_command_runner.dart:229:5)
           <asynchronous suspension>
           #8      run.<anonymous closure>.<anonymous closure> (package:flutter_tools/runner.dart:62:9)
           <asynchronous suspension>
           #9      AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
           <asynchronous suspension>
           #10     main (package:flutter_tools/executable.dart:94:3)
           <asynchronous suspension>


[ +106 ms] ensureAnalyticsSent: 102ms
[   +1 ms] Running shutdown hooks
[        ] Shutdown hooks complete
[        ] exiting with code 1
```
</details>

<details>
<summary>`flutter doctor -v`</summary>

```
[√] Flutter (Channel stable, 2.10.3, on Microsoft Windows [Version 10.0.22000.588], locale en-GB)
    • Flutter version 2.10.3 at E:\software\flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 7e9793dee1 (3 weeks ago), 2022-03-02 11:23:12 -0600
    • Engine revision bd539267b4
    • Dart version 2.16.1
    • DevTools version 2.9.2

[√] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
    • Android SDK at E:\software\android
    • Platform android-31, build-tools 30.0.2
    • ANDROID_HOME = E:\software\android
    • Java binary at: E:\software\java\jdk-11.0.14\bin\java
    • Java version Java(TM) SE Runtime Environment 18.9 (build 11.0.14+8-LTS-263)
    • All Android licenses accepted.

[X] Chrome - develop for the web (Cannot find Chrome executable at .\Google\Chrome\Application\chrome.exe)
    ! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.

[√] Visual Studio - develop for Windows (Visual Studio Community 2022 17.1.2)
    • Visual Studio at E:\Program Files\Microsoft Visual Studio\2022\Community
    • Visual Studio Community 2022 version 17.1.32319.34
    • Windows 10 SDK version 10.0.19041.0

[!] Android Studio (not installed)
    • Android Studio not found; download from https://developer.android.com/studio/index.html
      (or visit https://flutter.dev/docs/get-started/install/windows#android-setup for detailed instructions).

[√] Connected device (3 available)
    • Pixel 4a (mobile) • 09011JEC212110 • android-arm64  • Android 12 (API 31)
    • Windows (desktop) • windows        • windows-x64    • Microsoft Windows [Version 10.0.22000.588]
    • Edge (web)        • edge           • web-javascript • Microsoft Edge 99.0.1150.46

[√] HTTP Host Availability
    • All required HTTP hosts are available

! Doctor found issues in 2 categories.
```
</details>