예제 #1
0
        private void GetVisualStudio(KoreBuildSettings.VisualStudioToolset vsToolset)
        {
            if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
            {
                if ((vsToolset.Required & ~KoreBuildSettings.RequiredPlatforms.Windows) != 0)
                {
                    Log.LogError("Visual Studio is not available on non-Windows. Change korebuild.json to 'required: [\"windows\"]'.");
                }
                else
                {
                    Log.LogMessage(MessageImportance.Low, "Skipping Visual Studio verification on non-Windows platforms.");
                }
                return;
            }

            var vs = VsWhere.FindLatestCompatibleInstallation(vsToolset, Log);

            if (vs == null)
            {
                if (vsToolset.Required != KoreBuildSettings.RequiredPlatforms.None)
                {
                    Log.LogError($"Could not find an installation of Visual Studio that satisifies the specified requirements in '{ConfigFile}'. " +
                                 "Execute `./run.ps1 install vs` to update or install the current VS installation. " +
                                 "See https://docs.microsoft.com/en-us/visualstudio/install/workload-component-id-vs-community for more details on workloads.");
                }
                return;
            }

            Log.LogMessage(MessageImportance.High, "Using {0} from {1}", vs.DisplayName, vs.InstallationPath);

            VisualStudioMSBuildx86Path = vs.GetMSBuildx86SubPath();
            VisualStudioMSBuildx64Path = vs.GetMSBuildx64SubPath();
        }
예제 #2
0
        public override bool Execute()
        {
            if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
            {
                Log.LogError("Visual Studio cannot be found on non-Windows platforms");
                return(false);
            }

            VsInstallation vs;

            if (!string.IsNullOrEmpty(ConfigFile))
            {
                if (!File.Exists(ConfigFile))
                {
                    Log.LogError($"Could not load the korebuild config file from '{ConfigFile}'");
                    return(false);
                }

                var settings  = KoreBuildSettings.Load(ConfigFile);
                var vsToolset = settings.Toolsets?.OfType <KoreBuildSettings.VisualStudioToolset>().FirstOrDefault();
                if (vsToolset != null)
                {
                    vs = VsWhere.FindLatestCompatibleInstallation(vsToolset, Log);
                    if (vs == null)
                    {
                        Log.LogError($"Could not find an installation of Visual Studio that satisifies the specified requirements in {ConfigFile}. " +
                                     "See https://docs.microsoft.com/en-us/visualstudio/install/workload-component-id-vs-community for more details on any missing components.");
                        return(false);
                    }
                }
                else
                {
                    vs = VsWhere.FindLatestInstallation(includePrerelease: true, log: Log);
                }
            }
            else
            {
                vs = VsWhere.FindLatestInstallation(includePrerelease: true, log: Log);
            }

            if (vs == null)
            {
                Log.LogError($"Could not find any installation of Visual Studio.");
                return(false);
            }

            Log.LogMessage(MessageImportance.Normal, "Found {0} in {1}", vs.DisplayName, vs.InstallationPath);

            InstallationBasePath = vs.InstallationPath;
            MSBuildx86Path       = vs.GetMSBuildx86SubPath();
            MSBuildx64Path       = vs.GetMSBuildx64SubPath();

            return(!Log.HasLoggedErrors);
        }