/// <summary> /// Extract text file from assembly to location on disk. /// </summary> /// <param name="fileSystem">The file system.</param> /// <param name="assembly">The assembly.</param> /// <param name="manifestLocation">The manifest location.</param> /// <param name="filePath">The file path.</param> /// <param name="overwriteExisting"> /// if set to <c>true</c> [overwrite existing]. /// </param> /// <exception cref="System.IO.FileNotFoundException"></exception> public static void extract_text_file_from_assembly(IFileSystem fileSystem, IAssembly assembly, string manifestLocation, string filePath, bool overwriteExisting = false) { if (overwriteExisting || !fileSystem.file_exists(filePath)) { fileSystem.create_directory_if_not_exists(fileSystem.get_directory_name(filePath)); var fileText = assembly.get_manifest_string(manifestLocation); if (string.IsNullOrWhiteSpace(fileText)) { string errorMessage = "Could not find a file in the manifest resource stream of '{0}' at '{1}'.".format_with(assembly.FullName, manifestLocation); "chocolatey".Log().Error(() => errorMessage); throw new FileNotFoundException(errorMessage); } fileSystem.write_file(filePath, fileText, Encoding.UTF8); } }