/// <summary> /// Write out the PEFile (the "bake" function) /// </summary> /// <param name="debug">include debug information</param> public void WritePEFile(bool writePDB) { if (outStream == null) { if (outputDir != null) { if (!outputDir.EndsWith("\\")) { fileName = outputDir + "\\" + fileName; } else { fileName = outputDir + fileName; } } output = new PEWriter(versionInfo, fileName, metaData, writePDB); } else { // Check to make sure we have not been asked to write a PDB if (writePDB) { throw new Exception("You can not write PDB data when writing to a stream. Please try writing to a file instead."); } output = new PEWriter(versionInfo, outStream, metaData); } BuildMetaData(); // If the application is roundtripping an input PE-file with // unmanaged resources, then this.unmanagedResourceRoot != null. if (this.unmanagedResourceRoot != null) { output.AddUnmanagedResourceDirectory(this.unmanagedResourceRoot); } output.MakeFile(versionInfo); }