Unable to build godot from source on windows

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By PtrMan

I am unable to build the engine from source on windows

**********************************************************************
** Visual Studio 2019 Developer Command Prompt v16.1.0-pre.2.0
** Copyright (c) 2019 Microsoft Corporation
**********************************************************************
S:\win10host\programs\dev\ide\visual studio express 2019 preview>cd C:\godot

S:\win10host\programs\dev\ide\visual studio express 2019 preview>C:

C:\godot>scons p=windows vsproj=yes
scons: Reading SConscript files ...

scons: warning: No version of Visual Studio compiler found - C/C++ compilers most likely not set correctly
File "C:\godot\SConstruct", line 3, in <module>

scons: warning: No version of Visual Studio compiler found - C/C++ compilers most likely not set correctly
File "C:\godot\SConstruct", line 64, in <module>
Configuring for Windows: target=debug, bits=default
Found MSVC compiler: x86
Compiled program architecture will be a 32 bit executable. (forcing bits=32).
KeyError: 'MSVC_VERSION':
  File "C:\godot\SConstruct", line 294:
    detect.configure(env)
  File "./platform/windows\detect.py", line 369:
    configure_msvc(env, manual_msvc_config)
  File "./platform/windows\detect.py", line 199:
    if int(env['MSVC_VERSION'].split('.')[0]) >= 14: #vs2015 and later
  File "C:\python27-x64\scons\SCons\Environment.py", line 410:
    return self._dict[key]
:bust_in_silhouette: Reply From: PtrMan

Update scons to the newest version as described at visual-studio-2017-vsproj-yes-did-not-work and build it with

scons p=windows vsproj=yes

EDIT: Though not the issue, another method of building through command line is with calling the vcvars batch files directly.

More details at:
Compiling for Windows — Godot Engine (3.1) documentation in English

In the examples below, I’m using VS2017, if this varies, search the installation folders, or find the path from the shortcuts if they’re installed to your Start Menu.

32-bit Editor - Release/Debug (with VS Project)

“C:\Program Files (x86)\Microsoft Visual
Studio\2017\Community\VC\Auxiliary\Build\vcvars32.bat” x86 &&
scons platform=windows tools=yes target=release_debug vsproj=yes

64-bit Editor - Release/Debug (with VS Project)

Change to the vcvars64.bat and swap x86 to amd64.

“C:\Program Files (x86)\Microsoft Visual
Studio\2017\Community\VC\Auxiliary\Build\vcvars64.bat” amd64 &&
scons platform=windows tools=yes target=release_debug vsproj=yes

avencherus | 2019-04-29 21:30

I’ve already solved it and built it successfully. Thank you anyways, it’s hopefully useful to other people.

PtrMan | 2019-04-29 23:23

The environment variables were set up automatically just fine by the MSVC++19 shell.

PtrMan | 2019-04-29 23:25

Tired and misread some things here. X) Adjusted my response to a comment.

avencherus | 2019-04-30 04:42