示例#1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="GDKPlatform"/> class.
        /// </summary>
        protected GDKPlatform()
        {
            // Visual Studio 2017 or newer required
            var visualStudio = VisualStudioInstance.GetInstances().FirstOrDefault(x => x.Version == VisualStudioVersion.VisualStudio2017 || x.Version == VisualStudioVersion.VisualStudio2019);

            if (visualStudio == null)
            {
                _hasRequiredSDKsInstalled = false;
            }

            // Windows 10.0.19041.0 SDK or newer required
            var sdks = GetSDKs();

            if (!sdks.ContainsKey(WindowsPlatformSDK.v10_0_19041_0))
            {
                _hasRequiredSDKsInstalled = false;
            }

            // v141 toolset or newer required
            var toolsets = GetToolsets();

            if (!toolsets.ContainsKey(WindowsPlatformToolset.v141) &&
                !toolsets.ContainsKey(WindowsPlatformToolset.v142) &&
                !toolsets.ContainsKey(WindowsPlatformToolset.v143))
            {
                _hasRequiredSDKsInstalled = false;
            }
        }
示例#2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="UWPToolchain"/> class.
        /// </summary>
        /// <param name="platform">The platform.</param>
        /// <param name="architecture">The target architecture.</param>
        /// <param name="toolsetVer">The target platform toolset version.</param>
        /// <param name="sdkVer">The target platform SDK version.</param>
        public UWPToolchain(UWPPlatform platform, TargetArchitecture architecture, WindowsPlatformToolset toolsetVer = WindowsPlatformToolset.Latest, WindowsPlatformSDK sdkVer = WindowsPlatformSDK.Latest)
            : base(platform, architecture, toolsetVer, sdkVer)
        {
            var visualStudio = VisualStudioInstance.GetInstances().FirstOrDefault(x => x.Version == VisualStudioVersion.VisualStudio2017 || x.Version == VisualStudioVersion.VisualStudio2019);

            if (visualStudio == null)
            {
                throw new Exception("Missing Visual Studio 2017 or newer. It's required to build for UWP.");
            }
            _usingDirs.Add(Path.Combine(visualStudio.Path, "VC", "vcpackages"));

            var sdks  = WindowsPlatformBase.GetSDKs();
            var sdk10 = sdks.FirstOrDefault(x => x.Key != WindowsPlatformSDK.v8_1).Value;

            if (sdk10 == null)
            {
                throw new Exception("Missing Windows 10 SDK. It's required to build for UWP.");
            }
            var sdk10Ver = WindowsPlatformBase.GetSDKVersion(SDK).ToString();

            _usingDirs.Add(Path.Combine(sdk10, "References"));
            _usingDirs.Add(Path.Combine(sdk10, "References", sdk10Ver));
            _usingDirs.Add(Path.Combine(sdk10, "References", "CommonConfiguration", "Neutral"));
            _usingDirs.Add(Path.Combine(sdk10, "UnionMetadata", sdk10Ver));
        }
示例#3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="UWPPlatform"/> class.
        /// </summary>
        public UWPPlatform()
        {
            // Skip if running on non-Windows system
            if (Platform.BuildTargetPlatform != TargetPlatform.Windows)
            {
                _hasRequiredSDKsInstalled = false;
                return;
            }

            // Visual Studio 2017+ supported only
            var visualStudio = VisualStudioInstance.GetInstances().FirstOrDefault(x => x.Version == VisualStudioVersion.VisualStudio2017 || x.Version == VisualStudioVersion.VisualStudio2019);

            if (visualStudio == null)
            {
                _hasRequiredSDKsInstalled = false;
            }

            // Need Windows 10 SDK
            var sdks  = GetSDKs();
            var sdk10 = sdks.FirstOrDefault(x => x.Key != WindowsPlatformSDK.v8_1).Value;

            if (sdk10 == null)
            {
                _hasRequiredSDKsInstalled = false;
            }

            // Need v141+ toolset
            if (!GetToolsets().ContainsKey(WindowsPlatformToolset.v141) &&
                !GetToolsets().ContainsKey(WindowsPlatformToolset.v142))
            {
                _hasRequiredSDKsInstalled = false;
            }
        }
示例#4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="UWPPlatform"/> class.
        /// </summary>
        public UWPPlatform()
        {
            // Visual Studio 2017+ supported only
            var visualStudio = VisualStudioInstance.GetInstances().FirstOrDefault(x => x.Version == VisualStudioVersion.VisualStudio2017 || x.Version == VisualStudioVersion.VisualStudio2019);

            if (visualStudio == null)
            {
                _hasRequiredSDKsInstalled = false;
            }

            // Need Windows 10 SDK
            var sdks  = GetSDKs();
            var sdk10 = sdks.FirstOrDefault(x => x.Key != WindowsPlatformSDK.v8_1).Value;

            if (sdk10 == null)
            {
                _hasRequiredSDKsInstalled = false;
            }

            // Need v141 toolset
            if (!GetToolsets().ContainsKey(WindowsPlatformToolset.v141))
            {
                _hasRequiredSDKsInstalled = false;
            }
        }
示例#5
0
        /// <summary>
        /// Finds all the directories containing the Windows platform toolset.
        /// </summary>
        /// <returns>The collection of installed toolsets.</returns>
        public static Dictionary <WindowsPlatformToolset, string> GetToolsets()
        {
            if (_toolsets != null)
            {
                return(_toolsets);
            }
            _toolsets = new Dictionary <WindowsPlatformToolset, string>();

            // Skip if running on non-Windows system
            if (BuildTargetPlatform != TargetPlatform.Windows)
            {
                return(_toolsets);
            }

            var vsInstances = VisualStudioInstance.GetInstances();

            // Visual Studio 2015 - single instance
            var vs2015 = vsInstances.FirstOrDefault(x => x.Version == VisualStudioVersion.VisualStudio2015);

            if (vs2015 != null)
            {
                string rootDir = Path.Combine(vs2015.Path, "VC");
                if (Directory.Exists(rootDir) && (
                        File.Exists(Path.Combine(rootDir, "bin", "amd64", "cl.exe"))
                        ||
                        File.Exists(Path.Combine(rootDir, "bin", "x86_amd64", "cl.exe"))
                        ))
                {
                    _toolsets[WindowsPlatformToolset.v140] = rootDir;
                }
            }

            // Visual Studio 2017 - multiple instances
            foreach (var vs2017 in vsInstances.Where(x => x.Version == VisualStudioVersion.VisualStudio2017))
            {
                FindMsvcToolsets(Path.Combine(vs2017.Path, "VC", "Tools", "MSVC"));
            }

            // Visual Studio 2019 - multiple instances
            foreach (var vs2019 in vsInstances.Where(x => x.Version == VisualStudioVersion.VisualStudio2019))
            {
                FindMsvcToolsets(Path.Combine(vs2019.Path, "VC", "Tools", "MSVC"));
            }

            foreach (var e in _toolsets)
            {
                Log.Verbose(string.Format("Found Windows toolset {0} at {1}", e.Key, e.Value));
            }

            return(_toolsets);
        }
示例#6
0
        private static string GetMSBuildToolPath()
        {
            string toolPath;

            switch (Platform.BuildPlatform.Target)
            {
            case TargetPlatform.Linux:
            {
                // Use msbuild from Mono
                toolPath = UnixPlatform.Which("msbuild");
                if (toolPath != null)
                {
                    return(toolPath);
                }

                break;
            }

            case TargetPlatform.Windows:
            {
                var visualStudioInstances = VisualStudioInstance.GetInstances();
                foreach (var visualStudioInstance in visualStudioInstances)
                {
                    toolPath = Path.Combine(visualStudioInstance.Path, "MSBuild\\Current\\Bin\\MSBuild.exe");
                    if (File.Exists(toolPath))
                    {
                        return(toolPath);
                    }
                }

                if (CheckMsBuildPathFromRegistry("Microsoft\\VisualStudio\\SxS\\VS7", "15.0", "MSBuild\\15.0\\bin\\MSBuild.exe", out toolPath))
                {
                    return(toolPath);
                }

                toolPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86), "MSBuild", "14.0", "bin", "MSBuild.exe");
                if (File.Exists(toolPath))
                {
                    return(toolPath);
                }

                if (CheckMsBuildPathFromRegistry("Microsoft\\MSBuild\\ToolsVersions\\14.0", "MSBuildToolsPath", "MSBuild.exe", out toolPath))
                {
                    return(toolPath);
                }

                if (CheckMsBuildPathFromRegistry("Microsoft\\MSBuild\\ToolsVersions\\12.0", "MSBuildToolsPath", "MSBuild.exe", out toolPath))
                {
                    return(toolPath);
                }

                if (CheckMsBuildPathFromRegistry("Microsoft\\MSBuild\\ToolsVersions\\4.0", "MSBuildToolsPath", "MSBuild.exe", out toolPath))
                {
                    return(toolPath);
                }

                break;
            }
            }

            return(string.Empty);
        }