How to fix error in Visual Studio code in regard to the visual studio developer being applied

Jingly Schmidt 0 Reputation points
2026-01-10T14:22:17.84+00:00

I am getting an error when trying to run C++ code in Visual Studio Code that says "The source code could not be built because the Visual Studio developer environment was not applied", how do I fix this issue?

Thnak you

Developer technologies | Visual Studio | Extensions

Locked Question. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

6 answers

Sort by: Most helpful
  1. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more

  2. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more

  3. Raoul Van Hal 0 Reputation points
    2026-07-28T11:28:55.9866667+00:00

    I've faced the same issue but for my case the issue was related to company policy related to registry edits. It's blocked, but it's seems to be very excessive as it also blocks any READS of the registry.

    For me the problem is that my company policy is blocking registry queries like "reg query" for getting values from the registry. The C:\Program Files\Microsoft Visual Studio\2022\Professional\Common7\Tools\vsdevcmd\core\winsdk.bat file uses this command to determine and set specific environment variables. If those environment variables are not set, then VSCode will not be able to properly setup the environment. As a workaround I've replaced the "req query" calls with the powershell equivalent in the winsdk.bat file (AI is your friend). Luckily using powershell it is allowed to read the registry according to my companies policies. After making those changes and then in VSCode do Ctrl+Shift+P " C/C++: Clear Visual Studio Developer Environment" and then Ctrl+Shift+P "C/C++: Set Visual Studio Developer Environment" it started to work.

    To assert if this fix will work for you, just try to run "REG QUERY HKLM\Software\Microsoft\ResKit /v Version". If you get "ERROR: Registry editing has been disabled by your administrator." then the above solution should work.

    This is a workaround and in my opinion MS should update the winsdk.bat (as well as the dotnet.bat) to use Powershell instead of "reg query" to query the registry.

    Was this answer helpful?

  4. Bruce (SqlWork.com) 85,111 Reputation points
    2026-01-10T17:29:21.0166667+00:00

    To support c++ in vs code you need to install the extension, and you need to install a c++ build system.

    https://marketplace.visualstudio.com/items?itemName=ms-vscode.cpptools

    note: if you pick MSVC (just the C# extension) you will need a visual studio license. You can pick community if you qualify.

    Was this answer helpful?

  5. AI answer

    2026-01-10T14:22:24.9433333+00:00

    To fix the error "The source code could not be built because the Visual Studio developer environment was not applied" in Visual Studio Code, you can try the following steps:

    1. Ensure Visual Studio is Installed: Make sure that you have Visual Studio installed on your system, as Visual Studio Code relies on the Visual Studio build tools for C++ development.
    2. Install C++ Build Tools: If you haven't installed the C++ build tools, you can do so by modifying your Visual Studio installation. Go to the Visual Studio Installer and ensure that the C++ development tools are selected.
    3. Set Up Environment Variables: Ensure that the environment variables for Visual Studio are correctly set. You might need to open the Developer Command Prompt for Visual Studio to ensure all paths are set correctly.
    4. Check Your Configuration: In Visual Studio Code, check your tasks.json file to ensure that the build tasks are correctly configured to use the Visual Studio compiler.
    5. Use the Correct Build Command: Make sure you are using the correct command to build your C++ project. You might need to specify the build command in your tasks or use the integrated terminal to run the build command manually.
    6. Restart Visual Studio Code: Sometimes, simply restarting Visual Studio Code can resolve environment-related issues.

    If these steps do not resolve the issue, consider checking the Visual Studio Code documentation or forums for additional troubleshooting tips specific to your setup.

    AI-generated content may be incorrect. Read our transparency notes for more information.

    Was this answer helpful?