private void SN() { SN sn = new SN(this.Options); sn.Go(); }
private void RemoveSN() { SN sn = new SN(Options); sn.ShowStartTextInfo(); string[] rows = Options.Rows; for (int i = 0; i < rows.Length; i++) { string file = rows[i]; RemoveSN(file); } foreach (string file in _allAssemblies.Keys) { AssemblyDefinition ad = _allAssemblies[file]; FixAssemblyNameReference(ad, null); } _changedAssemblies.Clear(); string[] keys = new string[_allAssemblies.Count]; int count = 0; foreach (object key in _allAssemblies.Keys) { keys[count] = key as string; count++; } for (int i = 0; i < keys.Length; i++) { string file = keys[i]; AssemblyDefinition ad = _allAssemblies[file]; #region get output file string outputFile; if (Options.chkOverwriteOriginalFileChecked) outputFile = file; else if (Options.SourceDir == Options.OutputDir) outputFile = Path.ChangeExtension(file, ".NoSN" + Path.GetExtension(file)); else outputFile = Path.Combine(Options.OutputDir, Path.GetFileName(file)); #endregion get output file Options.AppendTextInfo(String.Format("Saving assembly: {0}\r\n", ad.Name.Name)); ad.Write(outputFile); _allAssemblies.Remove(file); ad = null; } sn.ShowCompleteTextInfo(); }
private void Resign(string file, string keyFile) { SN sn = new SN(); sn.Options.SourceDir = Options.SourceDir; sn.Options.Host = Options.Host; sn.Options.TextInfoBox = Options.TextInfoBox; sn.Options.Rows = new string[] { file }; sn.Options.rbRaChecked = true; sn.Options.KeyFile = keyFile; sn.Options.ShowStartCompleteTextInfo = false; sn.Go(); }
private void Sign() { SN sn = new SN(Options); sn.ShowStartTextInfo(); string keyFile = Options.KeyFile; StrongNameKeyPair snkp = null; try { using (FileStream fs = new FileStream(keyFile, FileMode.Open, FileAccess.Read)) { snkp = new StrongNameKeyPair(fs); } } catch { throw; } string[] rows = Options.Rows; for (int i = 0; i < rows.Length; i++) { string file = PathUtils.GetFullFileName(rows, i, Options.SourceDir); Sign(file, snkp); } foreach (string file in _allAssemblies.Keys) { AssemblyDefinition ad = _allAssemblies[file]; FixAssemblyNameReference(ad, snkp); ad = null; } //we free something to release memory, use lots of memory... _changedAssemblies.Clear(); string[] keys = new string[_allAssemblies.Count]; int count = 0; foreach (object key in _allAssemblies.Keys) { keys[count] = key as string; count++; } for (int i = 0; i < keys.Length; i++) { string file = keys[i]; AssemblyDefinition ad = _allAssemblies[file]; #region get output file string outputFile; if (Options.chkOverwriteOriginalFileChecked) outputFile = file; else if (Options.SourceDir == Options.OutputDir) outputFile = Path.ChangeExtension(file, ".SN" + Path.GetExtension(file)); else outputFile = Path.Combine(Options.OutputDir, Path.GetFileName(file)); #endregion get output file Options.AppendTextInfo(String.Format("Saving assembly: {0}\r\n", ad.Name.Name)); ad.Write(outputFile); Resign(outputFile, keyFile); _allAssemblies.Remove(file); ad = null; } sn.ShowCompleteTextInfo(); }
private void mnuGenStrongKey_Click(object sender, EventArgs e) { string initDir = null; if (!String.IsNullOrEmpty(Config.StrongKeyFile)) { initDir = Path.GetDirectoryName(Config.StrongKeyFile); } string file = SimpleDialog.OpenFile(null, "Key Files(*.snk)|*.snk|All Files(*.*)|*.*", ".snk", false, initDir); if (!String.IsNullOrEmpty(file)) { if (File.Exists(file)) File.Delete(file); SN sn = new SN(); sn.Options.Host = this; sn.Options.SourceDir = Path.GetDirectoryName(file); sn.Options.rbCustomChecked = true; sn.Options.AdditionalOptions = String.Format(" -k \"{0}\" ", file); sn.Options.TextInfoBox = new TextBox(); sn.Go(); if (File.Exists(file)) { SimpleMessage.ShowInfo(String.Format("Key pair written to {0}", file)); } else { SimpleMessage.ShowInfo(String.Format("Failed to generate key file.\n\n{0}", sn.Options.TextInfoBox.Text)); } } }
private void RemoveSN() { SN sn = new SN(Options); sn.ShowStartTextInfo(); string[] rows = Options.Rows; for (int i = 0; i < rows.Length; i++) { string file = rows[i]; RemoveSN(file); } foreach (string file in _allAssemblies.Keys) { AssemblyDefinition ad = _allAssemblies[file]; FixAssemblyNameReference(ad, null); } _changedAssemblies.Clear(); string[] keys = new string[_allAssemblies.Count]; int count = 0; foreach (object key in _allAssemblies.Keys) { keys[count] = key as string; count++; } for (int i = 0; i < keys.Length; i++) { string file = keys[i]; AssemblyDefinition ad = _allAssemblies[file]; #region get output file string outputFile; if (Options.chkOverwriteOriginalFileChecked) { outputFile = file; } else if (Options.SourceDir == Options.OutputDir) { outputFile = Path.ChangeExtension(file, ".NoSN" + Path.GetExtension(file)); } else { outputFile = Path.Combine(Options.OutputDir, Path.GetFileName(file)); } #endregion get output file Options.AppendTextInfo(String.Format("Saving assembly: {0}\r\n", ad.Name.Name)); ad.Write(outputFile); _allAssemblies.Remove(file); ad = null; } sn.ShowCompleteTextInfo(); }
private void Sign() { SN sn = new SN(Options); sn.ShowStartTextInfo(); string keyFile = Options.KeyFile; StrongNameKeyPair snkp = null; try { using (FileStream fs = new FileStream(keyFile, FileMode.Open, FileAccess.Read)) { snkp = new StrongNameKeyPair(fs); } } catch { throw; } string[] rows = Options.Rows; for (int i = 0; i < rows.Length; i++) { string file = PathUtils.GetFullFileName(rows, i, Options.SourceDir); Sign(file, snkp); } foreach (string file in _allAssemblies.Keys) { AssemblyDefinition ad = _allAssemblies[file]; FixAssemblyNameReference(ad, snkp); ad = null; } //we free something to release memory, use lots of memory... _changedAssemblies.Clear(); string[] keys = new string[_allAssemblies.Count]; int count = 0; foreach (object key in _allAssemblies.Keys) { keys[count] = key as string; count++; } for (int i = 0; i < keys.Length; i++) { string file = keys[i]; AssemblyDefinition ad = _allAssemblies[file]; #region get output file string outputFile; if (Options.chkOverwriteOriginalFileChecked) { outputFile = file; } else if (Options.SourceDir == Options.OutputDir) { outputFile = Path.ChangeExtension(file, ".SN" + Path.GetExtension(file)); } else { outputFile = Path.Combine(Options.OutputDir, Path.GetFileName(file)); } #endregion get output file Options.AppendTextInfo(String.Format("Saving assembly: {0}\r\n", ad.Name.Name)); ad.Write(outputFile); Resign(outputFile, keyFile); _allAssemblies.Remove(file); ad = null; } sn.ShowCompleteTextInfo(); }