UniversalCrt not found on fresh Win7/64 + VS2017RC

Hi Epic,

on a clean Win7/64 + VC2017RC + Epic Launcher/4.14.1 Install the universalCRT headers and libraries are not found. This also applies to source compiles!

  • VS2017RC was installed with the Windows8.1Kit, since the Windows10Kit wouldnt install

The problem lies within the FindUniversalCRTInstallationFolder function in UnrealEngine/Engine/Source/Programs/UnrealBuildTool/Windows/VCEnvironment.cs.

		/// <summary>
		/// Finds the directory containing the Universal CRT installation. Returns null for Visual Studio versions before 2015
		/// </summary>
		static string FindUniversalCRTInstallationFolder()
		{
			if (WindowsPlatform.Compiler < WindowsCompiler.VisualStudio2015)
			{
				return null;
			}

			object Value =
				Registry.GetValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows Kits\\Installed Roots", "KitsRoot10", null) ??
				Registry.GetValue("HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows Kits\\Installed Roots", "KitsRoot10", null) ??
				Registry.GetValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Microsoft\\Windows Kits\\Installed Roots", "KitsRoot10", null) ??
				Registry.GetValue("HKEY_CURRENT_USER\\SOFTWARE\\Wow6432Node\\Microsoft\\Windows Kits\\Installed Roots", "KitsRoot10", null);

			return (Value as string);
}

This checks only if the KitsRoot10 key is present and returns it’s value, but it doesn’t check if it’s in the right subkey.

On Win7 in the HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Kits\Installed Roots doesnt have the VALUE “Universal CRT Headers Libraries and Sources x86” which clearly suggests that this isn’t the right subkey for the universalCRT installation folder.

Fix:

Check if the value “Universal CRT Headers Libraries and Sources x86” is present in the subkey.

        private static string GetWindowsKitsRootPath(string registryPath)
        {
            Dictionary<string, object> keyValuePairs;
            RegistryKey mainKey;
            if (registryPath.StartsWith("HKEY_LOCAL_MACHINE\\"))
            {
                mainKey = Registry.LocalMachine;
            }
            else if (registryPath.StartsWith("HKEY_CURRENT_USER\\"))
            {
                mainKey = Registry.CurrentUser;
            }
            else
            {
                throw new NotSupportedException("Main Registrykey " + registryPath.Substring(0, registryPath.IndexOf('\\')) + " not supported.");
            }


            using (var settingsRegKey = mainKey.OpenSubKey(registryPath.Substring(registryPath.IndexOf('\\') + 1)))
            {
                if (settingsRegKey == null)
                {
                    return null;
                }
                var valueNames = settingsRegKey.GetValueNames();
                keyValuePairs = valueNames.ToDictionary(name => name, settingsRegKey.GetValue);
            }
            if (keyValuePairs.ContainsValue("Universal CRT Headers Libraries and Sources x86"))
            {
                if (keyValuePairs.ContainsKey("KitsRoot10"))
                {
                    return keyValuePairs["KitsRoot10"].ToString();
                }
            }
            return null;
        }

        /// <summary>
        /// Finds the directory containing the Universal CRT installation. Returns null for Visual Studio versions before 2015
        /// </summary>
        static string FindUniversalCRTInstallationFolder()
		{
			if (WindowsPlatform.Compiler < WindowsCompiler.VisualStudio2015)
			{
				return null;
			}

            object Value = GetWindowsKitsRootPath("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows Kits\\Installed Roots") ??
                GetWindowsKitsRootPath("HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows Kits\\Installed Roots") ??
                GetWindowsKitsRootPath("HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Microsoft\\Windows Kits\\Installed Roots") ??
                GetWindowsKitsRootPath("HKEY_CURRENT_USER\\SOFTWARE\\Wow6432Node\\Microsoft\\Windows Kits\\Installed Roots");
            	return (Value as string);
		}
}

I checked for the value, since i don’t know where the keyname is coming from, but i’ve seen the value in a few different installations now, and even if the win64 key is pointing also to Program Files (x86) the WOW6432 node always had the right path AND the “Universal CRT Headers Libraries and Sources x86” value present.

Regards

Hey -

Since you already have a possible fix suggested, would you be able to submit that as a Pull Request on GitHub (https://github.com/EpicGames/UnrealEngine/compare?expand=1) ? That is our preferred method for receiving suggested fixes. If you are unable to do so, or prefer not to, let me know and I will get a ticket put in for this issue and mention your suggested fix there.

Cheers

Cleaned up the code and made a PR

Thx and have nice holidays :slight_smile: