예제 #1
0
        public async Task SaveRunConfigurationsToUserProject()
        {
            string   solFile = Util.GetSampleProject("run-configurations", "ConsoleProject.sln");
            Solution sol     = (Solution)await Services.ProjectService.ReadWorkspaceItem(Util.GetMonitor(), solFile);

            var p = (DotNetProject)sol.Items [0];

            var es = new ProjectRunConfiguration("Test1");

            es.StoreInUserFile = false;
            es.Properties.SetValue("SomeValue", "Foo");
            p.RunConfigurations.Add(es);

            es = new ProjectRunConfiguration("Test2");
            es.Properties.SetValue("SomeValue", "Bar");
            p.RunConfigurations.Add(es);

            Assert.AreEqual(3, p.GetRunConfigurations().Count());

            await sol.SaveAsync(Util.GetMonitor());

            string projectXml    = File.ReadAllText(p.FileName);
            string newProjectXml = File.ReadAllText(p.FileName.ChangeName("ConsoleProject.configs-user-added"));

            Assert.AreEqual(newProjectXml, projectXml);

            Assert.IsTrue(File.Exists(p.FileName + ".user"));

            projectXml    = File.ReadAllText(p.FileName + ".user");
            newProjectXml = File.ReadAllText(p.FileName.ChangeName("ConsoleProject.configs-user-added") + ".user");
            Assert.AreEqual(newProjectXml, projectXml);

            sol.Dispose();
        }
예제 #2
0
        internal bool Equals(ProjectRunConfiguration other)
        {
            var dict1 = new Dictionary <string, string> ();
            var dict2 = new Dictionary <string, string> ();

            var thisData = new ProjectItemMetadata();

            Write(thisData);
            GetProps(MainPropertyGroup, dict1);
            GetProps(thisData, dict1);

            var otherData = new ProjectItemMetadata();

            other.Write(otherData);
            GetProps(other.MainPropertyGroup, dict2);
            GetProps(otherData, dict2);

            if (dict1.Count != dict2.Count)
            {
                return(false);
            }
            foreach (var tp in dict1)
            {
                string v;
                if (!dict2.TryGetValue(tp.Key, out v) || tp.Value != v)
                {
                    return(false);
                }
            }
            return(true);
        }
		public static RunConfigurationEditor CreateEditorForConfiguration (ProjectRunConfiguration config)
		{
			var name = config.GetType ().FullName;
			var node = AddinManager.GetExtensionNodes<RunConfigurationEditorExtensionNode> (EditorsExtension).FirstOrDefault (n => n.RunConfigurationType == name);
			if (node != null)
				return (RunConfigurationEditor)node.CreateInstance (typeof (RunConfigurationEditor));
			else
				return null;
		}
        protected override void OnCopyFrom(ProjectRunConfiguration config, bool isRename)
        {
            base.OnCopyFrom(config, isRename);

            var other = (AssemblyRunConfiguration)config;

            StartProgram    = other.StartProgram;
            StartAction     = other.StartAction;
            monoParameters  = other.monoParameters.Clone();
            TargetRuntimeId = other.TargetRuntimeId;
        }
		protected override void OnCopyFrom (ProjectRunConfiguration config, bool isRename)
		{
			base.OnCopyFrom (config, isRename);

			var other = (ProcessRunConfiguration)config;

			StartArguments = other.StartArguments;
			StartWorkingDirectory = other.StartWorkingDirectory;
			EnvironmentVariables = new EnvironmentVariableCollection (other.EnvironmentVariables);
			ExternalConsole = other.ExternalConsole;
			PauseConsoleOutput = other.PauseConsoleOutput;
		}
예제 #6
0
        protected override void OnCopyFrom(ProjectRunConfiguration config, bool isRename)
        {
            base.OnCopyFrom(config, isRename);

            var other = (ProcessRunConfiguration)config;

            StartArguments        = other.StartArguments;
            StartWorkingDirectory = other.StartWorkingDirectory;
            EnvironmentVariables  = new EnvironmentVariableCollection(other.EnvironmentVariables);
            ExternalConsole       = other.ExternalConsole;
            PauseConsoleOutput    = other.PauseConsoleOutput;
        }
		public RunWithCustomParametersDialog (Project project)
		{
			this.project = project;
			runConfig = project.CreateRunConfiguration ("Custom");

			Title = GettextCatalog.GetString ("Custom Parameters");

			Width = 650;
			Height = 400;

			editor = RunConfigurationService.CreateEditorForConfiguration (runConfig);
			editor.Load (project, runConfig);

			var box = new VBox ();
			Content = box;
			var c = editor.CreateControl ().GetNativeWidget<Gtk.Widget> ();
			box.PackStart (box.Surface.ToolkitEngine.WrapWidget (c, NativeWidgetSizing.DefaultPreferredSize), true);

			box.PackStart (new HSeparator ());

			var hbox = new HBox ();
			hbox.PackStart (new Label ("Run Action: "));
			hbox.PackStart (modeCombo = new ComboBox ());
			box.PackStart (hbox);

			runButton = new DialogButton (new Command ("run", GettextCatalog.GetString ("Run")));

			Buttons.Add (Command.Cancel);
			Buttons.Add (runButton);

			LoadModes ();
			UpdateStatus ();

			editor.Changed += Editor_Changed;
			modeCombo.SelectionChanged += (s,a) => UpdateStatus ();
		}
예제 #8
0
 protected virtual void OnCopyFrom(ProjectRunConfiguration config, bool isRename)
 {
 }
예제 #9
0
 /// <summary>
 /// Copies the data of a run configuration into this configuration
 /// </summary>
 /// <param name="config">Configuration from which to get the data.</param>
 /// <param name="isRename">If true, it means that the copy is being made as a result of a rename or clone operation. In this case,
 /// the overriden method may change the value of some properties that depend on the configuration name.</param>
 public void CopyFrom(ProjectRunConfiguration config, bool isRename = false)
 {
     StoreInUserFile = config.StoreInUserFile;
     OnCopyFrom(config, isRename);
 }
		internal protected virtual ExecutionCommand OnCreateExecutionCommand (ConfigurationSelector configSel, DotNetProjectConfiguration configuration, ProjectRunConfiguration runConfiguration)
		{
			return next.OnCreateExecutionCommand (configSel, configuration, runConfiguration);
		}
예제 #11
0
		public async Task SaveRunConfigurationsToUserProject ()
		{
			string solFile = Util.GetSampleProject ("run-configurations", "ConsoleProject.sln");
			Solution sol = (Solution)await Services.ProjectService.ReadWorkspaceItem (Util.GetMonitor (), solFile);
			var p = (DotNetProject)sol.Items [0];

			var es = new ProjectRunConfiguration ("Test1");
			es.StoreInUserFile = false;
			es.Properties.SetValue ("SomeValue", "Foo");
			p.RunConfigurations.Add (es);

			es = new ProjectRunConfiguration ("Test2");
			es.Properties.SetValue ("SomeValue", "Bar");
			p.RunConfigurations.Add (es);

			Assert.AreEqual (3, p.GetRunConfigurations ().Count ());

			await sol.SaveAsync (Util.GetMonitor ());

			string projectXml = File.ReadAllText (p.FileName);
			string newProjectXml = File.ReadAllText (p.FileName.ChangeName ("ConsoleProject.configs-user-added"));
			Assert.AreEqual (newProjectXml, projectXml);

			Assert.IsTrue (File.Exists (p.FileName + ".user"));

			projectXml = File.ReadAllText (p.FileName + ".user");
			newProjectXml = File.ReadAllText (p.FileName.ChangeName ("ConsoleProject.configs-user-added") + ".user");
			Assert.AreEqual (newProjectXml, projectXml);
		}
예제 #12
0
		internal override void ImportDefaultRunConfiguration (ProjectRunConfiguration config)
		{
			base.ImportDefaultRunConfiguration (config);
			if (config is AssemblyRunConfiguration) {
				var defaultConf = (DefaultConfiguration ?? Configurations.FirstOrDefault<SolutionItemConfiguration> ()) as DotNetProjectConfiguration;
				if (defaultConf != null) {
					var drc = (AssemblyRunConfiguration)config;
					var cmd = defaultConf.CustomCommands.FirstOrDefault (cc => cc.Type == CustomCommandType.Execute);
					if (cmd != null) {
						drc.StartAction = AssemblyRunConfiguration.StartActions.Program;
						drc.StartProgram = cmd.GetCommandFile (this, defaultConf.Selector);
						drc.StartArguments = cmd.GetCommandArgs (this, defaultConf.Selector);
						foreach (var v in cmd.EnvironmentVariables)
							drc.EnvironmentVariables.Add (v.Key, v.Value);
						drc.StartWorkingDirectory = cmd.GetCommandWorkingDir (this, defaultConf.Selector);
						drc.ExternalConsole = cmd.ExternalConsole;
						drc.PauseConsoleOutput = cmd.PauseExternalConsole;
						defaultConf.CustomCommands.Remove (cmd);
					}
				}
			}
		}
예제 #13
0
		internal void ReplaceConfiguration (ProjectRunConfiguration oldConf, ProjectRunConfiguration newConf)
		{
			var i = configs.FindIndex (ci => ci.EditedConfig == oldConf);
			var oldc = configs [i];
			var newc = new RunConfigInfo { EditedConfig = newConf };
			configs [i] = newc;
			RemovePanel (oldc);
			AddPanel (newc);
		}
예제 #14
0
 internal protected virtual void OnWriteRunConfiguration(ProgressMonitor monitor, ProjectRunConfiguration config, IPropertySet properties)
 {
     next.OnWriteRunConfiguration(monitor, config, properties);
 }
예제 #15
0
 internal protected virtual ExecutionCommand OnCreateExecutionCommand(ConfigurationSelector configSel, DotNetProjectConfiguration configuration, ProjectRunConfiguration runConfiguration)
 {
     return(next.OnCreateExecutionCommand(configSel, configuration, runConfiguration));
 }
		protected virtual void OnCopyFrom (ProjectRunConfiguration config, bool isRename)
		{
		}
		protected override void OnCopyFrom (ProjectRunConfiguration config, bool isRename)
		{
			base.OnCopyFrom (config, isRename);

			var other = (AssemblyRunConfiguration)config;

			StartProgram = other.StartProgram;
			StartAction = other.StartAction;
			monoParameters = other.monoParameters.Clone ();
			TargetRuntimeId = other.TargetRuntimeId;
		}
예제 #18
0
		internal protected virtual void OnWriteRunConfiguration (ProgressMonitor monitor, ProjectRunConfiguration config, IPropertySet properties)
		{
			next.OnWriteRunConfiguration (monitor, config, properties);
		}
예제 #19
0
		internal void ShowConfiguration (ProjectRunConfiguration editedConfig)
		{
			var rc = configs.First (ci => ci.EditedConfig == editedConfig);
			var section = sections [rc];
			ParentDialog.ShowPage (section);
		}
예제 #20
0
		internal void RemoveConfiguration (ProjectRunConfiguration editedConfig)
		{
			var c = configs.First (ci => ci.EditedConfig == editedConfig);
			configs.Remove (c);
			RemovePanel (c);
		}
예제 #21
0
		public ExecutionCommand CreateExecutionCommand (ConfigurationSelector configSel, DotNetProjectConfiguration configuration, ProjectRunConfiguration runConfiguration)
		{
			return ProjectExtension.OnCreateExecutionCommand (configSel, configuration, runConfiguration);
		}
		internal bool Equals (ProjectRunConfiguration other)
		{
			var dict1 = new Dictionary<string, string> ();
			var dict2 = new Dictionary<string, string> ();

			var thisData = new ProjectItemMetadata ();
			Write (thisData);
			GetProps (MainPropertyGroup, dict1);
			GetProps (thisData, dict1);

			var otherData = new ProjectItemMetadata ();
			other.Write (otherData);
			GetProps (other.MainPropertyGroup, dict2);
			GetProps (otherData, dict2);

			if (dict1.Count != dict2.Count)
				return false;
			foreach (var tp in dict1) {
				string v;
				if (!dict2.TryGetValue (tp.Key, out v) || tp.Value != v)
					return false;
			}
			return true;
		}
예제 #23
0
		internal protected virtual ExecutionCommand OnCreateExecutionCommand (ConfigurationSelector configSel, DotNetProjectConfiguration configuration, ProjectRunConfiguration runConfiguration)
		{
			ExecutionCommand rcmd;
			var rc = runConfiguration as AssemblyRunConfiguration;
			if (rc != null && rc.StartAction == AssemblyRunConfiguration.StartActions.Program) {
				var pcmd = Runtime.ProcessService.CreateCommand (rc.StartProgram);
				pcmd.Arguments = rc.StartArguments;
				pcmd.WorkingDirectory = rc.StartWorkingDirectory;
				pcmd.EnvironmentVariables = rc.EnvironmentVariables;
				rcmd = pcmd;
			} else {
#pragma warning disable 618 // Type or member is obsolete
				rcmd = ProjectExtension.OnCreateExecutionCommand (configSel, configuration);
#pragma warning restore 618 // Type or member is obsolete
			}

			var cmd = rcmd as DotNetExecutionCommand;
			if (cmd == null)
				return rcmd;

			if (rc != null) {
				// Don't directly overwrite the settings, since those may have been set by the OnCreateExecutionCommand
				// overload that doesn't take a runConfiguration.

				string monoOptions;
				rc.MonoParameters.GenerateOptions (cmd.EnvironmentVariables, out monoOptions);
				cmd.RuntimeArguments = monoOptions;
				if (!string.IsNullOrEmpty (rc.StartArguments))
					cmd.Arguments = rc.StartArguments;
				if (!rc.StartWorkingDirectory.IsNullOrEmpty)
					cmd.WorkingDirectory = rc.StartWorkingDirectory;
				foreach (var env in rc.EnvironmentVariables)
					cmd.EnvironmentVariables [env.Key] = env.Value;
				cmd.PauseConsoleOutput = rc.PauseConsoleOutput;
				cmd.ExternalConsole = rc.ExternalConsole;
				cmd.TargetRuntime = Runtime.SystemAssemblyService.GetTargetRuntime (rc.TargetRuntimeId);
			}
			return cmd;
		}
		/// <summary>
		/// Copies the data of a run configuration into this configuration
		/// </summary>
		/// <param name="config">Configuration from which to get the data.</param>
		/// <param name="isRename">If true, it means that the copy is being made as a result of a rename or clone operation. In this case,
		/// the overriden method may change the value of some properties that depend on the configuration name.</param>
		public void CopyFrom (ProjectRunConfiguration config, bool isRename = false)
		{
			StoreInUserFile = config.StoreInUserFile;
			OnCopyFrom (config, isRename);
		}
예제 #25
0
		internal void AddConfiguration (ProjectRunConfiguration editedConfig)
		{
			var c = new RunConfigInfo { EditedConfig = editedConfig };
			configs.Add (c);
			AddPanel (c);
		}