Example #1
0
		public void Load (Project project, ProjectConfiguration config)
		{	
			this.configuration = config;
			
			parametersEntry.Text = configuration.CommandLineParameters;
			externalConsoleCheckButton.Active = configuration.ExternalConsole;
			pauseConsoleOutputCheckButton.Active = configuration.PauseConsoleOutput;
			pauseConsoleOutputCheckButton.Sensitive = externalConsoleCheckButton.Active;
			
			envVarList.LoadValues (configuration.EnvironmentVariables);
		}
Example #2
0
        public PHPProject(ProjectCreateInformation info, XmlElement projectOptions, string language)
        {
            if (info != null) {
                Name = info.ProjectName;
            }

            ProjectConfiguration configuration = new ProjectConfiguration ();
            configuration.Name = "Debug";
            this.Configurations.Add (configuration);

            configuration = new ProjectConfiguration();
            configuration.Name = "Release";
            this.Configurations.Add (configuration);
        }
Example #3
0
        protected override BuildResult OnBuild(IProgressMonitor monitor, ConfigurationSelector configuration)
        {
            // create output directory, if not exists
            ProjectConfiguration conf = GetConfiguration(configuration) as ProjectConfiguration;

            if (conf == null)
            {
                BuildResult cres = new BuildResult();
                cres.AddError(GettextCatalog.GetString("Configuration '{0}' not found in project '{1}'", configuration.ToString(), Name));
                return(cres);
            }

            StringParserService.Properties["Project"] = Name;

            if (UsingMSBuildEngine(configuration))
            {
                return(DoBuild(monitor, configuration));
            }

            string outputDir = conf.OutputDirectory;

            try {
                DirectoryInfo directoryInfo = new DirectoryInfo(outputDir);
                if (!directoryInfo.Exists)
                {
                    directoryInfo.Create();
                }
            } catch (Exception e) {
                throw new ApplicationException("Can't create project output directory " + outputDir + " original exception:\n" + e.ToString());
            }

            //copy references and files marked to "CopyToOutputDirectory"
            CopySupportFiles(monitor, configuration);

            monitor.Log.WriteLine("Performing main compilation...");

            BuildResult res = DoBuild(monitor, configuration);

            if (res != null)
            {
                string errorString   = GettextCatalog.GetPluralString("{0} error", "{0} errors", res.ErrorCount, res.ErrorCount);
                string warningString = GettextCatalog.GetPluralString("{0} warning", "{0} warnings", res.WarningCount, res.WarningCount);

                monitor.Log.WriteLine(GettextCatalog.GetString("Build complete -- ") + errorString + ", " + warningString);
            }

            return(res);
        }
Example #4
0
        /// <summary>
        /// Copies the support files to the output directory
        /// </summary>
        /// <param name='monitor'>
        /// Progress monitor.
        /// </param>
        /// <param name='configuration'>
        /// Configuration for which to copy the files.
        /// </param>
        /// <remarks>
        /// Copies all support files to the output directory of the given configuration. Support files
        /// include: assembly references with the Local Copy flag, data files with the Copy to Output option, etc.
        /// </remarks>
        public void CopySupportFiles(IProgressMonitor monitor, ConfigurationSelector configuration)
        {
            ProjectConfiguration config = (ProjectConfiguration)GetConfiguration(configuration);

            foreach (FileCopySet.Item item in GetSupportFileList(configuration))
            {
                FilePath dest = Path.GetFullPath(Path.Combine(config.OutputDirectory, item.Target));
                FilePath src  = Path.GetFullPath(item.Src);

                try {
                    if (dest == src)
                    {
                        continue;
                    }

                    if (item.CopyOnlyIfNewer && File.Exists(dest) && (File.GetLastWriteTimeUtc(dest) >= File.GetLastWriteTimeUtc(src)))
                    {
                        continue;
                    }

                    // Use Directory.Create so we don't trigger the VersionControl addin and try to
                    // add the directory to version control.
                    if (!Directory.Exists(Path.GetDirectoryName(dest)))
                    {
                        Directory.CreateDirectory(Path.GetDirectoryName(dest));
                    }

                    if (File.Exists(src))
                    {
                        dest.Delete();
                        FileService.CopyFile(src, dest);

                        // Copied files can't be read-only, so they can be removed when rebuilding the project
                        FileAttributes atts = File.GetAttributes(dest);
                        if (atts.HasFlag(FileAttributes.ReadOnly))
                        {
                            File.SetAttributes(dest, atts & ~FileAttributes.ReadOnly);
                        }
                    }
                    else
                    {
                        monitor.ReportError(GettextCatalog.GetString("Could not find support file '{0}'.", src), null);
                    }
                } catch (IOException ex) {
                    monitor.ReportError(GettextCatalog.GetString("Error copying support file '{0}'.", dest), ex);
                }
            }
        }
        internal protected override bool OnGetCanExecute(ExecutionContext context, ConfigurationSelector configuration)
        {
            ProjectConfiguration config = (ProjectConfiguration)GetConfiguration(configuration);

            if (config == null)
            {
                return(false);
            }
            if (FileName.Extension.ToLower() != ".exe")
            {
                return(false);
            }
            ExecutionCommand cmd = CreateExecutionCommand(configuration, config);

            return(context.ExecutionHandler.CanExecute(cmd));
        }
        protected override bool OnGetCanExecute(ExecutionContext context, ConfigurationSelector configuration, SolutionItemRunConfiguration runConfiguration)
        {
            ProjectConfiguration config = (ProjectConfiguration)GetConfiguration(configuration);

            if (config == null)
            {
                return(false);
            }
            if (!string.Equals(FileName.Extension, ".exe", StringComparison.OrdinalIgnoreCase))
            {
                return(false);
            }
            ExecutionCommand cmd = CreateExecutionCommand(configuration, config);

            return(context.ExecutionHandler.CanExecute(cmd));
        }
        protected override void OnCopyFrom(ItemConfiguration configuration, bool isRename)
        {
            base.OnCopyFrom(configuration, isRename);

            ProjectConfiguration projectConf = configuration as ProjectConfiguration;

            if (isRename && projectConf.IntermediateOutputDirectory == projectConf.DefaultIntermediateOutputDirectory)
            {
                intermediateOutputDirectory = null;
            }
            else
            {
                intermediateOutputDirectory = projectConf.intermediateOutputDirectory;
            }

            outputDirectory = projectConf.outputDirectory;

            if (isRename && outputDirectory != null)
            {
                var ps = outputDirectory.ToString().Split(Path.DirectorySeparatorChar);
                int i  = Array.IndexOf(ps, configuration.Name);
                if (i != -1)
                {
                    ps [i]          = Name;
                    outputDirectory = string.Join(Path.DirectorySeparatorChar.ToString(), ps);
                }
            }

            debugMode             = projectConf.debugMode;
            pauseConsoleOutput    = projectConf.pauseConsoleOutput;
            externalConsole       = projectConf.externalConsole;
            commandLineParameters = projectConf.commandLineParameters;
            debugType             = projectConf.debugType;
            debugTypeWasNone      = projectConf.debugTypeWasNone;
            debugTypeReadAsEmpty  = projectConf.debugTypeReadAsEmpty;

            environmentVariables.Clear();
            foreach (KeyValuePair <string, string> el in projectConf.environmentVariables)
            {
                environmentVariables.Add(el.Key, el.Value);
            }

            runWithWarnings = projectConf.runWithWarnings;

            MainPropertyGroup.CopyFrom(projectConf.MainPropertyGroup);
        }
Example #8
0
        public override void CopyFrom(ItemConfiguration conf)
        {
            base.CopyFrom(conf);

            ProjectConfiguration projectConf = conf as ProjectConfiguration;

            outputDirectory       = projectConf.outputDirectory;
            debugMode             = projectConf.debugMode;
            pauseConsoleOutput    = projectConf.pauseConsoleOutput;
            externalConsole       = projectConf.externalConsole;
            commandLineParameters = projectConf.commandLineParameters;

            environmentVariables.Clear();
            foreach (KeyValuePair <string, string> el in projectConf.environmentVariables)
            {
                environmentVariables.Add(el.Key, el.Value);
            }

            runWithWarnings = projectConf.runWithWarnings;
        }
        internal protected override void OnExecute(IProgressMonitor monitor, ExecutionContext context, ConfigurationSelector configuration)
        {
            ProjectConfiguration conf = (ProjectConfiguration)GetConfiguration(configuration);

            monitor.Log.WriteLine(GettextCatalog.GetString("Running {0} ...", FileName));

            IConsole console = conf.ExternalConsole
                           ? context.ExternalConsoleFactory.CreateConsole(!conf.PauseConsoleOutput)
                           : context.ConsoleFactory.CreateConsole(!conf.PauseConsoleOutput);

            AggregatedOperationMonitor aggregatedOperationMonitor = new AggregatedOperationMonitor(monitor);

            try
            {
                try
                {
                    ExecutionCommand executionCommand = CreateExecutionCommand(configuration, conf);

                    if (!context.ExecutionHandler.CanExecute(executionCommand))
                    {
                        monitor.ReportError(GettextCatalog.GetString("Can not execute \"{0}\". The selected execution mode is not supported for .NET projects.", FileName), null);
                        return;
                    }

                    IProcessAsyncOperation asyncOp = context.ExecutionHandler.Execute(executionCommand, console);
                    aggregatedOperationMonitor.AddOperation(asyncOp);
                    asyncOp.WaitForCompleted();

                    monitor.Log.WriteLine(GettextCatalog.GetString("The application exited with code: {0}", asyncOp.ExitCode));
                }
                finally
                {
                    console.Dispose();
                    aggregatedOperationMonitor.Dispose();
                }
            }
            catch (Exception ex)
            {
                monitor.ReportError(GettextCatalog.GetString("Cannot execute \"{0}\"", FileName), ex);
            }
        }
Example #10
0
        /// <summary>
        /// Removes all support files from the output directory
        /// </summary>
        /// <param name='monitor'>
        /// Progress monitor.
        /// </param>
        /// <param name='configuration'>
        /// Configuration for which to delete the files.
        /// </param>
        /// <remarks>
        /// Deletes all support files from the output directory of the given configuration. Support files
        /// include: assembly references with the Local Copy flag, data files with the Copy to Output option, etc.
        /// </remarks>
        public void DeleteSupportFiles(IProgressMonitor monitor, ConfigurationSelector configuration)
        {
            ProjectConfiguration config = (ProjectConfiguration)GetConfiguration(configuration);

            foreach (FileCopySet.Item item in GetSupportFileList(configuration))
            {
                FilePath dest = Path.Combine(config.OutputDirectory, item.Target);

                // Ignore files which were not copied
                if (Path.GetFullPath(dest) == Path.GetFullPath(item.Src))
                {
                    continue;
                }

                try {
                    dest.Delete();
                } catch (IOException ex) {
                    monitor.ReportError(GettextCatalog.GetString("Error deleting support file '{0}'.", dest), ex);
                }
            }
        }
Example #11
0
        public void CopySupportFiles(IProgressMonitor monitor, ConfigurationSelector configuration)
        {
            ProjectConfiguration config = (ProjectConfiguration)GetConfiguration(configuration);

            foreach (FileCopySet.Item item in GetSupportFileList(configuration))
            {
                string dest = Path.GetFullPath(Path.Combine(config.OutputDirectory, item.Target));
                string src  = Path.GetFullPath(item.Src);

                try {
                    if (dest == src)
                    {
                        continue;
                    }

                    if (item.CopyOnlyIfNewer && File.Exists(dest) && (File.GetLastWriteTimeUtc(dest) >= File.GetLastWriteTimeUtc(src)))
                    {
                        continue;
                    }

                    if (!Directory.Exists(Path.GetDirectoryName(dest)))
                    {
                        FileService.CreateDirectory(Path.GetDirectoryName(dest));
                    }

                    if (File.Exists(src))
                    {
                        FileService.CopyFile(src, dest);
                    }
                    else
                    {
                        monitor.ReportError(GettextCatalog.GetString("Could not find support file '{0}'.", src), null);
                    }
                } catch (IOException ex) {
                    monitor.ReportError(GettextCatalog.GetString("Error copying support file '{0}'.", dest), ex);
                }
            }
        }
Example #12
0
        protected override void OnClean(IProgressMonitor monitor, ConfigurationSelector configuration)
        {
            SetDirty();

            ProjectConfiguration config = GetConfiguration(configuration) as ProjectConfiguration;

            if (config == null)
            {
                monitor.ReportError(GettextCatalog.GetString("Configuration '{0}' not found in project '{1}'", config.Id, Name), null);
                return;
            }

            if (UsingMSBuildEngine())
            {
                DoClean(monitor, config.Selector);
                return;
            }

            monitor.Log.WriteLine("Removing output files...");

            // Delete generated files
            foreach (FilePath file in GetOutputFiles(configuration))
            {
                if (File.Exists(file))
                {
                    file.Delete();
                    if (file.ParentDirectory.CanonicalPath != config.OutputDirectory.CanonicalPath && Directory.GetFiles(file.ParentDirectory).Length == 0)
                    {
                        file.ParentDirectory.Delete();
                    }
                }
            }

            DeleteSupportFiles(monitor, configuration);

            DoClean(monitor, config.Selector);
            monitor.Log.WriteLine(GettextCatalog.GetString("Clean complete"));
        }
Example #13
0
        protected async override Task OnExecute(ProgressMonitor monitor, ExecutionContext context, ConfigurationSelector configuration, SolutionItemRunConfiguration runConfiguration)
        {
            ProjectConfiguration conf = (ProjectConfiguration)GetConfiguration(configuration);

            monitor.Log.WriteLine(GettextCatalog.GetString("Running {0} ...", FileName));

            OperationConsole console = conf.ExternalConsole
                                ? context.ExternalConsoleFactory.CreateConsole(!conf.PauseConsoleOutput, monitor.CancellationToken)
                                                                                   : context.ConsoleFactory.CreateConsole(
                OperationConsoleFactory.CreateConsoleOptions.Default.WithTitle(Path.GetFileName(FileName)), monitor.CancellationToken);

            try {
                try {
                    ExecutionCommand executionCommand = CreateExecutionCommand(configuration, conf);

                    if (!context.ExecutionHandler.CanExecute(executionCommand))
                    {
                        monitor.ReportError(GettextCatalog.GetString("Can not execute \"{0}\". The selected execution mode is not supported for .NET projects.", FileName), null);
                        return;
                    }

                    ProcessAsyncOperation asyncOp = context.ExecutionHandler.Execute(executionCommand, console);
                    var stopper = monitor.CancellationToken.Register(asyncOp.Cancel);

                    await asyncOp.Task;

                    stopper.Dispose();

                    monitor.Log.WriteLine(GettextCatalog.GetString("The application exited with code: {0}", asyncOp.ExitCode));
                } finally {
                    console.Dispose();
                }
            } catch (Exception ex) {
                LoggingService.LogError(string.Format("Cannot execute \"{0}\"", FileName), ex);
                monitor.ReportError(GettextCatalog.GetString("Cannot execute \"{0}\"", FileName), ex);
            }
        }
		internal protected virtual void OnWriteConfiguration (ProgressMonitor monitor, ProjectConfiguration config, IPropertySet pset)
		{
			next.OnWriteConfiguration (monitor, config, pset);
		}
Example #15
0
 internal protected virtual void OnWriteConfiguration(ProgressMonitor monitor, ProjectConfiguration config, IPropertySet pset)
 {
     next.OnWriteConfiguration(monitor, config, pset);
 }
		protected override void OnReadConfiguration (ProgressMonitor monitor, ProjectConfiguration config, IMSBuildEvaluatedPropertyCollection pset)
		{
			base.OnReadConfiguration (monitor, config, pset);

			// Backwards compatibility. Move parameters to the project parameters object

			var prop = pset.GetProperty ("ApplicationIcon");
			if (prop != null)
				win32Icon = prop.GetPathValue ();

			prop = pset.GetProperty ("Win32Resource");
			if (prop != null)
				win32Resource = prop.GetPathValue ();

			prop = pset.GetProperty ("StartupObject");
			if (prop != null)
				mainclass = prop.Value;

			prop = pset.GetProperty ("CodePage");
			if (prop != null)
				codePage = int.Parse (prop.Value);
		}
		protected override void OnWriteConfiguration (ProgressMonitor monitor, ProjectConfiguration config, IPropertySet pset)
		{
			base.OnWriteConfiguration (monitor, config, pset);
			if (MSBuildProject.IsNewProject)
				pset.SetValue ("ErrorReport", "prompt");
			
		}
		protected virtual ExecutionCommand CreateExecutionCommand (ConfigurationSelector configSel, ProjectConfiguration configuration)
		{
			DotNetExecutionCommand cmd = new DotNetExecutionCommand (FileName);
			cmd.Arguments = configuration.CommandLineParameters;
			cmd.WorkingDirectory = Path.GetDirectoryName (FileName);
			cmd.EnvironmentVariables = new Dictionary<string, string> (configuration.EnvironmentVariables);
			return cmd;
		}
		protected override void OnWriteConfiguration (ProgressMonitor monitor, ProjectConfiguration config, IPropertySet pset)
		{
			base.OnWriteConfiguration (monitor, config, pset);
			pset.SetValue ("OutputPath", config.OutputDirectory);
		}
Example #20
0
 protected override void OnWriteConfiguration(ProgressMonitor monitor, ProjectConfiguration config, IPropertySet pset)
 {
     base.OnWriteConfiguration(monitor, config, pset);
     pset.SetValue("OutputPath", config.OutputDirectory);
 }
		internal protected virtual void OnReadConfiguration (ProgressMonitor monitor, ProjectConfiguration config, IMSBuildEvaluatedPropertyCollection pset)
		{
			next.OnReadConfiguration (monitor, config, pset);
		}
        protected virtual ExecutionCommand CreateExecutionCommand(ConfigurationSelector configSel, ProjectConfiguration configuration)
        {
            DotNetExecutionCommand cmd = new DotNetExecutionCommand(FileName);

            cmd.Arguments            = configuration.CommandLineParameters;
            cmd.WorkingDirectory     = Path.GetDirectoryName(FileName);
            cmd.EnvironmentVariables = new Dictionary <string, string> (configuration.EnvironmentVariables);
            return(cmd);
        }
 internal protected virtual void OnReadConfiguration(ProgressMonitor monitor, ProjectConfiguration config, IMSBuildEvaluatedPropertyCollection pset)
 {
     next.OnReadConfiguration(monitor, config, pset);
 }