Exception: Failed to locate env variables VS140COMNTOOLS or VS120COMNTOOLS

Hi,

when I try to create a Build an run it on Local Machine, I get the following three errors:

  1. “Exception: Failed to locate env variables VS140COMNTOOLS or VS120COMNTOOLS. Utility.GetVSVersion () (at C:/buildslave/unity/build/PlatformDependent/WinRT/SharedSources/CSharp/Utility.cs:623) ApplicationLauncherImpl.Build () (at C:/buildslave/unity/build/PlatformDependent/MetroPlayer/Extensions/Managed/ApplicationLauncher.cs:200) ApplicationLauncher.BuildAndRunOnSingle (BuildLaunchPlayerArgs args, WSASDK wsaSDK, WSABuildAndRunDeployTarget deployTarget) (at C:/buildslave/unity/build/PlatformDependent/MetroPlayer/Extensions/Managed/ApplicationLauncher.cs:60) ApplicationLauncher.BuildAndRun (BuildLaunchPlayerArgs args) (at C:/buildslave/unity/build/PlatformDependent/MetroPlayer/Extensions/Managed/ApplicationLauncher.cs:50) UnityEditor.WSA.BuildPostprocessor.LaunchPlayer (BuildLaunchPlayerArgs args) (at C:/buildslave/unity/build/PlatformDependent/MetroPlayer/Extensions/Managed/ExtensionModule.cs:122) UnityEditor.PostprocessBuildPlayer.Launch (BuildTargetGroup targetGroup, BuildTarget buildTarget, System.String path, System.String productName, BuildOptions options, UnityEditor.BuildReporting.BuildReport buildReport) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/PostprocessBuildPlayer.cs:216) UnityEditor.HostView:OnGUI()”

  2. “Exception: Failed to locate env variables VS140COMNTOOLS or VS120COMNTOOLS.”

  3. “UnityEditor.BuildPlayerWindow+BuildMethodException: Build failed with errors. at UnityEditor.BuildPlayerWindow+DefaultBuildMethods.BuildPlayer (BuildPlayerOptions options) [0x001b9] in C:\buildslave\unity\build\Editor\Mono\BuildPlayerWindowBuildMethods.cs:162 at UnityEditor.BuildPlayerWindow.CallBuildMethods (Boolean askForBuildLocation, BuildOptions defaultBuildOptions) [0x00050] in C:\buildslave\unity\build\Editor\Mono\BuildPlayerWindowBuildMethods.cs:83 UnityEditor.HostView:OnGUI()”

I tried Unity 2017.1.0b6 (64-bit) and Unity 5.6.1f1 (64-bit) on Windows 10 Pro 64 bit with Visual Studio 2017 Community installed and Visual Studio 2015 Tools for Unity installed.

Any idea how to solve this problem?

Thanks in advance
Andrej

Solved 1 and 2 by reinstalling Unity and VS.

Hey i got pretty much the same problem only reinstalling didn’t help. Any insights?

The quick fix that worked for me (using VS 2017 community edition) is add those environment variables myself:
VS140COMNTOOLS=C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\Tools

4 Likes