Beispiel #1
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);
        }
Beispiel #5
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);
        }