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)) { PropertyStorage.SetPropertyValue("LocalDebuggerCommandArguments", 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); }
/// <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); }
/// <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)) { string UProjectFileName = Utils.GetUProjectFileName(SelectedStartupProject); if (CommandLineArguments.Trim().StartsWith(UProjectFileName, StringComparison.OrdinalIgnoreCase)) { CommandLineArguments = CommandLineArguments.Trim().Substring(UProjectFileName.Length).Trim(); } else if (CommandLineArguments.Trim().StartsWith(SelectedStartupProject.Name, StringComparison.OrdinalIgnoreCase)) { CommandLineArguments = CommandLineArguments.Trim().Substring(SelectedStartupProject.Name.Length).Trim(); } } Text = CommandLineArguments; } else { Text = InvalidProjectString; } } } return(Text); }
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); }
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); }