示例#1
0
        public BasicOptionPanelWidget(Project entry, bool creatingProject)
        {
            this.Build();

            WidgetFlags |= Gtk.WidgetFlags.NoShowAll;

            this.entry = entry;
            if (entry is DotNetProject)
            {
                DotNetProject project = (DotNetProject)entry;
                boxExe.Visible     = (project.CompileTarget == CompileTarget.Exe || project.CompileTarget == CompileTarget.WinExe);
                boxLibrary.Visible = (project.CompileTarget == CompileTarget.Library || project.GetOutputFileName(ConfigurationSelector.Default).FileName.EndsWith(".dll"));
            }
            else
            {
                boxExe.Visible = boxLibrary.Visible = false;
            }

            LinuxDeployData data = LinuxDeployData.GetLinuxDeployData(entry);

            checkScript.Active    = data.GenerateScript;
            entryScript.Text      = data.ScriptName;
            checkPcFile.Active    = data.GeneratePcFile;
            entryScript.Sensitive = checkScript.Active;

            if (!creatingProject)
            {
                checkDesktop.Visible = false;
            }
        }
示例#2
0
        public void Store()
        {
            DotNetProject project = entry as DotNetProject;

            if (project == null)
            {
                return;
            }

            LinuxDeployData data = LinuxDeployData.GetLinuxDeployData(project);

            data.GenerateScript = checkScript.Active;
            data.ScriptName     = entryScript.Text;
            data.GeneratePcFile = checkPcFile.Active;

            if (checkDesktop.Active)
            {
                DesktopEntry de = new DesktopEntry();
                de.SetEntry("Encoding", "UTF-8");
                de.Type     = DesktopEntryType.Application;
                de.Name     = entry.Name;
                de.Exec     = entryScript.Text;
                de.Terminal = false;
                string file = System.IO.Path.Combine(entry.BaseDirectory, "app.desktop");
                de.Save(file);
                ProjectFile      pfile = project.AddFile(file, BuildAction.Content);
                DeployProperties props = DeployService.GetDeployProperties(pfile);
                props.TargetDirectory = LinuxTargetDirectory.DesktopApplications;
            }
        }
        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);
        }
 void OnFileAdded(object o, ProjectFileEventArgs args)
 {
     foreach (ProjectFileEventInfo a in args)
     {
         if (a.ProjectFile.Name.EndsWith(".desktop"))
         {
             DesktopEntry de = new DesktopEntry();
             try {
                 de.Load(a.ProjectFile.Name);
                 a.ProjectFile.BuildAction = BuildAction.Content;
                 DeployProperties props = DeployService.GetDeployProperties(a.ProjectFile);
                 props.TargetDirectory = LinuxTargetDirectory.DesktopApplications;
                 if (string.IsNullOrEmpty(de.Exec))
                 {
                     LinuxDeployData dd = LinuxDeployData.GetLinuxDeployData(a.Project);
                     if (dd.GenerateScript && !string.IsNullOrEmpty(dd.ScriptName))
                     {
                         de.Exec = dd.ScriptName;
                         de.Save(a.ProjectFile.Name);
                     }
                 }
             } catch (Exception ex) {
                 LoggingService.LogError("Could not read .desktop file", ex);
             }
         }
     }
 }
        public static LinuxDeployData GetLinuxDeployData(SolutionItem entry)
        {
            LinuxDeployData data = (LinuxDeployData)entry.ExtendedProperties ["Deployment.LinuxDeployData"];

            if (data != null)
            {
                if (data.entry == null)
                {
                    data.Bind(entry);
                    data.connected = true;
                }
                return(data);
            }

            data = (LinuxDeployData)entry.ExtendedProperties ["Temp.Deployment.LinuxDeployData"];
            if (data != null)
            {
                return(data);
            }

            data = CreateDefault(entry);
            entry.ExtendedProperties ["Temp.Deployment.LinuxDeployData"] = data;
            data.Bind(entry);
            return(data);
        }
        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);
        }
		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;
		}
		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;
		}
示例#9
0
        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);
        }
示例#10
0
        public static LinuxDeployData GetLinuxDeployData(Project entry)
        {
            LinuxDeployData data = (LinuxDeployData)entry.ExtendedProperties ["Deployment.LinuxDeployData"];

            if (data != null)
            {
                return(data);
            }

            var elem = entry.MSBuildProject.GetMonoDevelopProjectExtension("Deployment.LinuxDeployData");

            if (elem != null)
            {
                XmlDataSerializer ser = new XmlDataSerializer(new DataContext());
                data = (LinuxDeployData)ser.Deserialize(new XmlNodeReader(elem), typeof(LinuxDeployData));
            }
            else
            {
                data = CreateDefault(entry);
            }
            data.entry = entry;
            entry.ExtendedProperties ["Deployment.LinuxDeployData"] = data;
            return(data);
        }