Example #1
0
        private bool ProjectPredicate(Project Project)
        {
            // Initialize the cached options if they haven't been read from UnrealVSOptions yet
            if (!CachedHideNonGameStartupProjects.HasValue)
            {
                UpdateCachedOptions();
            }

            // Optionally, ignore non-game projects
            if (CachedHideNonGameStartupProjects.Value)
            {
                if (!Utils.IsGameProject(Project))
                {
                    Logging.WriteLine("StartupProjectSelector: Not listing project " + Project.Name + " because it is not a game");
                    return(false);
                }
            }

            // Always filter out non-executable projects
            if (!Utils.IsProjectSuitable(Project))
            {
                Logging.WriteLine("StartupProjectSelector: Not listing project " + Project.Name + " because it is not executable");
                return(false);
            }

            Logging.WriteLine("StartupProjectSelector: Listing project " + Project.Name);
            return(true);
        }
 private void SortCachedStartupProjects()
 {
     // Sort projects by game y/n then alphabetically
     _CachedStartupProjects = (_CachedStartupProjects.OrderBy(ProjectRef => ProjectRef.Name == "UE4" ? 0 : 1)
                               .ThenBy(ProjectRef => Utils.IsGameProject(ProjectRef.Project) ? 0 : 1)
                               .ThenBy(ProjectRef => ProjectRef.Name)).ToList();
 }
        private void CommitCommandLineText(string CommandLine)
        {
            string FullCommandLine = CommandLine;

            IVsHierarchy ProjectHierarchy;

            UnrealVSPackage.Instance.SolutionBuildManager.get_StartupProject(out ProjectHierarchy);
            if (ProjectHierarchy != null)
            {
                var SelectedStartupProject = Utils.HierarchyObjectToProject(ProjectHierarchy);

                if (SelectedStartupProject != null)
                {
                    // for "Game" projects automatically remove the game project filename from the start of the command line
                    var ActiveConfiguration = (SolutionConfiguration2)UnrealVSPackage.Instance.DTE.Solution.SolutionBuild.ActiveConfiguration;
                    if (UnrealVSPackage.Instance.IsUE4Loaded && Utils.IsGameProject(SelectedStartupProject) && Utils.HasUProjectCommandLineArg(ActiveConfiguration.Name))
                    {
                        string UProjectFileName = Utils.GetUProjectFileName(SelectedStartupProject);
                        if (FullCommandLine.Trim().StartsWith(UProjectFileName, StringComparison.InvariantCultureIgnoreCase))
                        {
                            VsShellUtilities.ShowMessageBox(ServiceProvider.GlobalProvider,
                                                            string.Format("INFORMATION: The project filename {0} has been removed from the command line because it is included automatically for 'Game' projects.", UProjectFileName),
                                                            "UnrealVS",
                                                            OLEMSGICON.OLEMSGICON_INFO,
                                                            OLEMSGBUTTON.OLEMSGBUTTON_OK,
                                                            OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST);
                        }
                        else if (FullCommandLine.Trim().StartsWith(SelectedStartupProject.Name, StringComparison.OrdinalIgnoreCase))
                        {
                            VsShellUtilities.ShowMessageBox(ServiceProvider.GlobalProvider,
                                                            string.Format("INFORMATION: The project name {0} has been removed from the command line because it is included automatically for 'Game' projects.", SelectedStartupProject.Name),
                                                            "UnrealVS",
                                                            OLEMSGICON.OLEMSGICON_INFO,
                                                            OLEMSGBUTTON.OLEMSGBUTTON_OK,
                                                            OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST);
                        }
                        else
                        {
                            FullCommandLine = UProjectFileName + " " + FullCommandLine;
                        }
                    }

                    var CommandLineArgumentsProperty = GetProjectCommandLineProperty(SelectedStartupProject);

                    if (CommandLineArgumentsProperty != null)
                    {
                        Utils.SetPropertyValue(CommandLineArgumentsProperty, FullCommandLine);
                    }
                }
            }

            CommitCommandLineToMRU(CommandLine);
        }
Example #4
0
        private void CommitCommandLineText(string CommandLine)
        {
            IVsHierarchy ProjectHierarchy;

            if (UnrealVSPackage.Instance.SolutionBuildManager.get_StartupProject(out ProjectHierarchy) == VSConstants.S_OK && ProjectHierarchy != null)
            {
                Project SelectedStartupProject = Utils.HierarchyObjectToProject(ProjectHierarchy);
                if (SelectedStartupProject != null)
                {
                    Configuration SelectedConfiguration = SelectedStartupProject.ConfigurationManager.ActiveConfiguration;
                    if (SelectedConfiguration != null)
                    {
                        IVsBuildPropertyStorage PropertyStorage = ProjectHierarchy as IVsBuildPropertyStorage;
                        if (PropertyStorage != null)
                        {
                            string FullCommandLine = CommandLine;

                            // for "Game" projects automatically remove the game project filename from the start of the command line
                            var ActiveConfiguration = (SolutionConfiguration2)UnrealVSPackage.Instance.DTE.Solution.SolutionBuild.ActiveConfiguration;
                            if (UnrealVSPackage.Instance.IsUE4Loaded && Utils.IsGameProject(SelectedStartupProject) && Utils.HasUProjectCommandLineArg(ActiveConfiguration.Name))
                            {
                                string AutoPrefix = Utils.GetAutoUProjectCommandLinePrefix(SelectedStartupProject);
                                if (FullCommandLine.IndexOf(Utils.UProjectExtension, StringComparison.OrdinalIgnoreCase) < 0 &&
                                    string.Compare(FullCommandLine, SelectedStartupProject.Name, StringComparison.OrdinalIgnoreCase) != 0 &&
                                    !FullCommandLine.StartsWith(SelectedStartupProject.Name + " ", StringComparison.OrdinalIgnoreCase))
                                {
                                    // Committed command line does not specify a .uproject
                                    FullCommandLine = AutoPrefix + " " + FullCommandLine;
                                }
                            }

                            // Get the project kind. C++ projects store the debugger arguments differently to other project types.
                            string ProjectKind = SelectedStartupProject.Kind;

                            // Update the property
                            string ProjectConfigurationName = String.Format("{0}|{1}", SelectedConfiguration.ConfigurationName, SelectedConfiguration.PlatformName);
                            if (String.Equals(ProjectKind, "{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}", StringComparison.InvariantCultureIgnoreCase))
                            {
                                PropertyStorage.SetPropertyValue("LocalDebuggerCommandArguments", ProjectConfigurationName, (uint)_PersistStorageType.PST_USER_FILE, FullCommandLine);
                            }
                            else
                            {
                                PropertyStorage.SetPropertyValue("StartArguments", ProjectConfigurationName, (uint)_PersistStorageType.PST_USER_FILE, FullCommandLine);
                            }
                        }
                    }
                }
            }

            CommitCommandLineToMRU(CommandLine);
        }
        /// <summary>
        /// Returns a string to display in the command-line combo box, based on project state
        /// </summary>
        /// <returns>String to display</returns>
        private string MakeCommandLineComboText()
        {
            string Text = "";

            IVsHierarchy ProjectHierarchy;

            UnrealVSPackage.Instance.SolutionBuildManager.get_StartupProject(out ProjectHierarchy);
            if (ProjectHierarchy != null)
            {
                var SelectedStartupProject = Utils.HierarchyObjectToProject(ProjectHierarchy);

                if (SelectedStartupProject != null)
                {
                    var CommandLineArgumentsProperty = GetProjectCommandLineProperty(SelectedStartupProject);

                    if (CommandLineArgumentsProperty != null)
                    {
                        var CommandLineArguments = (string)CommandLineArgumentsProperty.Value;

                        // for "Game" projects automatically remove the game project filename from the start of the command line
                        var ActiveConfiguration = (SolutionConfiguration2)UnrealVSPackage.Instance.DTE.Solution.SolutionBuild.ActiveConfiguration;
                        if (UnrealVSPackage.Instance.IsUE4Loaded && Utils.IsGameProject(SelectedStartupProject) && Utils.HasUProjectCommandLineArg(ActiveConfiguration.Name))
                        {
                            var AutoPrefix = Utils.GetAutoUProjectCommandLinePrefix(SelectedStartupProject);

                            if (!string.IsNullOrEmpty(AutoPrefix))
                            {
                                if (CommandLineArguments.Trim().StartsWith(AutoPrefix, StringComparison.OrdinalIgnoreCase))
                                {
                                    CommandLineArguments = CommandLineArguments.Trim().Substring(AutoPrefix.Length).Trim();
                                }
                                //else if (CommandLineArguments.Trim().StartsWith(SelectedStartupProject.Name + " ", StringComparison.OrdinalIgnoreCase))
                                //{
                                //	CommandLineArguments = CommandLineArguments.Trim().Substring(SelectedStartupProject.Name.Length + 1).Trim();
                                //}
                            }
                        }

                        Text = CommandLineArguments;
                    }
                    else
                    {
                        Text = InvalidProjectString;
                    }
                }
            }

            return(Text);
        }
        /// <summary>
        /// Returns a string to display in the command-line combo box, based on project state
        /// </summary>
        /// <returns>String to display</returns>
        private string MakeCommandLineComboText()
        {
            string Text = "";

            IVsHierarchy ProjectHierarchy;

            if (UnrealVSPackage.Instance.SolutionBuildManager.get_StartupProject(out ProjectHierarchy) == VSConstants.S_OK && ProjectHierarchy != null)
            {
                Project SelectedStartupProject = Utils.HierarchyObjectToProject(ProjectHierarchy);
                if (SelectedStartupProject != null)
                {
                    Configuration SelectedConfiguration = SelectedStartupProject.ConfigurationManager.ActiveConfiguration;
                    if (SelectedConfiguration != null)
                    {
                        IVsBuildPropertyStorage PropertyStorage = ProjectHierarchy as IVsBuildPropertyStorage;
                        if (PropertyStorage != null)
                        {
                            // Query the property store for the debugger arguments
                            string ConfigurationName = String.Format("{0}|{1}", SelectedConfiguration.ConfigurationName, SelectedConfiguration.PlatformName);
                            if (PropertyStorage.GetPropertyValue("LocalDebuggerCommandArguments", ConfigurationName, (uint)_PersistStorageType.PST_USER_FILE, out Text) != VSConstants.S_OK)
                            {
                                if (PropertyStorage.GetPropertyValue("StartArguments", ConfigurationName, (uint)_PersistStorageType.PST_USER_FILE, out Text) != VSConstants.S_OK)
                                {
                                    Text = "";
                                }
                            }

                            // for "Game" projects automatically remove the game project filename from the start of the command line
                            var ActiveConfiguration = (SolutionConfiguration2)UnrealVSPackage.Instance.DTE.Solution.SolutionBuild.ActiveConfiguration;
                            if (UnrealVSPackage.Instance.IsUE4Loaded && Utils.IsGameProject(SelectedStartupProject) && Utils.HasUProjectCommandLineArg(ActiveConfiguration.Name))
                            {
                                string AutoPrefix = Utils.GetAutoUProjectCommandLinePrefix(SelectedStartupProject);
                                if (!string.IsNullOrEmpty(AutoPrefix))
                                {
                                    if (Text.Trim().StartsWith(AutoPrefix, StringComparison.OrdinalIgnoreCase))
                                    {
                                        Text = Text.Trim().Substring(AutoPrefix.Length).Trim();
                                    }
                                }
                            }
                        }
                    }
                }
            }

            return(Text);
        }
        private void CommitCommandLineText(string CommandLine)
        {
            IVsHierarchy ProjectHierarchy;

            UnrealVSPackage.Instance.SolutionBuildManager.get_StartupProject(out ProjectHierarchy);
            if (ProjectHierarchy != null)
            {
                var SelectedStartupProject = Utils.HierarchyObjectToProject(ProjectHierarchy);

                if (SelectedStartupProject != null)
                {
                    var CommandLineArgumentsProperty = GetProjectCommandLineProperty(SelectedStartupProject);

                    if (CommandLineArgumentsProperty != null)
                    {
                        string FullCommandLine = CommandLine;

                        // for "Game" projects automatically remove the game project filename from the start of the command line
                        var ActiveConfiguration = (SolutionConfiguration2)UnrealVSPackage.Instance.DTE.Solution.SolutionBuild.ActiveConfiguration;
                        if (UnrealVSPackage.Instance.IsUE4Loaded && Utils.IsGameProject(SelectedStartupProject) && Utils.HasUProjectCommandLineArg(ActiveConfiguration.Name))
                        {
                            var AutoPrefix = Utils.GetAutoUProjectCommandLinePrefix(SelectedStartupProject);

                            if (FullCommandLine.IndexOf(Utils.UProjectExtension, StringComparison.OrdinalIgnoreCase) < 0 &&
                                string.Compare(FullCommandLine, SelectedStartupProject.Name, StringComparison.OrdinalIgnoreCase) != 0 &&
                                !FullCommandLine.StartsWith(SelectedStartupProject.Name + " ", StringComparison.OrdinalIgnoreCase))
                            {
                                // Committed command line does not specify a .uproject
                                FullCommandLine = AutoPrefix + " " + FullCommandLine;
                            }
                        }

                        Utils.SetPropertyValue(CommandLineArgumentsProperty, FullCommandLine);
                    }
                }
            }

            CommitCommandLineToMRU(CommandLine);
        }
Example #8
0
        private void CommitCommandLineText(string CommandLine)
        {
            IVsHierarchy ProjectHierarchy;

            if (UnrealVSPackage.Instance.SolutionBuildManager.get_StartupProject(out ProjectHierarchy) == VSConstants.S_OK && ProjectHierarchy != null)
            {
                Project SelectedStartupProject = Utils.HierarchyObjectToProject(ProjectHierarchy);
                if (SelectedStartupProject != null)
                {
                    Configuration SelectedConfiguration = SelectedStartupProject.ConfigurationManager.ActiveConfiguration;
                    if (SelectedConfiguration != null)
                    {
                        IVsBuildPropertyStorage PropertyStorage = ProjectHierarchy as IVsBuildPropertyStorage;
                        if (PropertyStorage != null)
                        {
                            string FullCommandLine = CommandLine;

                            // for "Game" projects automatically remove the game project filename from the start of the command line
                            var ActiveConfiguration = (SolutionConfiguration2)UnrealVSPackage.Instance.DTE.Solution.SolutionBuild.ActiveConfiguration;
                            if (UnrealVSPackage.Instance.IsUE4Loaded && Utils.IsGameProject(SelectedStartupProject) && Utils.HasUProjectCommandLineArg(ActiveConfiguration.Name))
                            {
                                string AutoPrefix = Utils.GetAutoUProjectCommandLinePrefix(SelectedStartupProject);
                                if (FullCommandLine.IndexOf(Utils.UProjectExtension, StringComparison.OrdinalIgnoreCase) < 0 &&
                                    string.Compare(FullCommandLine, SelectedStartupProject.Name, StringComparison.OrdinalIgnoreCase) != 0 &&
                                    !FullCommandLine.StartsWith(SelectedStartupProject.Name + " ", StringComparison.OrdinalIgnoreCase))
                                {
                                    // Committed command line does not specify a .uproject
                                    FullCommandLine = AutoPrefix + " " + FullCommandLine;
                                }
                            }

                            // Get the project platform name.
                            string ProjectPlatformName = SelectedConfiguration.PlatformName;
                            if (ProjectPlatformName == "Any CPU")
                            {
                                ProjectPlatformName = "AnyCPU";
                            }

                            // Get the project kind. C++ projects store the debugger arguments differently to other project types.
                            string ProjectKind = SelectedStartupProject.Kind;

                            // Update the property
                            string ProjectConfigurationName = String.Format("{0}|{1}", SelectedConfiguration.ConfigurationName, ProjectPlatformName);
                            if (String.Equals(ProjectKind, "{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}", StringComparison.InvariantCultureIgnoreCase))
                            {
                                List <string> ExtraFields = Utils.GetExtraDebuggerCommandArguments(ProjectPlatformName, SelectedStartupProject);

                                if (FullCommandLine.Length == 0)
                                {
                                    PropertyStorage.RemoveProperty("LocalDebuggerCommandArguments", ProjectConfigurationName, (uint)_PersistStorageType.PST_USER_FILE);
                                    PropertyStorage.RemoveProperty("RemoteDebuggerCommandArguments", ProjectConfigurationName, (uint)_PersistStorageType.PST_USER_FILE);
                                    foreach (string ExtraField in ExtraFields)
                                    {
                                        PropertyStorage.RemoveProperty(ExtraField, ProjectConfigurationName, (uint)_PersistStorageType.PST_USER_FILE);
                                    }
                                }
                                else
                                {
                                    PropertyStorage.SetPropertyValue("LocalDebuggerCommandArguments", ProjectConfigurationName, (uint)_PersistStorageType.PST_USER_FILE, FullCommandLine);
                                    PropertyStorage.SetPropertyValue("RemoteDebuggerCommandArguments", ProjectConfigurationName, (uint)_PersistStorageType.PST_USER_FILE, FullCommandLine);
                                    foreach (string ExtraField in ExtraFields)
                                    {
                                        PropertyStorage.SetPropertyValue(ExtraField, ProjectConfigurationName, (uint)_PersistStorageType.PST_USER_FILE, FullCommandLine);
                                    }
                                }
                            }
                            else
                            {
                                // For some reason, have to update C# projects this way, otherwise the properties page doesn't update. Conversely, SelectedConfiguration.Properties is always null for C++ projects in VS2017.
                                if (SelectedConfiguration.Properties != null)
                                {
                                    foreach (Property Property in SelectedConfiguration.Properties)
                                    {
                                        if (Property.Name.Equals("StartArguments", StringComparison.InvariantCultureIgnoreCase))
                                        {
                                            Property.Value = FullCommandLine;
                                            break;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }

            CommitCommandLineToMRU(CommandLine);
        }