Esempio n. 1
0
        private void btCreateEXE_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                string sTempFile = Path.Combine(Environment.ExpandEnvironmentVariables("%TEMP%"), Path.GetRandomFileName() + ".json");
                SaveAsJSON(sTempFile);

                string jSW = File.ReadAllText(sTempFile);
                File.Delete(sTempFile);

                CreateExe oExe = new CreateExe(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, tbProductName.Text + "_" + tbVersion.Text + "_" + tbArchitecture.Text + "_setup.exe"));
                if (imgIcon.Tag != null)
                {
                    oExe.Icon = imgIcon.Tag as byte[];
                }
                oExe.Sources.Add(Properties.Resources.Source.Replace("RZRZRZ", tbProductName.Text));
                oExe.Sources.Add(Properties.Resources.RZUpdate);
                oExe.Sources.Add(Properties.Resources.RZRestApi);
                oExe.Sources.Add(Properties.Resources.Assembly.Replace("RZRZRZ", tbProductName.Text).Replace("[assembly: AssemblyFileVersion(\"1.0.0.0\")]", "[assembly: AssemblyFileVersion(\"" + tbVersion.Text + "\")]"));

                System.Resources.ResourceWriter writer = new System.Resources.ResourceWriter("Resources.resx");
                writer.AddResource("SW.json", jSW);
                writer.Generate();
                writer.Close();
                oExe.cp.EmbeddedResources.Add("Resources.resx");
                if (!oExe.Compile())
                {
                    MessageBox.Show("Failed to create .Exe", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                }
                File.Delete("Resources.resx");
            }
            catch { }
        }
Esempio n. 2
0
        public void Translate(string infile, string outfile)
        {
            var writer = new System.Resources.ResourceWriter(outfile);

            foreach (var resource in MSBuildResXReader.GetResourcesFromFile(infile, pathsRelativeToBasePath: true))
            {
                resource.AddTo(writer);
            }

            writer.Generate();
            writer.Close();
        }
Esempio n. 3
0
        public void Translate(string infile, string outfile)
        {
            var writer = new System.Resources.ResourceWriter(outfile);

            using (var inf = File.OpenText(infile))
            {
                var reader = new mono.ResXResourceReader(inf);
                foreach (DictionaryEntry d in reader)
                {
                    writer.AddResource(d.Key.ToString(), d.Value);
                }
            }

            writer.Generate();
            writer.Close();
        }
        public static void CreateResourceFile(string filename, Dictionary<string, object> data)
        {
            System.IO.MemoryStream memStream = new System.IO.MemoryStream();

            System.Resources.ResourceWriter rw = new System.Resources.ResourceWriter(memStream);

            System.Collections.IDictionaryEnumerator dictEnum = data.GetEnumerator();

            while (dictEnum.MoveNext())
            {
                if(dictEnum.Value != null)
                    rw.AddResource(dictEnum.Key.ToString(), dictEnum.Value);
            }

            rw.Generate();

            byte[] resourceBytes = FileUtils.GetStreamBytes(memStream);

            resourceBytes = Utilities.CryptoUtils.Encrypt(resourceBytes, "asdlfa9sd879*Lasldflkajsdf243o8729");

            // Zip the bytes
            /*MemoryStream zippedMemStream = new MemoryStream();
            System.IO.Compression.GZipStream zipStream = new System.IO.Compression.GZipStream(zippedMemStream, System.IO.Compression.CompressionMode.Compress);

            byte[] resourceBytes = FileUtils.GetStreamBytes(memStream);
            zipStream.Write(resourceBytes, 0, resourceBytes.Length);

            // Now Encrypt the resource file
            zippedMemStream.Position = 0;
            resourceBytes = Utilities.CryptoUtils.Encrypt(FileUtils.GetStreamBytes(zippedMemStream), "asdlfa9sd879*Lasldflkajsdf243o8729");

            zippedMemStream.Close();
            zippedMemStream.Dispose();*/

            memStream.Close();
            memStream.Dispose();

            rw.Close();
            rw.Dispose();

            File.WriteAllBytes(filename, resourceBytes);
        }
Esempio n. 5
0
 private void _addNewResource(string key, string value)
 {
     System.Resources.IResourceWriter writer = new System.Resources.ResourceWriter(Properties.Resources.ResourceManager.BaseName);
     writer.AddResource(key, value);
     writer.Close();
 }
Esempio n. 6
0
        protected void bt_Compile_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(tb_Filename.Text))
            {
                ShowMessage("Filename is missing.. !", MessageType.Error);
                return;
            }
            if (string.IsNullOrEmpty(tb_PSSCript.Text))
            {
                ShowMessage("PowerShell script cannot be empty.. !", MessageType.Error);
                return;
            }
            string sPSTest = TestPowerShellSyntax(tb_PSSCript.Text);

            if (!string.IsNullOrEmpty(sPSTest))
            {
                ShowMessage("Syntax Error:" + sPSTest, MessageType.Error);
                return;
            }
            string sFilename = Environment.ExpandEnvironmentVariables(Server.MapPath("~/App_Data/" + Path.GetRandomFileName().Split('.')[0] + ".exe"));

            //string sResname = Environment.ExpandEnvironmentVariables(Server.MapPath("~/App_Data/" + Path.GetRandomFileName().Split('.')[0]));
            //Directory.CreateDirectory(sResname);
            if (!Directory.Exists(Server.MapPath("~/App_Data")))
            {
                try
                {
                    Directory.CreateDirectory(Server.MapPath("~/App_Data"));
                }
                catch { }
            }


            //string sFilename = Environment.ExpandEnvironmentVariables(Server.MapPath("~/App_Data/" + tb_Filename.Text));
            string sResname = Environment.ExpandEnvironmentVariables(Server.MapPath("~/App_Data/Resources.resx"));

            try
            {
                File.Delete(sFilename);
                File.Delete(sResname);
            }
            catch { }

            CreateExe oExe = new CreateExe(sFilename, Server.MapPath("~/Bin"));

            oExe.cp.CompilerOptions = Environment.ExpandEnvironmentVariables("/win32icon:\"" + Server.MapPath("~/Images/powershell.ico") + "\" /optimize");

            oExe.Sources.Add(Properties.Resources.Source);
            oExe.Sources.Add(Properties.Resources.Assembly);

            System.Resources.ResourceWriter writer = new System.Resources.ResourceWriter(sResname);
            writer.AddResource("psCode.ps1", " " + Zip(tb_PSSCript.Text.Trim()));
            writer.Generate();
            writer.Close();
            oExe.cp.EmbeddedResources.Add(sResname);

            if (!oExe.Compile())
            {
                //MessageBox.Show("Failed to create .Exe", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                sFilename.ToString();
            }

            //File.Delete(sResname);
            //Directory.Delete(sResname);

            Response.ContentType = "application/octet-stream";
            Response.AppendHeader("Content-Disposition", "attachment; filename=" + tb_Filename.Text);
            Response.TransmitFile(sFilename);
            Response.End();


            try
            {
                File.Delete(sFilename);
                File.Delete(sResname);
            }
            catch { }
        }