예제 #1
0
        void InstallEntry(ProgressMonitor monitor, DeployContext ctx, SolutionFolderItem entry, ConfigurationSelector configuration)
        {
            foreach (DeployFile df in DeployService.GetDeployFiles(ctx, new SolutionFolderItem[] { entry }, configuration))
            {
                string targetPath = df.ResolvedTargetFile;
                if (targetPath == null)
                {
                    monitor.ReportWarning("Could not copy file '" + df.RelativeTargetPath + "': Unknown target directory.");
                    continue;
                }

                CopyFile(monitor, df.SourcePath, df.ResolvedTargetFile, df.FileAttributes);
            }

            SolutionFolder c = entry as SolutionFolder;

            if (c != null)
            {
                monitor.BeginTask("Installing solution '" + c.Name + "'", c.Items.Count);
                foreach (SolutionFolderItem ce in c.Items)
                {
                    InstallEntry(monitor, ctx, ce, configuration);
                    monitor.Step(1);
                }
                monitor.EndTask();
            }
        }
		public virtual DeployFileCollection GetCombineDeployFiles (DeployContext ctx, SolutionFolder combine, ConfigurationSelector configuration)
		{
			if (Next != null)
				return Next.GetDeployFiles (ctx, combine, configuration);
			else
				return new DeployFileCollection ();
		}
		public override DeployFileCollection GetProjectDeployFiles (DeployContext ctx, Project project, ConfigurationSelector config)
		{
			DeployFileCollection col = base.GetProjectDeployFiles (ctx, project, config);
			
			LinuxDeployData data = LinuxDeployData.GetLinuxDeployData (project);
			
			if (ctx.Platform == "Linux") {
				DotNetProject netProject = project as DotNetProject;
				if (netProject != null) {
					DotNetProjectConfiguration conf = netProject.GetConfiguration (config) as DotNetProjectConfiguration;
					if (conf != null) {
						if (conf.CompileTarget == CompileTarget.Exe || conf.CompileTarget == CompileTarget.WinExe) {
							if (data.GenerateScript) {
								col.Add (GenerateLaunchScript (ctx, netProject, data, conf));
							}
						}
						if (conf.CompileTarget == CompileTarget.Library || conf.CompiledOutputName.FileName.EndsWith (".dll")) {
							if (data.GeneratePcFile) {
								col.Add (GeneratePcFile (ctx, netProject, data, conf));
							}
						}
					}
				}
			}
			
			// If the project is deploying an app.desktop file, rename it to the name of the project.
			foreach (DeployFile file in col) {
				if (Path.GetFileName (file.RelativeTargetPath) == "app.desktop") {
					string dir = Path.GetDirectoryName (file.RelativeTargetPath);
					file.RelativeTargetPath = Path.Combine (dir, data.PackageName + ".desktop");
				}
			}
			
			return col;
		}
		// Returns the path for the provided folderId.
		// The prefix can be null, an absolute path, or a symbolic representation
		// of a folder (e.g. a makefile variable)
		public virtual string ResolveDirectory (DeployContext context, string folderId)
		{
			if (Next != null)
				return Next.ResolveDirectory (context, folderId);
			else
				return null;
		}
예제 #5
0
        internal bool Build(ProgressMonitor monitor)
        {
            monitor.BeginTask("Package: " + Description, 1);
            DeployContext ctx = null;

            try {
                ctx = CreateDeployContext();
                if (ctx != null)
                {
                    ctx.FileFilter = this;
                }
                if (!OnBuild(monitor, ctx))
                {
                    return(false);
                }
            } catch (Exception ex) {
                monitor.ReportError("Package creation failed", ex);
                LoggingService.LogError("Package creation failed", ex);
                return(false);
            } finally {
                monitor.EndTask();
                if (ctx != null)
                {
                    ctx.Dispose();
                }
            }
            return(true);
        }
		public override DeployFileCollection GetDeployFiles (DeployContext ctx, SolutionItem entry, ConfigurationSelector configuration)
		{
			if (entry is IDeployable)
				return new DeployFileCollection (((IDeployable)entry).GetDeployFiles (configuration));
			
			return base.GetDeployFiles (ctx, entry, configuration);
		}
예제 #7
0
        public static DeployFileCollection GetDeployFiles(DeployContext ctx, SolutionFolderItem entry, ConfigurationSelector configuration)
        {
            ArrayList todel = new ArrayList();

            DeployFileCollection col = GetExtensionChain().GetDeployFiles(ctx, entry, configuration);

            foreach (DeployFile df in col)
            {
                if (!ctx.IncludeFile(df))
                {
                    todel.Add(df);
                    continue;
                }
                df.SetContext(ctx);
                if (df.ContainsPathReferences)
                {
                    string name = df.DisplayName;
                    df.SourcePath  = ProcessFileTemplate(ctx, df.SourcePath);
                    df.DisplayName = name;
                }
            }
            foreach (DeployFile df in todel)
            {
                col.Remove(df);
            }
            return(col);
        }
		public virtual DeployFileCollection GetProjectDeployFiles (DeployContext ctx, Project project, ConfigurationSelector configuration)
		{
			if (Next != null)
				return Next.GetDeployFiles (ctx, project, configuration);
			else
				return new DeployFileCollection ();
		}
예제 #9
0
        internal static string ProcessFileTemplate(DeployContext ctx, string file)
        {
            TextFile      tf      = TextFile.ReadFile(file);
            string        text    = tf.Text;
            StringBuilder sb      = new StringBuilder();
            int           lastPos = 0;
            int           pos     = text.IndexOf('@');

            while (pos != -1)
            {
                int ep = text.IndexOf('@', pos + 1);
                if (ep == -1)
                {
                    break;
                }
                string tag = text.Substring(pos + 1, ep - pos - 1);
                string dir = ctx.GetDirectory(tag);
                if (dir != null)
                {
                    sb.Append(text, lastPos, pos - lastPos);
                    sb.Append(dir);
                    lastPos = ep + 1;
                }
                pos = text.IndexOf('@', ep + 1);
            }
            sb.Append(text, lastPos, text.Length - lastPos);
            string tmp = ctx.CreateTempFile();

            TextFile.WriteFile(tmp, sb.ToString(), tf.SourceEncoding);
            return(tmp);
        }
		public override DeployFileCollection GetProjectDeployFiles (DeployContext ctx, Project project, 
		                                                            ConfigurationSelector configuration)
		{
			DeployFileCollection files = base.GetProjectDeployFiles (ctx, project, configuration);
			
			AspNetAppProject aspProj = project as AspNetAppProject;
			
			//none of this needs to happen if it's just happening during solution build
			if (aspProj == null || ctx.ProjectBuildOnly)
				return files;
			
			//audit the DeployFiles to make sure they're allowed and laid out for ASP.NET
			foreach (DeployFile df in files) {
				//rewrite ProgramFiles target to ASP.NET's "bin" target
				if (df.TargetDirectoryID == TargetDirectory.ProgramFiles) {
					df.RelativeTargetPath = Path.Combine ("bin", df.RelativeTargetPath);
				}
			}
			
			//add all ASP.NET files marked as content. They go relative to the application root, which we assume to be ProgramFiles
			foreach (ProjectFile pf in aspProj.Files) {
				if (pf.BuildAction == BuildAction.Content)
					files.Add (new DeployFile (aspProj, pf.FilePath, pf.ProjectVirtualPath, TargetDirectory.ProgramFiles));
			}
			
			return files;
		}
		public void Install (ProgressMonitor monitor, SolutionFolderItem entry, string appName, string prefix, ConfigurationSelector configuration)
		{
			this.appName = appName;
			
			using (DeployContext ctx = new DeployContext (this, DeployService.CurrentPlatform, prefix)) {
				InstallEntry (monitor, ctx, entry, configuration);
			}
		}
		public void Install (IProgressMonitor monitor, SolutionItem entry, string appName, string prefix, ConfigurationSelector configuration)
		{
			this.appName = appName;
			
			using (DeployContext ctx = new DeployContext (this, "Linux", prefix)) {
				InstallEntry (monitor, ctx, entry, configuration);
			}
		}
예제 #13
0
        public void Install(IProgressMonitor monitor, SolutionItem entry, string appName, string prefix, ConfigurationSelector configuration)
        {
            this.appName = appName;

            using (DeployContext ctx = new DeployContext(this, "Linux", prefix)) {
                InstallEntry(monitor, ctx, entry, configuration);
            }
        }
예제 #14
0
        public void Install(ProgressMonitor monitor, SolutionFolderItem entry, string appName, string prefix, ConfigurationSelector configuration)
        {
            this.appName = appName;

            using (DeployContext ctx = new DeployContext(this, DeployService.CurrentPlatform, prefix)) {
                InstallEntry(monitor, ctx, entry, configuration);
            }
        }
예제 #15
0
        public override DeployFileCollection GetProjectDeployFiles(DeployContext ctx, Project project, ConfigurationSelector configuration)
        {
            DeployFileCollection deployFiles = new DeployFileCollection();

            base.GetProjectDeployFiles(ctx, project, configuration);
            // Add the compiled output file

            string outputFile = project.GetOutputFileName(configuration);

            if (!string.IsNullOrEmpty(outputFile))
            {
                deployFiles.Add(new DeployFile(project, outputFile, Path.GetFileName(outputFile), TargetDirectory.ProgramFiles));
            }

            // Collect deployable files
            foreach (ProjectFile file in project.Files)
            {
                // skip CopyToOutputDirectory files when it's just a project build, because
                // MonoDevelop.Project.Projects already copies these files using more subtle overwriting
                // semantics
                if (file.CopyToOutputDirectory != FileCopyMode.None)
                {
                    continue;
                }

                DeployProperties props = new DeployProperties(file);
                if (props.ShouldDeploy)
                {
                    DeployFile dp = new DeployFile(file);
                    deployFiles.Add(dp);

                    if (string.Compare(Path.GetFileName(dp.SourcePath), "app.config", true) == 0 && string.Compare(Path.GetFileName(dp.RelativeTargetPath), "app.config", true) == 0)
                    {
                        string newName = Path.GetFileName(outputFile) + ".config";
                        dp.RelativeTargetPath = Path.Combine(Path.GetDirectoryName(dp.RelativeTargetPath), newName);
                    }
                }
            }

            foreach (FileCopySet.Item item in project.GetSupportFileList(configuration))
            {
                deployFiles.Add(new DeployFile(project, item.Src, item.Target, TargetDirectory.ProgramFiles));
            }

            DotNetProject netProject = project as DotNetProject;

            if (netProject != null)
            {
                DotNetProjectConfiguration conf = (DotNetProjectConfiguration)project.GetConfiguration(configuration);
                if (conf.DebugMode)
                {
                    string mdbFile = netProject.TargetRuntime.GetAssemblyDebugInfoFile(conf.CompiledOutputName);
                    deployFiles.Add(new DeployFile(project, mdbFile, Path.GetFileName(mdbFile), TargetDirectory.ProgramFiles));
                }
            }

            return(deployFiles);
        }
        public override DeployFileCollection GetDeployFiles(DeployContext ctx, SolutionItem entry, ConfigurationSelector configuration)
        {
            if (entry is IDeployable)
            {
                return(new DeployFileCollection(((IDeployable)entry).GetDeployFiles(configuration)));
            }

            return(base.GetDeployFiles(ctx, entry, configuration));
        }
예제 #17
0
        public static DeployFileCollection GetDeployFiles(DeployContext ctx, SolutionFolderItem[] entries, ConfigurationSelector configuration)
        {
            DeployFileCollection col = new DeployFileCollection();

            foreach (SolutionFolderItem e in entries)
            {
                col.AddRange(GetDeployFiles(ctx, e, configuration));
            }
            return(col);
        }
 // Returns the path for the provided folderId.
 // The prefix can be null, an absolute path, or a symbolic representation
 // of a folder (e.g. a makefile variable)
 public virtual string ResolveDirectory(DeployContext context, string folderId)
 {
     if (Next != null)
     {
         return(Next.ResolveDirectory(context, folderId));
     }
     else
     {
         return(null);
     }
 }
 public virtual DeployFileCollection GetProjectDeployFiles(DeployContext ctx, Project project, ConfigurationSelector configuration)
 {
     if (Next != null)
     {
         return(Next.GetDeployFiles(ctx, project, configuration));
     }
     else
     {
         return(new DeployFileCollection());
     }
 }
 public virtual DeployFileCollection GetCombineDeployFiles(DeployContext ctx, SolutionFolder combine, ConfigurationSelector configuration)
 {
     if (Next != null)
     {
         return(Next.GetDeployFiles(ctx, combine, configuration));
     }
     else
     {
         return(new DeployFileCollection());
     }
 }
		public virtual DeployFileCollection GetDeployFiles (DeployContext ctx, SolutionFolderItem entry, ConfigurationSelector configuration)
		{
			if (entry is SolutionFolder)
				return GetCombineDeployFiles (ctx, (SolutionFolder) entry, configuration);
			else if (entry is Project)
				return GetProjectDeployFiles (ctx, (Project) entry, configuration);
			else if (Next != null)
				return Next.GetDeployFiles (ctx, entry, configuration);
			else
				return new DeployFileCollection ();
		}
예제 #22
0
		public string GetDirectory (DeployContext context, string folderId)
		{
			if (folderId == TargetDirectory.ProgramFiles)
				return string.Empty;
			
			// While this would seem to be what the deploy API expects, for a web deploy it could 
			// produces results the user wouldn't expect
			//if (context.Prefix != null)
			//	directory = Path.Combine (context.Prefix, directory);
			
			return null;
		}
예제 #23
0
        public string GetDirectory(DeployContext ctx, string folderId)
        {
            switch (folderId)
            {
            case TargetDirectory.ProgramFiles:
                return(Path.Combine(ctx.GetDirectory(TargetDirectory.ProgramFilesRoot), appName));

            case TargetDirectory.CommonApplicationData:
                return(Path.Combine(ctx.GetDirectory(TargetDirectory.ProgramFilesRoot), appName));
            }

            if (ctx.Platform == "Linux" || ctx.Platform == "Unix")
            {
                string prefix = ctx.Prefix;
                if (prefix == null)
                {
                    prefix = "/usr/local";
                }
                switch (folderId)
                {
                case TargetDirectory.ProgramFilesRoot:
                    return(Path.Combine(prefix, "lib"));

                case TargetDirectory.CommonApplicationDataRoot:
                    return(Path.Combine(prefix, "share"));

                case TargetDirectory.Binaries:
                    return(Path.Combine(prefix, "bin"));

                case TargetDirectory.IncludeRoot:
                    return(Path.Combine(prefix, "include"));

                case TargetDirectory.Include:
                    return(Path.Combine(ctx.GetDirectory(TargetDirectory.IncludeRoot), appName));
                }
            }
            else if (ctx.Platform == "Windows")
            {
                switch (folderId)
                {
                case TargetDirectory.ProgramFilesRoot:
                    return(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles));

                case TargetDirectory.Binaries:
                    return(Path.Combine(ctx.GetDirectory(TargetDirectory.ProgramFilesRoot), appName));

                case TargetDirectory.CommonApplicationDataRoot:
                    return(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData));
                }
            }
            return(null);
        }
		public override DeployFileCollection GetProjectDeployFiles (DeployContext ctx, Project project, ConfigurationSelector configuration)
		{
			DeployFileCollection deployFiles = new DeployFileCollection ();
			base.GetProjectDeployFiles (ctx, project, configuration);
			// Add the compiled output file
			
			string outputFile = project.GetOutputFileName (configuration);
			if (!string.IsNullOrEmpty (outputFile))
				deployFiles.Add (new DeployFile (project, outputFile, Path.GetFileName (outputFile), TargetDirectory.ProgramFiles));
			
			// Collect deployable files
			foreach (ProjectFile file in project.Files) {
				// skip CopyToOutputDirectory files when it's just a project build, because 
				// MonoDevelop.Project.Projects already copies these files using more subtle overwriting
				// semantics
				if (file.CopyToOutputDirectory != FileCopyMode.None)
					continue;
				    
				DeployProperties props = new DeployProperties (file);
				if (props.ShouldDeploy) {
					DeployFile dp = new DeployFile (file);
					deployFiles.Add (dp);
					
					if (string.Compare (Path.GetFileName (dp.SourcePath), "app.config", true)==0 && string.Compare (Path.GetFileName (dp.RelativeTargetPath), "app.config", true)==0) {
						string newName = Path.GetFileName (outputFile) + ".config";
						dp.RelativeTargetPath = Path.Combine (Path.GetDirectoryName (dp.RelativeTargetPath), newName);
					}
				}
			}
			
			foreach (FileCopySet.Item item in project.GetSupportFileList (configuration)) {
				 deployFiles.Add (new DeployFile (project, item.Src, item.Target, TargetDirectory.ProgramFiles));
			}
			
			DotNetProject netProject = project as DotNetProject;
			if (netProject != null) {
				DotNetProjectConfiguration conf = (DotNetProjectConfiguration) project.GetConfiguration (configuration);
				if (conf.DebugMode) {
					string mdbFile = netProject.TargetRuntime.GetAssemblyDebugInfoFile (conf.CompiledOutputName);
					deployFiles.Add (new DeployFile (project, mdbFile, Path.GetFileName (mdbFile), TargetDirectory.ProgramFiles));
				}
			}
			
			return deployFiles;
		}
        public void Fill(PackageBuilder builder)
        {
            if (context != null)
            {
                context.Dispose();
            }

            this.builder = builder;
            this.context = builder.CreateDeployContext();

            store.Clear();

            string[] configs = builder.GetSupportedConfigurations();

            string currentActive = comboConfigs.Active != -1 ? comboConfigs.ActiveText : null;
            int    i             = Array.IndexOf(configs, currentActive);

            if (i == -1)
            {
                i = 0;
            }

            ((Gtk.ListStore)comboConfigs.Model).Clear();
            foreach (string conf in configs)
            {
                comboConfigs.AppendText(conf);
            }

            if (configs.Length <= 1)
            {
                labelFiles.Text      = GettextCatalog.GetString("The following files will be included in the package:");
                comboConfigs.Visible = false;
                if (configs.Length == 0)
                {
                    return;
                }
            }
            else if (configs.Length > 0)
            {
                comboConfigs.Visible = true;
                labelFiles.Text      = GettextCatalog.GetString("The following files will be included in the package for the configuration:");
            }

            comboConfigs.Active = i;
        }
        public override DeployFileCollection GetProjectDeployFiles(DeployContext ctx, Project project, ConfigurationSelector configuration)
        {
            DeployFileCollection deployFiles = new DeployFileCollection();

            base.GetProjectDeployFiles(ctx, project, configuration);

            // Add the compiled output files

            ProjectConfiguration pconf  = (ProjectConfiguration)project.GetConfiguration(configuration);
            FilePath             outDir = pconf.OutputDirectory;

            foreach (FilePath file in project.GetOutputFiles(configuration))
            {
                deployFiles.Add(new DeployFile(project, file, file.ToRelative(outDir), TargetDirectory.ProgramFiles));
            }

//			FilePath outputFile = project.GetOutputFileName (configuration);

            // Collect deployable files
            foreach (ProjectFile file in project.Files)
            {
                // skip CopyToOutputDirectory files when it's just a project build, because
                // MonoDevelop.Project.Projects already copies these files using more subtle overwriting
                // semantics
                if (file.CopyToOutputDirectory != FileCopyMode.None)
                {
                    continue;
                }

                DeployProperties props = new DeployProperties(file);
                if (props.ShouldDeploy)
                {
                    DeployFile dp = new DeployFile(file);
                    deployFiles.Add(dp);
                }
            }

            foreach (FileCopySet.Item item in project.GetSupportFileList(configuration))
            {
                deployFiles.Add(new DeployFile(project, item.Src, item.Target, TargetDirectory.ProgramFiles));
            }

            return(deployFiles);
        }
 public virtual DeployFileCollection GetDeployFiles(DeployContext ctx, SolutionItem entry, ConfigurationSelector configuration)
 {
     if (entry is SolutionFolder)
     {
         return(GetCombineDeployFiles(ctx, (SolutionFolder)entry, configuration));
     }
     else if (entry is Project)
     {
         return(GetProjectDeployFiles(ctx, (Project)entry, configuration));
     }
     else if (Next != null)
     {
         return(Next.GetDeployFiles(ctx, entry, configuration));
     }
     else
     {
         return(new DeployFileCollection());
     }
 }
		DeployFile GenerateLaunchScript (DeployContext ctx, DotNetProject netProject, LinuxDeployData data, DotNetProjectConfiguration conf)
		{
			string file = ctx.CreateTempFile ();
			string exe = "@ProgramFiles@/" + Path.GetFileName (conf.CompiledOutputName);
			
			using (StreamWriter sw = new StreamWriter (file)) {
				sw.WriteLine ("#!/bin/sh");
				sw.WriteLine ();
				sw.WriteLine ("exec mono \"" + exe + "\" \"$@\"");
			}
			string outfile = data.ScriptName;
			if (string.IsNullOrEmpty (outfile))
				outfile = netProject.Name.ToLower ();
			DeployFile df = new DeployFile (netProject, file, outfile, TargetDirectory.Binaries);
			df.ContainsPathReferences = true;
			df.DisplayName = GettextCatalog.GetString ("Launch script for {0}", netProject.Name);
			df.FileAttributes = DeployFileAttributes.Executable;
			return df;
		}
		public override DeployFileCollection GetProjectDeployFiles (DeployContext ctx, Project project, ConfigurationSelector configuration)
		{
			DeployFileCollection deployFiles = new DeployFileCollection ();
			base.GetProjectDeployFiles (ctx, project, configuration);
			
			// Add the compiled output files
			
			ProjectConfiguration pconf = (ProjectConfiguration) project.GetConfiguration (configuration);
			FilePath outDir = pconf.OutputDirectory;
			foreach (FilePath file in project.GetOutputFiles (configuration)) {
				deployFiles.Add (new DeployFile (project, file, file.ToRelative (outDir), TargetDirectory.ProgramFiles));
			}
			
			FilePath outputFile = project.GetOutputFileName (configuration);
			
			// Collect deployable files
			foreach (ProjectFile file in project.Files) {
				// skip CopyToOutputDirectory files when it's just a project build, because 
				// MonoDevelop.Project.Projects already copies these files using more subtle overwriting
				// semantics
				if (file.CopyToOutputDirectory != FileCopyMode.None)
					continue;
				    
				DeployProperties props = new DeployProperties (file);
				if (props.ShouldDeploy) {
					DeployFile dp = new DeployFile (file);
					deployFiles.Add (dp);
					
					if (string.Compare (Path.GetFileName (dp.SourcePath), "app.config", true)==0 && string.Compare (Path.GetFileName (dp.RelativeTargetPath), "app.config", true)==0) {
						string newName = Path.GetFileName (outputFile) + ".config";
						dp.RelativeTargetPath = Path.Combine (Path.GetDirectoryName (dp.RelativeTargetPath), newName);
					}
				}
			}
			
			foreach (FileCopySet.Item item in project.GetSupportFileList (configuration)) {
				 deployFiles.Add (new DeployFile (project, item.Src, item.Target, TargetDirectory.ProgramFiles));
			}
			
			return deployFiles;
		}
		void InstallEntry (ProgressMonitor monitor, DeployContext ctx, SolutionFolderItem entry, ConfigurationSelector configuration)
		{
			foreach (DeployFile df in DeployService.GetDeployFiles (ctx, new SolutionFolderItem[] { entry }, configuration)) {
				string targetPath = df.ResolvedTargetFile;
				if (targetPath == null) {
					monitor.ReportWarning ("Could not copy file '" + df.RelativeTargetPath + "': Unknown target directory.");
					continue;
				}
				
				CopyFile (monitor, df.SourcePath, df.ResolvedTargetFile, df.FileAttributes);
			}
			
			SolutionFolder c = entry as SolutionFolder;
			if (c != null) {
				monitor.BeginTask ("Installing solution '" + c.Name + "'", c.Items.Count);
				foreach (SolutionFolderItem ce in c.Items) {
					InstallEntry (monitor, ctx, ce, configuration);
					monitor.Step (1);
				}
				monitor.EndTask ();
			}
		}
		DeployFile GeneratePcFile (DeployContext ctx, DotNetProject netProject, LinuxDeployData data, DotNetProjectConfiguration conf)
		{
			string libs = "-r:@ProgramFiles@/" + Path.GetFileName (conf.CompiledOutputName);
			string requires = "";
			string version = netProject.Version;
			if (string.IsNullOrEmpty (version) && netProject.ParentSolution != null)
				version = netProject.ParentSolution.Version;
			    
			string file = ctx.CreateTempFile ();
			using (StreamWriter sw = new StreamWriter (file)) {
				sw.WriteLine ("Name: " + netProject.Name);
				sw.WriteLine ("Description: " + (String.IsNullOrEmpty(netProject.Description) ? netProject.Name : netProject.Description));
				sw.WriteLine ("Version: " + version);
				sw.WriteLine ();
				sw.WriteLine ("Requires: " + requires);
				sw.WriteLine ("Libs: " + libs);
			}
			string outfile = netProject.Name.ToLower () + ".pc";
			DeployFile df = new DeployFile (netProject, file, outfile, LinuxTargetDirectory.PkgConfig);
			df.ContainsPathReferences = true;
			df.DisplayName = GettextCatalog.GetString ("pkg-config file for {0}", netProject.Name);
			return df;
		}
		public virtual DeployFileCollection GetDeployFiles (DeployContext ctx, ConfigurationSelector configuration)
		{
			return DeployService.GetDeployFiles (ctx, GetAllEntries (), configuration);
		}
		protected virtual string OnResolveDirectory (DeployContext ctx, string folderId)
		{
			return null;
		}
예제 #34
0
 protected virtual string OnResolveDirectory(DeployContext ctx, string folderId)
 {
     return(null);
 }
예제 #35
0
		internal static string GetDeployDirectory (DeployContext ctx, string folderId)
		{
			return GetExtensionChain ().ResolveDirectory (ctx, folderId);
		}
예제 #36
0
		public static DeployFileCollection GetDeployFiles (DeployContext ctx, SolutionFolderItem[] entries, ConfigurationSelector configuration)
		{
			DeployFileCollection col = new DeployFileCollection ();
			foreach (SolutionFolderItem e in entries) {
				col.AddRange (GetDeployFiles (ctx, e, configuration));
			}
			return col;
		}
예제 #37
0
 protected virtual bool OnBuild(ProgressMonitor monitor, DeployContext ctx)
 {
     return(true);
 }
예제 #38
0
		protected override bool OnBuild (IProgressMonitor monitor, DeployContext ctx)
		{
			string tmpFolder = FileService.CreateTempDirectory ();
			Solution solution = null;
			SolutionItem entry = RootSolutionItem;
			
			try {
				if (generateFiles) {
					List<string> childEntries = new List<string> ();
					if (entry is SolutionFolder) {
						SolutionItem[] ents = GetChildEntries ();
						foreach (SolutionItem it in ents)
							childEntries.Add (it.ItemId);
					}
					else {
						// If the entry is not a combine, use the parent combine as base combine
						childEntries.Add (entry.ItemId);
						entry = entry.ParentFolder;
					}
							
					string sourceFile;
					if (entry is SolutionFolder)
						sourceFile = entry.ParentSolution.FileName;
					else
						sourceFile = ((SolutionEntityItem)entry).FileName;
					
					string efile = Services.ProjectService.Export (new FilteredProgressMonitor (monitor), sourceFile, childEntries.ToArray (), tmpFolder, null);
					if (efile == null) {
						monitor.ReportError (GettextCatalog.GetString ("The project could not be exported."), null);
						return false;
					}
					solution = Services.ProjectService.ReadWorkspaceItem (new NullProgressMonitor (), efile) as Solution;
				}
				else {
					solution = entry.ParentSolution;
				}
				
				solution.Build (monitor, (SolutionConfigurationSelector) defaultConfig);
			
				if (monitor.IsCancelRequested || !monitor.AsyncOperation.Success)
					return false;
			
				SolutionDeployer deployer = new SolutionDeployer (generateAutotools);
				deployer.AddSwitches (switchs);
				
				if (!deployer.Deploy ( ctx, solution, DefaultConfiguration, TargetDir, generateFiles, monitor ))
					return false;
				
			} finally {
				if (solution != null)
					solution.Dispose ();
				Directory.Delete (tmpFolder, true);
			}
			return true;
		}
		public bool Deploy ( DeployContext ctx, Solution solution, string defaultConf, string targetDir, bool generateFiles, IProgressMonitor monitor  )
		{
			if (generateFiles) {
				if ( !GenerateFiles ( ctx, solution, defaultConf, monitor ) ) 
					return false;
			}
			
			monitor.BeginTask ( GettextCatalog.GetString( "Deploying Solution to Tarball" ) , 3 );
			try
			{
				string baseDir = Path.GetDirectoryName ( solution.FileName);
	
				ProcessWrapper ag_process = Runtime.ProcessService.StartProcess ( "sh", 
						generateAutotools ? "autogen.sh" : "configure",
						baseDir, 
						monitor.Log, 
						monitor.Log, 
						null );
				ag_process.WaitForOutput ();
				
				if ( ag_process.ExitCode > 0 )
					throw new Exception ( GettextCatalog.GetString ("An unspecified error occurred while running '{0}'", generateAutotools ? "autogen.sh" : "configure") );
				
				monitor.Step ( 1 );

				StringWriter sw = new StringWriter ();
				LogTextWriter chainedOutput = new LogTextWriter ();
				chainedOutput.ChainWriter (monitor.Log);
				chainedOutput.ChainWriter (sw);

				ProcessWrapper process = Runtime.ProcessService.StartProcess ( "make", 
						"dist", 
						baseDir, 
						chainedOutput, 
						monitor.Log, 
						null );
				process.WaitForOutput ();

				if ( process.ExitCode > 0 )
					throw new Exception ( GettextCatalog.GetString ("An unspecified error occurred while running '{0}'", "make dist") );

				monitor.Step ( 1 );

				// FIXME: hackish way to get the created tarball's filename
				string output = sw.ToString();
				int targz = output.LastIndexOf  ( "tar.gz" );
				int begin = output.LastIndexOf ( '>', targz );

				string filename = output.Substring ( begin + 1, (targz - begin) + 5 ).Trim ();
				
				FileService.CopyFile (Path.Combine (baseDir, filename), Path.Combine (targetDir, filename));
				monitor.Step ( 1 );
			}
			catch ( Exception e )
			{
				monitor.ReportError ( GettextCatalog.GetString ("Solution could not be deployed: "), e );
				return false;
			}
			finally 
			{
				monitor.EndTask ();
			}
			monitor.ReportSuccess (GettextCatalog.GetString ("Solution was successfully deployed."));
			return true;
		}
		public bool GenerateFiles (DeployContext ctx, Solution solution, string defaultConf, IProgressMonitor monitor )
		{
			string filesString = generateAutotools ? "Autotools files" : "Makefiles";
			monitor.BeginTask ( GettextCatalog.GetString ("Generating {0} for Solution {1}", filesString, solution.Name), 1 );

			try
			{
				solution_dir = Path.GetDirectoryName(solution.FileName);

				string[] configs = new string [ solution.Configurations.Count ];
				for (int ii=0; ii < configs.Length; ii++ )
					configs [ii] = solution.Configurations[ii].Id;
					
				MakefileType mt = generateAutotools ? MakefileType.AutotoolsMakefile : MakefileType.SimpleMakefile;
				
				context = new AutotoolsContext ( ctx, solution_dir, configs, mt );
				context.TargetSolution = solution;
				context.Switches = switchs;
				
				IMakefileHandler handler = AutotoolsContext.GetMakefileHandler (solution.RootFolder, mt);
				if (handler == null)
					throw new Exception (string.Format (
						"{0} does not currently support generating {1} for one (or more) child projects.",
						filesString, BrandingService.ApplicationName
					));

				solution_name = solution.Name;
				solution_version = AutotoolsContext.EscapeStringForAutoconf (solution.Version, true);
				if (string.IsNullOrEmpty (solution_version))
					solution_version = "0.1";

				Makefile makefile = handler.Deploy ( context, solution.RootFolder, monitor );
				string path = Path.Combine (solution_dir, "Makefile");
				if (generateAutotools) {
					context.AddAutoconfFile (path);
					CreateAutoGenDotSH (context, monitor);
					CreateConfigureDotAC (solution, defaultConf, monitor, context);
					CreateMacros ();
				} else {
					CreateConfigureScript (solution, defaultConf, context, monitor);

					monitor.Log.WriteLine ( GettextCatalog.GetString ("Creating rules.make"));
					string rules_make_path = Path.Combine (solution_dir, "rules.make");
					File.Copy (Path.Combine (context.TemplateDir, "rules.make"), rules_make_path, true);
					context.AddGeneratedFile (rules_make_path);
				}

				CreateMakefileInclude ( context, monitor );
				AddTopLevelMakefileVars ( makefile, monitor );

				if (generateAutotools)
					path = path + ".am";
				StreamWriter writer = new StreamWriter (path);
				makefile.Write ( writer );
				writer.Close ();

				context.AddGeneratedFile (path);

				monitor.ReportSuccess ( GettextCatalog.GetString ("{0} were successfully generated.", filesString ) );
				monitor.Step (1);
			}
			catch ( Exception e )
			{
				monitor.ReportError ( GettextCatalog.GetString ("{0} could not be generated: ", filesString ), e );
				LoggingService.LogError (GettextCatalog.GetString ("{0} could not be generated: ", filesString ), e);
				DeleteGeneratedFiles ( context );
				return false;
			}
			finally
			{
				monitor.EndTask ();
			}
			return true;
		}
예제 #41
0
		protected override string OnResolveDirectory (DeployContext ctx, string folderId)
		{
			/*string prefix_var = generateAutotools ? "@prefix@" : "$(prefix)";
			string package_var = generateAutotools ? "@PACKAGE@" : "$(PACKAGE)";*/
			//FIXME: Temp till we find a proper solution
			string prefix_var = "@prefix@";
	  		string package_var = "@PACKAGE@";

			switch (folderId) {
			case TargetDirectory.ProgramFilesRoot:
				return "@expanded_libdir@";
			case TargetDirectory.ProgramFiles:
				return "@expanded_libdir@/" + package_var;
			case TargetDirectory.Binaries:
				return "@expanded_bindir@";
			case TargetDirectory.CommonApplicationDataRoot:
				return "@expanded_datadir@";
			case TargetDirectory.CommonApplicationData:
				return "@expanded_datadir@/" + package_var;
			case TargetDirectory.IncludeRoot:
				return prefix_var + "/include";
			case TargetDirectory.Include:
				return prefix_var + "/include/" + package_var;
			}
			return null;
		}
예제 #42
0
 public virtual DeployFileCollection GetDeployFiles(DeployContext ctx, ConfigurationSelector configuration)
 {
     return(DeployService.GetDeployFiles(ctx, GetAllEntries(), configuration));
 }
예제 #43
0
 internal static string GetDeployDirectory(DeployContext ctx, string folderId)
 {
     return(GetExtensionChain().ResolveDirectory(ctx, folderId));
 }
        public override DeployFileCollection GetProjectDeployFiles(DeployContext ctx, Project project, ConfigurationSelector configuration)
        {
            var deployFiles = new DeployFileCollection();

            base.GetProjectDeployFiles(ctx, project, configuration);

            // Add the compiled output files

            var pconf   = (ProjectConfiguration)project.GetConfiguration(configuration);
            var evalCtx = new TargetEvaluationContext();

            evalCtx.ItemsToEvaluate.Add("AllPublishItemsFullPathWithTargetPath");

            if (project.MSBuildProject.UseMSBuildEngine)
            {
                var result = project.RunTarget(new ProgressMonitor(), "GetCopyToPublishDirectoryItems", configuration, evalCtx).Result;
                foreach (var item in result.Items)
                {
                    if (item.Name == "AllPublishItemsFullPathWithTargetPath")
                    {
                        var fromPath = MSBuildProjectService.FromMSBuildPath(project.ItemDirectory, item.Include);
                        var toPath   = item.Metadata.GetPathValue("TargetPath", relativeToPath: pconf.OutputDirectory);
                        deployFiles.Add(new DeployFile(project, fromPath, toPath, TargetDirectory.ProgramFiles));
                    }
                }
            }
            else
            {
#pragma warning disable 618 //obsolete
                FilePath outDir = pconf.OutputDirectory;
                foreach (FilePath file in project.GetOutputFiles(configuration))
                {
                    deployFiles.Add(new DeployFile(project, file, file.ToRelative(outDir), TargetDirectory.ProgramFiles));
                }
                foreach (FileCopySet.Item item in project.GetSupportFileList(configuration))
                {
                    deployFiles.Add(new DeployFile(project, item.Src, item.Target, TargetDirectory.ProgramFiles));
                }
#pragma warning restore 618
            }

            // Collect deployable files
            foreach (ProjectFile file in project.Files)
            {
                // skip CopyToOutputDirectory files when it's just a project build, because
                // MonoDevelop.Project.Projects already copies these files using more subtle overwriting
                // semantics
                if (file.CopyToOutputDirectory != FileCopyMode.None)
                {
                    continue;
                }

                var props = new DeployProperties(file);
                if (props.ShouldDeploy)
                {
                    var dp = new DeployFile(file);
                    deployFiles.Add(dp);
                }
            }

            return(deployFiles);
        }
예제 #45
0
 internal void CopyFiles(IProgressMonitor monitor, IFileReplacePolicy replacePolicy, FileCopyConfiguration copyConfig, DeployFileCollection files, DeployContext context)
 {
     handler.CopyFiles(monitor, replacePolicy, copyConfig, files, context);
 }
예제 #46
0
		internal static void GenerateMakefiles (SolutionItem entry, Solution solution)
		{
			if (solution == null) {
				AlertButton generateMakefilesButton = new AlertButton (GettextCatalog.GetString ("_Generate Makefiles"));
				if (MessageService.AskQuestion (GettextCatalog.GetString ("Generating Makefiles is not supported for single projects. Do you want to generate them for the full solution - '{0}' ?", entry.ParentSolution.Name),
				                                AlertButton.Cancel,
				                                generateMakefilesButton) == generateMakefilesButton) 
					solution = ((SolutionItem)entry).ParentSolution;
				else
					return;
			}

			DeployContext ctx = null;
			IProgressMonitor monitor = null;

			GenerateMakefilesDialog dialog = new GenerateMakefilesDialog (solution);
			try {
				if (MessageService.RunCustomDialog (dialog) != (int) Gtk.ResponseType.Ok)
					return;

				SolutionDeployer deployer = new SolutionDeployer (dialog.GenerateAutotools);
				if ( deployer.HasGeneratedFiles ( solution ) )
				{
					string msg = GettextCatalog.GetString ( "{0} already exist for this solution.  Would you like to overwrite them?", dialog.GenerateAutotools ? "Autotools files" : "Makefiles" );
					if (MonoDevelop.Ide.MessageService.AskQuestion (msg, AlertButton.Cancel, AlertButton.OverwriteFile) != AlertButton.OverwriteFile)
						return;
				}

				ctx = new DeployContext (new TarballDeployTarget (dialog.GenerateAutotools), "Linux", null);
				monitor = IdeApp.Workbench.ProgressMonitors.GetToolOutputProgressMonitor (true);
				deployer.GenerateFiles (ctx, solution, dialog.DefaultConfiguration, monitor);
			} finally {
				dialog.Destroy ();
				if (ctx != null)
					ctx.Dispose ();
				if (monitor != null)
					monitor.Dispose ();
			}
		}
예제 #47
0
		public int Run (string [] arguments)
		{
			Console.WriteLine ("MonoDevelop Makefile generator");
			if (arguments.Length == 0) {
				ShowUsage ();
				return 0;
			}

			// Parse arguments
			foreach (string s in arguments) {
				if (s == "--simple-makefiles" || s == "-s") {
					generateAutotools = false;
				} else if (s.StartsWith ("-d:")) {
					if (s.Length > 3)
						defaultConfig = s.Substring (3);
				} else if (s [0] == '-') {
					Console.WriteLine (GettextCatalog.GetString ("Error: Unknown option {0}", s));
					return 1;
				} else {
					if (filename != null) {
						Console.WriteLine (GettextCatalog.GetString ("Error: Filename already specified - {0}, another filename '{1}' cannot be specified.", filename, s));
						return 1;
					}

					filename = s;
				}
			}

			if (filename == null) {
				Console.WriteLine (GettextCatalog.GetString ("Error: Solution file not specified."));
				ShowUsage ();
				return 1;
			}

			Console.WriteLine (GettextCatalog.GetString ("Loading solution file {0}", filename));
			ConsoleProgressMonitor monitor = new ConsoleProgressMonitor ();
			
			Solution solution = Services.ProjectService.ReadWorkspaceItem (monitor, filename) as Solution;
			if (solution == null) {
				Console.WriteLine (GettextCatalog.GetString ("Error: Makefile generation supported only for solutions.\n"));
				return 1;
			}

			if (defaultConfig == null || !CheckValidConfig (solution, defaultConfig)) {
				Console.WriteLine (GettextCatalog.GetString ("\nInvalid configuration {0}. Valid configurations : ", defaultConfig));
				for (int i = 0; i < solution.Configurations.Count; i ++) {
					SolutionConfiguration cc = (SolutionConfiguration) solution.Configurations [i];
					Console.WriteLine ("\t{0}. {1}", i + 1, cc.Id);
				}

				int configCount = solution.Configurations.Count;
				int op = 0;
				do {
					Console.Write (GettextCatalog.GetString ("Select configuration : "));
					string s = Console.ReadLine ();
					if (s.Length == 0)
						return 1;
					if (int.TryParse (s, out op)) {
						if (op > 0 && op <= configCount)
							break;
					}
				} while (true);

				defaultConfig = solution.Configurations [op - 1].Id;

			}

			SolutionDeployer deployer = new SolutionDeployer (generateAutotools);
			if (deployer.HasGeneratedFiles (solution)) {
				string msg = GettextCatalog.GetString ( "{0} already exist for this solution.  Would you like to overwrite them? (Y/N)",
						generateAutotools ? "Autotools files" : "Makefiles" );
				bool op = false;
				do {
					Console.Write (msg);
					string line = Console.ReadLine ();
					if (line.Length == 0)
						return 1;

					if (line.Length == 1) {
						if (line [0] == 'Y' || line [0] == 'y')
							op = true;
						else if (line [0] == 'N' || line [0] == 'n')
							op = false;
						else
							continue;
					} else {
						if (String.Compare (line, "YES", true) == 0)
							op = true;
						else if (String.Compare (line, "NO", true) == 0)
							op = false;
						else
							continue;
					}
					break;
				} while (true);
				if (!op)
					return 0;
			}

			DeployContext ctx = new DeployContext (new TarballDeployTarget (), "Linux", null);
			try {
				deployer.GenerateFiles (ctx, solution, defaultConfig, monitor);
			}
			finally {
				ctx.Dispose ();
				monitor.Dispose ();
			}

			return 0;
		}
		internal void CopyFiles (ProgressMonitor monitor, IFileReplacePolicy replacePolicy, FileCopyConfiguration copyConfig, DeployFileCollection files, DeployContext context)
		{
			handler.CopyFiles (monitor, replacePolicy, copyConfig, files, context);
		}
예제 #49
0
 protected override bool OnBuild(IProgressMonitor monitor, DeployContext ctx)
 {
     monitor.ReportError("Unknown package type. The package can't be generated.", null);
     return(false);
 }
예제 #50
0
 internal void SetContext(DeployContext deployContext)
 {
     this.deployContext = deployContext;
 }
 public void CopyFiles(IProgressMonitor monitor, IFileReplacePolicy replacePolicy, DeployFileCollection files, DeployContext context)
 {
     Handler.CopyFiles(monitor, replacePolicy, this, files, context);
 }
		protected virtual bool OnBuild (IProgressMonitor monitor, DeployContext ctx)
		{
			return true;
		}
예제 #53
0
		public static DeployFileCollection GetDeployFiles (DeployContext ctx, SolutionFolderItem entry, ConfigurationSelector configuration)
		{
			ArrayList todel = new ArrayList ();
			
			DeployFileCollection col = GetExtensionChain ().GetDeployFiles (ctx, entry, configuration);
			foreach (DeployFile df in col) {
				if (!ctx.IncludeFile (df)) {
					todel.Add (df);
					continue;
				}
				df.SetContext (ctx);
				if (df.ContainsPathReferences) {
					string name = df.DisplayName;
					df.SourcePath = ProcessFileTemplate (ctx, df.SourcePath);
					df.DisplayName = name;
				}
			}
			foreach (DeployFile df in todel) {
				col.Remove (df);
			}
			return col;
		}
		string IDirectoryResolver.GetDirectory (DeployContext ctx, string folderId)
		{
			return OnResolveDirectory (ctx, folderId);
		}
예제 #55
0
		internal static string ProcessFileTemplate (DeployContext ctx, string file)
		{
			TextFile tf = TextFile.ReadFile (file);
			string text = tf.Text;
			StringBuilder sb = new StringBuilder ();
			int lastPos = 0;
			int pos = text.IndexOf ('@');
			while (pos != -1) {
				int ep = text.IndexOf ('@', pos+1);
				if (ep == -1)
					break;
				string tag = text.Substring (pos + 1, ep - pos - 1);
				string dir = ctx.GetDirectory (tag);
				if (dir != null) {
					sb.Append (text, lastPos, pos - lastPos);
					sb.Append (dir);
					lastPos = ep + 1;
				}
				pos = text.IndexOf ('@', ep+1);
			}
			sb.Append (text, lastPos, text.Length - lastPos);
			string tmp = ctx.CreateTempFile ();
			TextFile.WriteFile (tmp, sb.ToString (), tf.SourceEncoding);
			return tmp;
		}
예제 #56
0
 string IDirectoryResolver.GetDirectory(DeployContext ctx, string folderId)
 {
     return(OnResolveDirectory(ctx, folderId));
 }