chocolatey/choco · error · FileNotFoundException
Could not find a file in the manifest resource stream of '{0
Error message
Could not find a file in the manifest resource stream of '{0}' at '{1}'. What it means
Thrown by AssemblyFileExtractor.ExtractTextFileFromAssembly when the embedded manifest resource string for the given manifestLocation comes back null/whitespace. The method asks the assembly for its manifest string; if the resource is absent or unreadable it logs an error and raises a FileNotFoundException naming the assembly and the missing manifest path.
Source
Thrown at src/chocolatey/infrastructure/extractors/AssemblyFileExtractor.cs:53
/// <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 ExtractTextFileFromAssembly(IFileSystem fileSystem, IAssembly assembly, string manifestLocation, string filePath, bool overwriteExisting = false)
{
if (overwriteExisting || !fileSystem.FileExists(filePath))
{
fileSystem.EnsureDirectoryExists(fileSystem.GetDirectoryName(filePath));
var fileText = assembly.GetManifestString(manifestLocation);
if (string.IsNullOrWhiteSpace(fileText))
{
var errorMessage = "Could not find a file in the manifest resource stream of '{0}' at '{1}'.".FormatWith(assembly.FullName, manifestLocation);
"chocolatey".Log().Error(() => errorMessage);
throw new FileNotFoundException(errorMessage);
}
fileSystem.WriteFile(filePath, fileText, Encoding.UTF8);
}
}
/// <summary>
/// Extract binary file from an assembly to a 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>
/// <param name="throwError">Throw an error if there are issues</param>
public static void ExtractBinaryFileFromAssembly(IFileSystem fileSystem, IAssembly assembly, string manifestLocation, string filePath, bool overwriteExisting = false, bool throwError = true)
View on GitHub (pinned to 0d5abdd10c)
Solutions
- Verify the manifestLocation string exactly matches the embedded resource name (default namespace + folder path + filename, case-sensitive).
- Open the assembly in a decompiler/ILSpy and confirm the resource exists under Resources; re-embed it with Build Action = Embedded Resource if missing.
- If the file is legitimately optional, guard the call or skip extraction when the resource is known-absent rather than letting it throw.
Example fix
// before AssemblyFileExtractor.ExtractFileFromAssembly(fs, asm, "chocolatey.templates.old_name.ps1", outPath); // after (resource renamed in build) AssemblyFileExtractor.ExtractFileFromAssembly(fs, asm, "chocolatey.templates.new_name.ps1", outPath);
Defensive patterns
Strategy: validation
Validate before calling
var names = assembly.GetManifestResourceNames();
if (Array.IndexOf(names, manifestLocation) < 0)
throw new InvalidOperationException("Manifest resource '" + manifestLocation + "' not present in assembly '" + assembly.FullName + "'."); Try / catch
try
{
AssemblyFileExtractor.ExtractTextFileFromAssembly(fs, assembly, manifestLocation, filePath);
}
catch (FileNotFoundException ex) when (ex.Message.Contains("manifest resource stream"))
{
logger.Error(ex.Message + " Verify the resource is embedded with the correct name and namespace.");
throw;
} Prevention
- Cross-check manifestLocation against GetManifestResourceNames() during build/tests.
- Keep embedded resource paths stable across renames; update manifestLocation constants when files move.
When it happens
Trigger: Calling ExtractTextFileFromAssembly with a manifestLocation that does not match any embedded resource in the assembly, or against an assembly whose embedded resources were stripped/not compiled in. assembly.GetManifestString(manifestLocation) yields empty.
Common situations: A Chocolatey build that forgot to embed a template/helper file (.ps1, .txt) as an embedded resource, or a renamed resource path after refactoring. Third-party licensed assemblies missing expected resources on a version mismatch.
Related errors
- No {0} files (or more than 1) were found to build in '{1}'.
- Unable to find suitable location for PowerShell. Searched th
AI-assisted analysis of chocolatey/choco@0d5abdd10c (2026-08-13).
Data as JSON: /api/errors/094b5bfe94dec68a.
Report an issue: GitHub.