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; } }
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); } } } }
void Run() { var eventPublisher = new EventPublisher(); var connection = new Mock <IEnvironmentConnection>(); connection.Setup(e => e.ServerEvents).Returns(eventPublisher); connection.Setup(e => e.ExecuteCommand(It.IsAny <StringBuilder>(), It.IsAny <Guid>())).Returns(new StringBuilder()); var envMock = new Mock <IServer>(); envMock.Setup(e => e.Connection).Returns(connection.Object); envMock.Setup(e => e.ResourceRepository.DeployResource(It.IsAny <IResourceModel>(), It.IsAny <string>())).Verifiable(); envMock.Setup(e => e.ResourceRepository.SaveTests(It.IsAny <IResourceModel>(), It.IsAny <List <IServiceTestModelTO> >())).Verifiable(); envMock.Setup(e => e.IsConnected).Returns(true); var sourceMock = new Mock <IServer>(); sourceMock.Setup(e => e.Connection).Returns(connection.Object); sourceMock.Setup(e => e.ResourceRepository.LoadResourceTestsForDeploy(It.IsAny <Guid>())).Returns(new List <IServiceTestModelTO>()).Verifiable(); sourceMock.Setup(e => e.IsConnected).Returns(true); var dtoMock = new Mock <IDeployDto>(); dtoMock.Setup(d => d.ResourceModels).Returns(CreateModels(envMock.Object)); var ds = new DeployService(); ds.Deploy(dtoMock.Object, sourceMock.Object, envMock.Object); envMock.Verify(e => e.ResourceRepository.DeployResource(It.IsAny <IResourceModel>(), It.IsAny <string>()), Times.Exactly(_numModels)); }
static IAsyncOperation BuildPackages(ICollection packages) { IProgressMonitor mon = IdeApp.Workbench.ProgressMonitors.GetToolOutputProgressMonitor(true); // Run the deploy command in a background thread to avoid // deadlocks with the gui thread System.Threading.Thread t = new System.Threading.Thread( delegate() { using (mon) { mon.BeginTask("Creating packages", packages.Count); foreach (Package p in packages) { DeployService.BuildPackage(mon, p); mon.Step(1); } mon.EndTask(); } }); t.IsBackground = true; t.Start(); return(mon.AsyncOperation); }
public override PackageBuilder[] CreateDefaultBuilders() { List <PackageBuilder> list = new List <PackageBuilder> (); foreach (FileFormat format in Services.ProjectService.FileFormats.GetFileFormatsForObject(RootSolutionItem)) { SourcesZipPackageBuilder pb = (SourcesZipPackageBuilder)Clone(); pb.FileFormat = format; // The suffix for the archive will be the extension of the file format. // If there is no extension, use the whole file name. string fname = format.GetValidFileName(RootSolutionItem, RootSolutionItem.ParentSolution.FileName); string suffix = Path.GetExtension(fname); if (suffix.Length > 0) { suffix = suffix.Substring(1).ToLower(); // Remove the initial dot } else { suffix = Path.GetFileNameWithoutExtension(suffix).ToLower(); } // Change the name in the target file string ext = DeployService.GetArchiveExtension(pb.TargetFile); string fn = TargetFile.Substring(0, TargetFile.Length - ext.Length); pb.TargetFile = fn + "-" + suffix + ext; list.Add(pb); } return(list.ToArray()); }
internal static string ImportFile(Project prj, string file) { ProjectFile pfile = prj.Files.GetFile(file); if (pfile == null) { var files = IdeApp.ProjectOperations.AddFilesToProject(prj, new string[] { file }, prj.BaseDirectory); if (files.Count == 0 || files[0] == null) { return(null); } pfile = files [0]; } if (pfile.BuildAction == BuildAction.EmbeddedResource) { AlertButton embedButton = new AlertButton(GettextCatalog.GetString("_Use as Source")); if (MessageService.AskQuestion(GettextCatalog.GetString("You are requesting the file '{0}' to be used as source for an image. However, this file is already added to the project as a resource. Are you sure you want to continue (the file will have to be removed from the resource list)?"), AlertButton.Cancel, embedButton) == embedButton) { return(null); } } pfile.BuildAction = BuildAction.Content; DeployProperties props = DeployService.GetDeployProperties(pfile); props.UseProjectRelativePath = true; return(pfile.FilePath); }
protected override bool OnBuild(ProgressMonitor monitor, DeployContext ctx) { string sourceFile; SolutionFolderItem entry = RootSolutionItem; if (entry is SolutionFolder) { sourceFile = entry.ParentSolution.FileName; } else { sourceFile = ((SolutionItem)entry).FileName; } AggregatedProgressMonitor mon = new AggregatedProgressMonitor(); mon.AddSlaveMonitor(monitor, MonitorAction.WriteLog | MonitorAction.ReportError | MonitorAction.ReportWarning | MonitorAction.ReportSuccess); string tmpFolder = FileService.CreateTempDirectory(); try { string tf = Path.GetFileNameWithoutExtension(targetFile); if (tf.EndsWith(".tar")) { tf = Path.GetFileNameWithoutExtension(tf); } string folder = FileService.GetFullPath(Path.Combine(tmpFolder, tf)); Directory.CreateDirectory(folder); // Export the project SolutionFolderItem[] ents = GetChildEntries(); string[] epaths = new string [ents.Length]; for (int n = 0; n < ents.Length; n++) { epaths [n] = ents [n].ItemId; } var r = Services.ProjectService.Export(mon, sourceFile, epaths, folder, FileFormat).Result; if (string.IsNullOrEmpty(r)) { return(false); } // Create the archive string td = Path.GetDirectoryName(targetFile); if (!Directory.Exists(td)) { Directory.CreateDirectory(td); } DeployService.CreateArchive(mon, tmpFolder, targetFile); } finally { Directory.Delete(tmpFolder, true); } monitor.Log.WriteLine(GettextCatalog.GetString("Created file: {0}", targetFile)); return(true); }
public void IfDeployThrowsExShouldBeHandled(DeployMode mode) { var cFactory = DefaultMocks.GetConfFactory(); var validator = new Mock <IValidator>(); validator.Setup(v => v.IsValidForInstall()).Returns(true); validator.Setup(v => v.IsValidForUpdate()).Returns(true); var correctDeployers = DefaultMocks.GetMockedDeployers(3).ToList(); var deployersWithEx = correctDeployers.ToList(); var deployerWithEx = new Mock <IDeployer>(); deployerWithEx.Setup(d => d.Name).Returns(string.Format("deployer-{0}", 4)); deployerWithEx.Setup(d => d.Install()).Throws(new DeployException("deploy ex install")); deployerWithEx.Setup(d => d.Update()).Throws(new DeployException("deploy ex update")); deployersWithEx.Add(deployerWithEx); var settingsMock = new Mock <IConf>(); settingsMock.Setup(s => s.SurveyPath).Returns(new SurveyPaths(_surveyPath, null)); settingsMock.Setup(s => s.Survey).Returns(new Survey(null, null, mode)); settingsMock.Setup(s => s.PackageManager).Returns(new PackageManagerStub()); var dsFactory = DefaultMocks.GetServiceFactory(mode); dsFactory.Setup(f => f.CreateDeployExHandlerObj(It.IsAny <IDeployEvents>(), It.IsAny <IConf>(), It.IsAny <IServiceLogger>(), It.IsAny <ISession>())) .Returns(new DeployExceptionHandlerStub()); dsFactory.Setup(f => f.CreateValidatorsList(It.IsAny <IConf>())).Returns(new List <IValidator> { validator.Object }); dsFactory.Setup(f => f.CreateDeployersList(It.IsAny <IConf>())).Returns(deployersWithEx.Select(d => d.Object)); using (var service = new DeployService(dsFactory.Object, cFactory.Object)) ConsumeService(service, mode); if (mode == DeployMode.Install) { validator.Verify(v => v.IsValidForInstall(), Times.Once()); } else { validator.Verify(v => v.IsValidForUpdate(), Times.Once()); } foreach (var deployer in correctDeployers) { if (mode == DeployMode.Install) { deployer.Verify(d => d.Install(), Times.Once()); deployer.Verify(d => d.InstallRollback(), Times.Once()); } else { deployer.Verify(d => d.Update(), Times.Once()); deployer.Verify(d => d.UpdateRollback(), Times.Once()); } } }
public void ServiceShouldDemandOpenSessionMethod() { var dsFacory = DefaultMocks.GetServiceFactory(); var service = new DeployService(dsFacory.Object, null); Assert.Throws <AuthenticationException>(() => service.Deploy(GetDeployContext(DeployMode.Install), new byte[10])); }
public BinariesZipEditorWidget(BinariesZipPackageBuilder builder) { this.Build(); this.builder = builder; loading = true; int pel = 0; platforms = DeployService.GetDeployPlatformInfo(); for (int n = 0; n < platforms.Length; n++) { comboPlatform.AppendText(platforms[n].Description); if (platforms[n].Id == builder.Platform) { pel = n; } } comboPlatform.Active = pel; builder.Platform = platforms [pel].Id; string[] archiveFormats = DeployService.SupportedArchiveFormats; int zel = 1; for (int n = 0; n < archiveFormats.Length; n++) { comboZip.AppendText(archiveFormats [n]); if (builder.TargetFile.EndsWith(archiveFormats [n])) { zel = n; } } if (!string.IsNullOrEmpty(builder.TargetFile)) { string ext = archiveFormats [zel]; folderEntry.Path = System.IO.Path.GetDirectoryName(builder.TargetFile); entryZip.Text = System.IO.Path.GetFileName(builder.TargetFile.Substring(0, builder.TargetFile.Length - ext.Length)); comboZip.Active = zel; } // Fill configurations zel = 0; foreach (string conf in builder.RootSolutionItem.ParentSolution.GetConfigurations()) { comboConfiguration.AppendText(conf); if (conf == builder.Configuration) { comboConfiguration.Active = zel; } zel++; } loading = false; }
public void ServiceShouldLockUsedFolders() { var dsFactory = DefaultMocks.GetServiceFactory(); using (var service1 = new DeployService(dsFactory.Object, null)) using (var service2 = new DeployService(dsFactory.Object, null)) { Assert.True(service1.OpenSession(_surveyName)); Assert.False(service2.OpenSession(_surveyName)); } }
public void CallDeployWithoutFilesWillFail() { var dsFactory = DefaultMocks.GetServiceFactory(); var cFactory = DefaultMocks.GetConfFactory(); Assert.Throws <InvalidOperationException>(() => { using (var service = new DeployService(dsFactory.Object, cFactory.Object)) { service.OpenSession(_surveyName); service.Deploy(GetDeployContext(), new byte[0]); } }); }
public FileCopyConfigurationSelector() { this.Build(); loading = true; handlers = DeployService.GetFileCopyHandlers(); foreach (FileCopyHandler handler in handlers) { comboHandlers.AppendText(handler.Name); } loading = false; comboHandlers.Active = 0; }
public static void Install(SolutionItem entry, ConfigurationSelector configuration) { using (IProgressMonitor mon = IdeApp.Workbench.ProgressMonitors.GetRunProgressMonitor()) { InstallDialog dlg = new InstallDialog(entry); try { if (MessageService.RunCustomDialog(dlg) == (int)Gtk.ResponseType.Ok) { DeployService.Install(mon, entry, dlg.Prefix, dlg.AppName, configuration); } } finally { dlg.Destroy(); } } }
static void Main(string[] args) { var entity = new DeployEntity(); entity.AppId = 100; entity.DeployCode = "100"; entity.DeployPackage = "100"; entity.DeployContent = "100"; entity.UploadUserId = 100; entity.UploadTime = DateTime.Now; entity.DeployType = 100; var service = new DeployService(); //插入 service.Insert(entity); //查询所有 var allList = service.GetAll <DeployEntity>(); //多条件查询 var pgMain = new PredicateGroup { Operator = GroupOperator.Or, Predicates = new List <IPredicate>() }; var pga = new PredicateGroup() { Operator = GroupOperator.And, Predicates = new List <IPredicate>() }; pga.Predicates.Add(Predicates.Field <DeployEntity>(f => f.DeployCode, Operator.Eq, "100")); pga.Predicates.Add(Predicates.Field <DeployEntity>(f => f.ID, Operator.Ge, 47)); pga.Predicates.Add(Predicates.Field <DeployEntity>(f => f.ID, Operator.Le, 48)); pgMain.Predicates.Add(pga); var pgb = new PredicateGroup() { Operator = GroupOperator.And, Predicates = new List <IPredicate>() }; pgb.Predicates.Add(Predicates.Field <DeployEntity>(f => f.DeployCode, Operator.Eq, "10000")); pgMain.Predicates.Add(pgb); var specialList = service.GetList <DeployEntity>(pgMain).ToList(); //分页查询 long allRowsCount = 0; var pageList = service.GetPageList <DeployEntity>(1, 2, out allRowsCount); }
public override PackageBuilder[] CreateDefaultBuilders() { List <PackageBuilder> list = new List <PackageBuilder> (); foreach (DeployPlatformInfo plat in DeployService.GetDeployPlatformInfo()) { BinariesZipPackageBuilder pb = (BinariesZipPackageBuilder)Clone(); pb.Platform = plat.Id; string ext = DeployService.GetArchiveExtension(pb.TargetFile); string fn = TargetFile.Substring(0, TargetFile.Length - ext.Length); pb.TargetFile = fn + "-" + plat.Id.ToLower() + ext; list.Add(pb); } return(list.ToArray()); }
public void OnApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext) { //Comment this out to control this setting via web.config compilation debug attribute BundleTable.EnableOptimizations = true; RegisterJavaScript(BundleTable.Bundles); RegisterStyles(BundleTable.Bundles); // Generate access.config var accessService = new NodeAccessService(); accessService.GenerateConfigFile(); // Prepare DB with new updates var deployService = new DeployService(); deployService.Install(); }
public void DeployService_GivenTrue_ShouldDeployResourcesAndTestsAndTriggers() { //---------------Set up test pack------------------- var eventPublisher = new EventPublisher(); var connection = new Mock <IEnvironmentConnection>(); connection.Setup(e => e.ServerEvents).Returns(eventPublisher); connection.Setup(e => e.ExecuteCommand(It.IsAny <StringBuilder>(), It.IsAny <Guid>())).Returns(new StringBuilder()); var envMock = new Mock <IServer>(); envMock.Setup(e => e.Connection).Returns(connection.Object); envMock.Setup(e => e.ResourceRepository.DeployResource(It.IsAny <IResourceModel>(), It.IsAny <string>())).Verifiable(); envMock.Setup(e => e.ResourceRepository.SaveTests(It.IsAny <IResourceModel>(), It.IsAny <List <IServiceTestModelTO> >())).Verifiable(); envMock.Setup(e => e.ResourceRepository.SaveQueue(It.IsAny <ITriggerQueue>())).Verifiable(); envMock.Setup(e => e.IsConnected).Returns(true); var sourceMock = new Mock <IServer>(); sourceMock.Setup(e => e.Connection).Returns(connection.Object); sourceMock.Setup(e => e.ResourceRepository.LoadResourceTestsForDeploy(It.IsAny <Guid>())).Returns(new List <IServiceTestModelTO>()).Verifiable(); var triggerQueues = new List <ITriggerQueue> { new TriggerQueue { QueueName = "Queue 1" } }; sourceMock.Setup(e => e.ResourceRepository.LoadResourceTriggersForDeploy(It.IsAny <Guid>())).Returns(triggerQueues).Verifiable(); sourceMock.Setup(e => e.IsConnected).Returns(true); var dtoMock = new Mock <IDeployDto>(); dtoMock.Setup(d => d.ResourceModels).Returns(CreateModels(envMock.Object)); dtoMock.Setup(d => d.DeployTests).Returns(true); dtoMock.Setup(d => d.DeployTriggers).Returns(true); //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- var ds = new DeployService(); ds.Deploy(dtoMock.Object, sourceMock.Object, envMock.Object); //---------------Test Result ----------------------- sourceMock.Verify(e => e.ResourceRepository.LoadResourceTestsForDeploy(It.IsAny <Guid>()), Times.AtLeastOnce); envMock.Verify(e => e.ResourceRepository.SaveTests(It.IsAny <IResourceModel>(), It.IsAny <List <IServiceTestModelTO> >()), Times.AtLeastOnce); envMock.Verify(e => e.ResourceRepository.DeployResource(It.IsAny <IResourceModel>(), It.IsAny <string>()), Times.AtLeastOnce); sourceMock.Verify(e => e.ResourceRepository.LoadResourceTriggersForDeploy(It.IsAny <Guid>()), Times.AtLeastOnce); envMock.Verify(e => e.ResourceRepository.SaveQueue(It.IsAny <ITriggerQueue>()), Times.AtLeastOnce); }
public void IfValidationFailedHadleExAndDontCallDeployers(DeployMode mode) { var cFactory = DefaultMocks.GetConfFactory(); var validator = new Mock <IValidator>(); validator.Setup(v => v.IsValidForInstall()).Returns(false); validator.Setup(v => v.IsValidForUpdate()).Returns(false); var deployer = new Mock <IDeployer>(); deployer.Setup(d => d.Install()); deployer.Setup(d => d.Update()); var exceptionHandler = new Mock <IDeployExceptionHandler>(); exceptionHandler.Setup(e => e.HandleValidation(It.IsAny <ValidationException>(), It.IsAny <IDeployEvents>())); var dsFactory = DefaultMocks.GetServiceFactory(mode); dsFactory.Setup(f => f.CreateDeployExHandlerObj(It.IsAny <IDeployEvents>(), It.IsAny <IConf>(), It.IsAny <IServiceLogger>(), It.IsAny <ISession>())) .Returns(exceptionHandler.Object); dsFactory.Setup(f => f.CreateValidatorsList(It.IsAny <IConf>())).Returns(new List <IValidator> { validator.Object }); dsFactory.Setup(f => f.CreateDeployersList(It.IsAny <IConf>())).Returns(new List <IDeployer> { deployer.Object }); using (var service = new DeployService(dsFactory.Object, cFactory.Object)) ConsumeService(service, mode); if (mode == DeployMode.Install) { validator.Verify(v => v.IsValidForInstall(), Times.Once()); } else { validator.Verify(v => v.IsValidForUpdate(), Times.Once()); } deployer.Verify(d => d.Install(), Times.Never()); deployer.Verify(d => d.Update(), Times.Never()); exceptionHandler.Verify(e => e.HandleValidation(It.IsAny <ValidationException>(), It.IsAny <IDeployEvents>()), Times.Once()); }
static async Task BuildPackages(ICollection packages) { ProgressMonitor mon = IdeApp.Workbench.ProgressMonitors.GetToolOutputProgressMonitor(true); // Run the deploy command in a background thread to avoid // deadlocks with the gui thread using (mon) { mon.BeginTask("Creating packages", packages.Count); foreach (Package p in packages) { await DeployService.BuildPackage(mon, p); mon.Step(1); } mon.EndTask(); } }
void FillBuilders() { builders.Clear(); foreach (PackageBuilder builder in DeployService.GetPackageBuilders()) { builders.Add(builder); } store.Clear(); foreach (PackageBuilder builder in builders) { Gdk.Pixbuf pix = ImageService.GetPixbuf(builder.Icon, Gtk.IconSize.LargeToolbar); store.AppendValues(pix, builder.Description, builder); } if (builders.Count > 0) { SelectBuilder(builders[0]); } }
public static void Main(string[] args) { //设置读取指定位置的nlog.config文件 if (RuntimeEnvironment.IsWindows) { NLogBuilder.ConfigureNLog("nlog-windows.config"); } else { NLogBuilder.ConfigureNLog("nlog-linux.config"); } var host = CreateHostBuilder(args).Build(); var map = GetArgsMap(args); DeployService deployService = new DeployService(host); if (map.Keys.Contains("m")) { var cmd = map["m"]; switch (cmd) { case "GenSecret": //deployService.InitSecret(); return; case "MigrateDatabase": deployService.MigrateDatabase(); return; default: Console.WriteLine("unkown cmd"); return; } } host.Run(); }
public void IfFilesTransferWasCorruptedDeployThrows() { var dsFactory = DefaultMocks.GetServiceFactory(); var cFactory = DefaultMocks.GetConfFactory(); Assert.Throws <ArgumentException>(() => { using (var service = new DeployService(dsFactory.Object, cFactory.Object)) { service.OpenSession(_surveyName); foreach (var chunk in _files.Chunks) { service.SendFilesChunk(chunk); } var spoiledFiles = new byte[_files.Bytes.Length]; Array.Copy(_files.Bytes, spoiledFiles, _files.Bytes.Length); spoiledFiles[100] = 0; service.Deploy(GetDeployContext(), MD5.Create().ComputeHash(spoiledFiles)); } }); }
public void ServiceShouldCallAllValidatorsAndDeployers(DeployMode mode) { var cFactory = DefaultMocks.GetConfFactory(); var validators = DefaultMocks.GetMockedValidators(3).ToList(); var deployers = DefaultMocks.GetMockedDeployers(3).ToList(); var dsFactory = DefaultMocks.GetServiceFactory(mode); dsFactory.Setup(f => f.CreateValidatorsList(It.IsAny <IConf>())).Returns(validators.Select(v => v.Object)); dsFactory.Setup(f => f.CreateDeployersList(It.IsAny <IConf>())).Returns(deployers.Select(v => v.Object)); using (var service = new DeployService(dsFactory.Object, cFactory.Object)) ConsumeService(service, mode); foreach (var validator in validators) { if (mode == DeployMode.Install) { validator.Verify(v => v.IsValidForInstall(), Times.Once()); } else { validator.Verify(v => v.IsValidForUpdate(), Times.Once()); } } foreach (var deployer in deployers) { if (mode == DeployMode.Install) { deployer.Verify(d => d.Install(), Times.Once()); } else { deployer.Verify(d => d.Update(), Times.Once()); } } }
void AddCreatePackageSection(Gtk.VBox vbox, string label, PackagingProject parentProject, bool showCheck) { Gtk.VBox vboxNewPacks; Gtk.Widget hbox; if (showCheck) { Gtk.CheckButton check = new Gtk.CheckButton(label); check.Show(); vbox.PackStart(check, false, false, 0); AddBox(vbox, out hbox, out vboxNewPacks); check.Toggled += delegate { hbox.Visible = check.Active; if (!check.Active) { DisableChecks(hbox); } }; } else { Gtk.Label lab = new Gtk.Label(label); lab.Show(); vbox.PackStart(lab, false, false, 0); AddBox(vbox, out hbox, out vboxNewPacks); hbox.Show(); } ICollection builders; if (creatingPackProject) { builders = DeployService.GetPackageBuilders(); } else { builders = DeployService.GetSupportedPackageBuilders(entry); } foreach (PackageBuilder pb in builders) { if (creatingPackProject) { pb.SetSolutionItem(parentFolder.ParentSolution.RootFolder); // Add all compatible projects foreach (SolutionItem e in parentFolder.ParentSolution.GetAllSolutionItems()) { if (pb.CanBuild(e)) { pb.AddEntry(e); } } } else { pb.SetSolutionItem(parentFolder, new SolutionItem [] { entry }); } PackageBuilder[] defp = pb.CreateDefaultBuilders(); if (defp.Length == 0) { continue; } if (defp.Length == 1) { AddPackageBuilder(vboxNewPacks, parentProject, defp[0]); } else { Gtk.CheckButton checkBuilder = new Gtk.CheckButton(pb.Description); checkBuilder.Show(); vboxNewPacks.PackStart(checkBuilder, false, false, 0); Gtk.VBox vboxDefPacks; Gtk.Widget thbox; AddBox(vboxNewPacks, out thbox, out vboxDefPacks); checkBuilder.Toggled += delegate { thbox.Visible = checkBuilder.Active; if (!checkBuilder.Active) { DisableChecks(thbox); } }; foreach (PackageBuilder dp in defp) { AddPackageBuilder(vboxDefPacks, parentProject, dp); } } } }
public ProjectFileWrapper(ProjectFile file) { props = DeployService.GetDeployProperties(file); this.file = file; }
public Microsoft.Extensions.Configuration.IConfigurationProvider Build(IConfigurationBuilder builder) { IDeployService deployService = new DeployService(_connectionString); return(new ConfigDbProvider(_optionsAction, deployService)); }
public Makefile Deploy(AutotoolsContext ctx, SolutionFolderItem entry, ProgressMonitor monitor) { generateAutotools = ctx.MakefileType == MakefileType.AutotoolsMakefile; monitor.BeginTask(GettextCatalog.GetString( "Creating {0} for Project {1}", generateAutotools ? "Makefile.am" : "Makefile", entry.Name), 1); Makefile makefile = new Makefile(); try { if (!CanDeploy(entry, generateAutotools ? MakefileType.AutotoolsMakefile : MakefileType.SimpleMakefile)) { throw new Exception(GettextCatalog.GetString("Not a deployable project.")); } Project project = entry as Project; TemplateEngine templateEngine = new TemplateEngine(); ISimpleAutotoolsSetup setup = FindSetupForProject(project); // Handle files to be deployed deployDirs = new Dictionary <string, StringBuilder> (); deployFileVars = new Dictionary <string, string> (); builtFiles = new List <string> (); deployFileCopyVars = new StringBuilder(); deployFileCopyTargets = new StringBuilder(); //used only for simple makefile generation templateFilesTargets = null; installTarget = null; installDeps = null; installDirs = null; uninstallTarget = null; // handle configuration specific variables conf_vars = new StringBuilder(); // grab all project files files = new StringBuilder(); res_files = new StringBuilder(); extras = new StringBuilder(); datafiles = new StringBuilder(); Set <string> extraFiles = new Set <string> (); string includes = String.Empty; string references, dllReferences; DotNetProject netProject = project as DotNetProject; ProcessProjectReferences(netProject, out references, out dllReferences, ctx); templateEngine.Variables["REFERENCES"] = references; templateEngine.Variables["DLL_REFERENCES"] = dllReferences; templateEngine.Variables["WARNING"] = "Warning: This is an automatically generated file, do not edit!"; if (entry is DotNetProject dotnetProject) { templateEngine.Variables ["RESGEN"] = "resgen"; } string pfpath = null; foreach (ProjectFile projectFile in project.Files) { pfpath = FileService.NormalizeRelativePath(projectFile.FilePath.ToRelative(project.BaseDirectory)); switch (projectFile.BuildAction) { case BuildAction.Compile: if (projectFile.Subtype != Subtype.Code) { continue; } files.AppendFormat("\\\n\t{0} ", MakefileData.ToMakefilePath(pfpath)); break; case BuildAction.Content: case BuildAction.None: extraFiles.Add(MakefileData.ToMakefilePath(pfpath)); break; case BuildAction.EmbeddedResource: if (!projectFile.FilePath.IsChildPathOf(ctx.BaseDirectory)) { // file is not within directory hierarchy, copy it in string rdir = Path.Combine(Path.GetDirectoryName(project.FileName), resourcedir); if (!Directory.Exists(rdir)) { Directory.CreateDirectory(rdir); } string newPath = Path.Combine(rdir, Path.GetFileName(projectFile.FilePath)); FileService.CopyFile(projectFile.FilePath, newPath); pfpath = project.GetRelativeChildPath(newPath); pfpath = FileService.NormalizeRelativePath(pfpath); } if (!String.IsNullOrEmpty(projectFile.ResourceId) && projectFile.ResourceId != Path.GetFileName(pfpath)) { res_files.AppendFormat("\\\n\t{0},{1} ", MakefileData.ToMakefilePath(pfpath), MakefileData.EscapeString(projectFile.ResourceId)); } else { res_files.AppendFormat("\\\n\t{0} ", MakefileData.ToMakefilePath(pfpath)); } break; case "FileCopy": datafiles.AppendFormat("\\\n\t{0} ", MakefileData.ToMakefilePath(pfpath)); break; } } if (!generateAutotools) { templateFilesTargets = new StringBuilder(); installTarget = new StringBuilder(); uninstallTarget = new StringBuilder(); installDeps = new StringBuilder(); installDirs = new List <string> (); customCommands = new StringBuilder(); string programFilesDir = ctx.DeployContext.GetDirectory(TargetDirectory.ProgramFiles); //FIXME:temp programFilesDir = TranslateDir(programFilesDir); installDirs.Add(programFilesDir); installTarget.Append("\tmake pre-install-local-hook prefix=$(prefix)\n"); installTarget.Append("\tmake install-satellite-assemblies prefix=$(prefix)\n"); installTarget.AppendFormat("\tmkdir -p '$(DESTDIR){0}'\n", programFilesDir); installTarget.AppendFormat("\t$(call cp,$(ASSEMBLY),$(DESTDIR){0})\n", programFilesDir); installTarget.AppendFormat("\t$(call cp,$(ASSEMBLY_MDB),$(DESTDIR){0})\n", programFilesDir); //remove dir? uninstallTarget.Append("\tmake pre-uninstall-local-hook prefix=$(prefix)\n"); uninstallTarget.Append("\tmake uninstall-satellite-assemblies prefix=$(prefix)\n"); uninstallTarget.AppendFormat("\t$(call rm,$(ASSEMBLY),$(DESTDIR){0})\n", programFilesDir); uninstallTarget.AppendFormat("\t$(call rm,$(ASSEMBLY_MDB),$(DESTDIR){0})\n", programFilesDir); installDeps.Append(" $(ASSEMBLY) $(ASSEMBLY_MDB)"); conf_vars.AppendFormat("srcdir=.\n"); conf_vars.AppendFormat("top_srcdir={0}\n\n", FileService.AbsoluteToRelativePath(project.BaseDirectory, ctx.TargetSolution.BaseDirectory)); conf_vars.AppendFormat("include $(top_srcdir)/config.make\n\n"); // Don't emit for top level project makefile(eg. pdn.make), as it would be // included by top level solution makefile if (ctx.TargetSolution.BaseDirectory != project.BaseDirectory) { string customhooks = Path.Combine(project.BaseDirectory, "custom-hooks.make"); bool include = File.Exists(customhooks); includes = "include $(top_srcdir)/Makefile.include\n"; includes += String.Format("{0}include $(srcdir)/custom-hooks.make\n\n", include ? "" : "#"); if (include) { makefile.SetVariable("EXTRA_DIST", "$(srcdir)/custom-hooks.make"); } } } bool buildEnabled; List <ConfigSection> configSections = new List <ConfigSection> (); allDeployVars = new Dictionary <string, DeployFileData> (); foreach (SolutionConfiguration combineConfig in ctx.TargetSolution.Configurations) { DotNetProjectConfiguration config = GetProjectConfig(combineConfig.Id, project, out buildEnabled) as DotNetProjectConfiguration; if (config == null) { continue; } ConfigSection configSection = new ConfigSection(combineConfig.Id); string assembly = MakefileData.GetUnixPath(project.GetRelativeChildPath(config.CompiledOutputName)); configSection.BuildVariablesBuilder.AppendFormat("ASSEMBLY_COMPILER_COMMAND = {0}\n", setup.GetCompilerCommand(project, config.Id)); configSection.BuildVariablesBuilder.AppendFormat("ASSEMBLY_COMPILER_FLAGS = {0}\n", setup.GetCompilerFlags(project, config.Id)); // add check for compiler command in configure.ac ctx.AddCommandCheck(setup.GetCompilerCommand(project, config.Id)); configSection.BuildVariablesBuilder.AppendFormat("ASSEMBLY = {0}\n", AutotoolsContext.EscapeStringForAutomake(assembly)); configSection.BuildVariablesBuilder.AppendFormat("ASSEMBLY_MDB = {0}\n", config.DebugSymbols ? "$(ASSEMBLY).mdb" : String.Empty); string target; switch (config.CompileTarget) { case CompileTarget.Exe: target = "exe"; break; case CompileTarget.Library: target = "library"; break; case CompileTarget.WinExe: target = "winexe"; break; case CompileTarget.Module: target = "module"; break; default: throw new Exception(GettextCatalog.GetString("Unknown target {0}", config.CompileTarget)); } configSection.BuildVariablesBuilder.AppendFormat("COMPILE_TARGET = {0}\n", target); // for project references, we need a ref to the dll for the current configuration StringWriter projectReferences = new StringWriter(); string pref = null; foreach (ProjectReference reference in netProject.References) { if (reference.ReferenceType != ReferenceType.Project) { continue; } Project refp = reference.ResolveProject(ctx.TargetSolution); if (refp == null) { throw new Exception(GettextCatalog.GetString("Couldn't find referenced project '{0}'", reference.Reference)); } if (!(refp is DotNetProject)) { continue; } DotNetProjectConfiguration dnpc = GetProjectConfig(combineConfig.Id, refp, out buildEnabled) as DotNetProjectConfiguration; if (dnpc == null) { throw new Exception(GettextCatalog.GetString ("Could not add reference to project '{0}'", refp.Name)); } projectReferences.WriteLine(" \\"); projectReferences.Write("\t"); pref = project.GetRelativeChildPath(dnpc.CompiledOutputName); projectReferences.Write(MakefileData.ToMakefilePath(pref)); } configSection.BuildVariablesBuilder.AppendFormat("PROJECT_REFERENCES = {0}\n", projectReferences.ToString()); string buildDir = project.GetRelativeChildPath(config.OutputDirectory); configSection.BuildVariablesBuilder.AppendFormat("BUILD_DIR = {0}\n", MakefileData.ToMakefilePath(buildDir)); // Register files built by this configuration. // Built files won't be distributed. foreach (string bfile in builtFiles) { ctx.AddBuiltFile(Path.Combine(config.OutputDirectory, bfile)); } DeployFileCollection deployFiles = DeployService.GetDeployFiles( ctx.DeployContext, new SolutionFolderItem[] { project }, config.Selector); ProcessDeployFilesForConfig(deployFiles, project, configSection, ctx, config); configSections.Add(configSection); if (!generateAutotools) { EmitCustomCommandTargets(config.CustomCommands, project, customCommands, combineConfig.Id, new CustomCommandType [] { CustomCommandType.BeforeBuild, CustomCommandType.AfterBuild, CustomCommandType.BeforeClean, CustomCommandType.AfterClean }, monitor); } else { if (config.CustomCommands.Count > 0) { monitor.ReportWarning(GettextCatalog.GetString("Custom commands are not supported for autotools based makefiles. Ignoring.")); } } // Register files generated by the compiler ctx.AddBuiltFile(project.GetOutputFileName(combineConfig.Selector)); if (config.DebugSymbols) { ctx.AddBuiltFile(project.GetOutputFileName(combineConfig.Selector) + ".mdb"); } if (config.SignAssembly) { string spath = project.GetRelativeChildPath(config.AssemblyKeyFile); spath = FileService.NormalizeRelativePath(spath); extraFiles.Add(MakefileData.ToMakefilePath(spath)); } if (buildEnabled && pkgs.Count > 0) { ctx.AddRequiredPackages(combineConfig.Id, pkgs); } } foreach (string ef in extraFiles) { extras.AppendFormat("\\\n\t{0} ", ef); } Dictionary <string, DeployFileData> commonDeployVars = new Dictionary <string, DeployFileData> (allDeployVars); foreach (ConfigSection configSection in configSections) { List <string> toRemove = new List <string> (); foreach (KeyValuePair <string, DeployFileData> pair in commonDeployVars) { if (!configSection.DeployFileVars.ContainsKey(pair.Key)) { toRemove.Add(pair.Key); } } foreach (string s in toRemove) { commonDeployVars.Remove(s); } } //emit the config sections here.. to conf_vars foreach (ConfigSection configSection in configSections) { conf_vars.AppendFormat(generateAutotools ? "if ENABLE_{0}\n" : "ifeq ($(CONFIG),{0})\n", ctx.EscapeAndUpperConfigName(configSection.Name)); conf_vars.Append(configSection.BuildVariablesBuilder.ToString()); conf_vars.Append("\n"); if (ctx.Switches != null) { foreach (Switch s in ctx.Switches) { conf_vars.AppendLine(string.Format(@"if ENABLE_{0} ASSEMBLY_COMPILER_FLAGS += -define:{1} endif", s.SwitchName.Replace('-', '_').ToUpperInvariant(), s.Define)); } } foreach (KeyValuePair <string, DeployFileData> pair in allDeployVars) { string targetDeployVar = pair.Key; if (pair.Value.File.ContainsPathReferences) { //Template files are not handled per-config continue; } if (configSection.DeployFileVars.ContainsKey(targetDeployVar)) { //use the dfile from the config section DeployFile dfile = configSection.DeployFileVars [targetDeployVar]; string fname = MakefileData.ToMakefilePath( FileService.AbsoluteToRelativePath( Path.GetFullPath(project.BaseDirectory), Path.GetFullPath(dfile.SourcePath))); conf_vars.AppendFormat("{0}_SOURCE={1}\n", targetDeployVar, fname); if (!commonDeployVars.ContainsKey(targetDeployVar)) { //FOO_DLL=$(BUILD_DIR)/foo.dll conf_vars.AppendFormat("{0}=$(BUILD_DIR)/{1}\n", targetDeployVar, MakefileData.ToMakefilePath(dfile.RelativeTargetPath)); } } else { // not common and not part of @configSection conf_vars.AppendFormat("{0}=\n", pair.Key); } } conf_vars.Append("\nendif\n\n"); } conf_vars.AppendFormat("AL=al\n"); conf_vars.AppendFormat("SATELLITE_ASSEMBLY_NAME=$(notdir $(basename $(ASSEMBLY))).resources.dll\n"); foreach (KeyValuePair <string, DeployFileData> pair in allDeployVars) { HandleDeployFile(pair.Value, pair.Key, project, ctx); if (commonDeployVars.ContainsKey(pair.Key)) { //FOO_DLL=$(BUILD_DIR)/foo.dll deployFileCopyVars.AppendFormat("{0} = $(BUILD_DIR)/{1}\n", pair.Key, MakefileData.ToMakefilePath(pair.Value.File.RelativeTargetPath)); } } conf_vars.Append('\n'); StringBuilder vars = new StringBuilder(); foreach (KeyValuePair <string, StringBuilder> pair in deployDirs) { //PROGRAM_FILES= .. etc conf_vars.AppendFormat("{0} = {1} \n\n", pair.Key, pair.Value.ToString()); //Build list of deploy dir variables vars.AppendFormat("$({0}) ", pair.Key); } if (!generateAutotools) { installTarget.Insert(0, String.Format("install-local:{0}\n", installDeps.ToString())); installTarget.Append("\tmake post-install-local-hook prefix=$(prefix)\n"); uninstallTarget.Insert(0, String.Format("uninstall-local:{0}\n", installDeps.ToString())); uninstallTarget.Append("\tmake post-uninstall-local-hook prefix=$(prefix)\n"); } if (!generateAutotools && customCommands.Length > 0) { customCommands.Insert(0, "# Targets for Custom commands\n"); } templateEngine.Variables["CONFIG_VARS"] = conf_vars.ToString(); templateEngine.Variables["DEPLOY_FILE_VARS"] = vars.ToString(); templateEngine.Variables["COPY_DEPLOY_FILES_VARS"] = deployFileCopyVars.ToString(); templateEngine.Variables["COPY_DEPLOY_FILES_TARGETS"] = deployFileCopyTargets.ToString(); templateEngine.Variables["ALL_TARGET"] = (ctx.TargetSolution.BaseDirectory == project.BaseDirectory) ? "all-local" : "all"; templateEngine.Variables["INCLUDES"] = includes; templateEngine.Variables["FILES"] = files.ToString(); templateEngine.Variables["RESOURCES"] = res_files.ToString(); templateEngine.Variables["EXTRAS"] = extras.ToString(); templateEngine.Variables["DATA_FILES"] = datafiles.ToString(); templateEngine.Variables["CLEANFILES"] = vars.ToString(); if (!generateAutotools) { templateEngine.Variables["TEMPLATE_FILES_TARGETS"] = templateFilesTargets.ToString(); templateEngine.Variables["INSTALL_TARGET"] = installTarget.ToString(); templateEngine.Variables["UNINSTALL_TARGET"] = uninstallTarget.ToString(); templateEngine.Variables["CUSTOM_COMMAND_TARGETS"] = customCommands.ToString(); } // Create project specific makefile Stream stream = ctx.GetTemplateStream( generateAutotools ? "Makefile.am.project.template" : "Makefile.noauto.project.template"); StreamReader reader = new StreamReader(stream); string txt = templateEngine.Process(reader); reader.Close(); makefile.Append(txt); monitor.Step(1); } finally { monitor.EndTask(); } return(makefile); }
protected override bool OnBuild(IProgressMonitor monitor, DeployContext ctx) { string tmpFolder = null; try { SolutionConfigurationSelector conf = (SolutionConfigurationSelector)configuration; BuildResult res = RootSolutionItem.Build(monitor, conf); if (res.ErrorCount > 0) { foreach (BuildError e in res.Errors) { monitor.ReportError(e.ToString(), null); } monitor.ReportError(GettextCatalog.GetString("The source project failed to build."), null); return(false); } tmpFolder = FileService.CreateTempDirectory(); string tf = Path.GetFileNameWithoutExtension(targetFile); if (tf.EndsWith(".tar")) { tf = Path.GetFileNameWithoutExtension(tf); } string folder = FileService.GetFullPath(Path.Combine(tmpFolder, tf)); // Export the binary files DeployFileCollection deployFiles = GetDeployFiles(ctx, conf); foreach (DeployFile file in deployFiles) { string tfile = Path.Combine(folder, file.ResolvedTargetFile); string tdir = FileService.GetFullPath(Path.GetDirectoryName(tfile)); if (!Directory.Exists(tdir)) { Directory.CreateDirectory(tdir); } File.Copy(file.SourcePath, tfile, true); } // Create the archive string td = Path.GetDirectoryName(targetFile); if (!Directory.Exists(td)) { Directory.CreateDirectory(td); } DeployService.CreateArchive(monitor, tmpFolder, targetFile); } catch (Exception ex) { monitor.ReportError("Package creation failed", ex); LoggingService.LogError("Package creation failed", ex); return(false); } finally { if (tmpFolder != null) { Directory.Delete(tmpFolder, true); } } if (monitor.AsyncOperation.Success) { monitor.Log.WriteLine(GettextCatalog.GetString("Created file: {0}", targetFile)); } return(true); }