public void TestControlLicenseResources() { InstallerLinkerArguments args = new InstallerLinkerArguments(); string licenseFile = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString() + ".txt"); try { Uri uri = new Uri(Assembly.GetExecutingAssembly().CodeBase); string binPath = Path.GetDirectoryName(HttpUtility.UrlDecode(uri.AbsolutePath)); ConfigFile configFile = new ConfigFile(); SetupConfiguration setupConfiguration = new SetupConfiguration(); configFile.Children.Add(setupConfiguration); ControlLicense license = new ControlLicense(); license.LicenseFile = licenseFile; Console.WriteLine("Writing '{0}'", license.LicenseFile); File.WriteAllText(license.LicenseFile, "Lorem ipsum"); setupConfiguration.Children.Add(license); args.config = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString() + ".xml"); Console.WriteLine("Writing '{0}'", args.config); configFile.SaveAs(args.config); args.output = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString() + ".exe"); Console.WriteLine("Linking '{0}'", args.output); args.template = dotNetInstallerExeUtils.Executable; InstallerLib.InstallerLinker.CreateInstaller(args); // check that the linker generated output Assert.IsTrue(File.Exists(args.output)); Assert.IsTrue(new FileInfo(args.output).Length > 0); using (ResourceInfo ri = new ResourceInfo()) { ri.Load(args.output); Assert.IsTrue(ri.Resources.ContainsKey(new ResourceId("CUSTOM"))); List <Resource> custom = ri.Resources[new ResourceId("CUSTOM")]; Assert.AreEqual("RES_BANNER", custom[0].Name.Name); Assert.AreEqual("RES_CONFIGURATION", custom[1].Name.ToString()); Assert.AreEqual("RES_LICENSE", custom[2].Name.ToString()); } } finally { if (File.Exists(licenseFile)) { File.Delete(licenseFile); } if (File.Exists(args.config)) { File.Delete(args.config); } if (File.Exists(args.output)) { File.Delete(args.output); } } }
private void FormMain_Load(object sender, EventArgs e) { btnMenuLicense.Enabled = false; lda = new TBL_LICENSE_DATA_ACCESS(); clm = new ControlLicenseMenuLeft(); cl = new ControlLicense(); clm.Dock = DockStyle.Fill; panelLeft.Controls.Add(clm); cl.Dock = DockStyle.Fill; panelContainer.Controls.Add(cl); GC.Collect(); }
public void TestGetFilesSourceAppPath() { ControlLicense license = new ControlLicense(); license.LicenseFile = @"#APPPATH\license.txt"; string supportdir = Environment.CurrentDirectory; ResourceFileCollection resources = license.GetResources(supportdir); Assert.AreEqual(1, resources.Count); Assert.AreEqual(Path.Combine(Environment.CurrentDirectory, "license.txt"), resources[0].path); Assert.AreEqual("RES_LICENSE", resources[0].id); }
public void ShowLicense(object sender, EventArgs e) { try { panelContainer.Controls.Clear(); cl = new ControlLicense(); cl.Dock = DockStyle.Fill; panelContainer.Controls.Add(cl); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
private void btnMenuLicense_Click(object sender, EventArgs e) { btnMenuLicense.Enabled = false; btnMenuReport.Enabled = true; btnMenuWork.Enabled = true; panelLeft.Controls.Clear(); panelContainer.Controls.Clear(); clm = new ControlLicenseMenuLeft(); cl = new ControlLicense(); clm.Dock = DockStyle.Fill; cl.Dock = DockStyle.Fill; panelLeft.Controls.Add(clm); panelContainer.Controls.Add(cl); GC.Collect(); }
public void TestUserControlLicense() { Console.WriteLine("TestUserControlLicense"); string configFilename = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString() + ".xml"); // a configuration with a license agreement control ConfigFile configFile = new ConfigFile(); SetupConfiguration setupConfiguration = new SetupConfiguration(); configFile.Children.Add(setupConfiguration); ControlLicense license = new ControlLicense(); license.Accepted = true; license.ResourceId = "MY_RES_LICENSE"; license.LicenseFile = configFilename; setupConfiguration.Children.Add(license); ComponentCmd cmd = new ComponentCmd(); cmd.command = "cmd.exe /C exit /b [MY_RES_LICENSE]"; cmd.required_install = true; setupConfiguration.Children.Add(cmd); // save config file Console.WriteLine("Writing '{0}'", configFilename); configFile.SaveAs(configFilename); // create a setup with the license file InstallerLinkerArguments args = new InstallerLinkerArguments(); args.config = configFilename; args.output = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString() + ".exe"); args.template = dotNetInstallerExeUtils.Executable; Console.WriteLine("Linking '{0}'", args.output); InstallerLinkerExeUtils.CreateInstaller(args); Assert.IsTrue(File.Exists(args.output)); // execute dotNetInstaller Assert.AreEqual(1, dotNetInstallerExeUtils.Run(args.output, "/q")); File.Delete(args.config); File.Delete(args.output); }