{"record":{"id":"d99a31bc3b36bb52","repo":"microsoft/aspire","slug":"embedded-telemetry-hook-script-resourcename-was-not-found-in","errorCode":null,"errorMessage":"Embedded telemetry hook script '{resourceName}' was not found in the CLI assembly.","messagePattern":"Embedded telemetry hook script '(.+?)' was not found in the CLI assembly\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Cli/Agents/Hooks/TelemetryHookInstaller.cs","lineNumber":66,"sourceCode":"        var powerShellContent = ReadEmbeddedText(PowerShellResourceName);\n\n        await WriteFileIfChangedAsync(shellPath, shellContent, cancellationToken);\n        await WriteFileIfChangedAsync(powerShellPath, powerShellContent, cancellationToken);\n\n        // Ensure the shell script is executable so a `bash <path>` (or direct exec) hook entry works.\n        // Spawning `chmod` would add PATH/shell failure modes, so use the platform API directly.\n        TrySetExecutable(shellPath);\n\n        return new TelemetryHookScripts(shellPath, powerShellPath);\n    }\n\n    private static string NormalizeToLf(string content)\n        => content.Replace(\"\\r\\n\", \"\\n\").Replace(\"\\r\", \"\\n\");\n\n    private static string ReadEmbeddedText(string resourceName)\n    {\n        using var stream = typeof(TelemetryHookInstaller).Assembly.GetManifestResourceStream(resourceName)\n            ?? throw new InvalidOperationException($\"Embedded telemetry hook script '{resourceName}' was not found in the CLI assembly.\");\n        using var reader = new StreamReader(stream, s_utf8NoBom);\n        return reader.ReadToEnd();\n    }\n\n    private async Task WriteFileIfChangedAsync(string path, string content, CancellationToken cancellationToken)\n    {\n        // Skip the write when the content already matches so a running hook isn't disturbed and the\n        // file mtime stays stable across repeated `agent init` runs.\n        if (File.Exists(path))\n        {\n            try\n            {\n                var existing = await File.ReadAllTextAsync(path, s_utf8NoBom, cancellationToken);\n                if (string.Equals(existing, content, StringComparison.Ordinal))\n                {\n                    return;\n                }\n            }","sourceCodeStart":48,"sourceCodeEnd":84,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Cli/Agents/Hooks/TelemetryHookInstaller.cs#L48-L84","documentation":"TelemetryHookInstaller.ReadEmbeddedText loads hook script text (shell/PowerShell) that is embedded as a manifest resource in the CLI assembly. This error means the resource name was not found — the assembly is missing an expected embedded script. It signals a broken or partially built/deployed CLI binary rather than a user input problem.","triggerScenarios":"Thrown when Assembly.GetManifestResourceStream(resourceName) returns null for a shell or PowerShell telemetry hook script — i.e. the resource was not embedded at build time, or a trimmed/published assembly dropped it.","commonSituations":"Running a hand-built or locally modified CLI where the .sh/.ps1 embedded resources were not included; IL trimming or single-file publish stripping resources; copying a partially built binary; mismatch between resource naming convention and code after a rename.","solutions":["Rebuild/reinstall the CLI from official sources (or run ./build.sh / dotnet publish with default settings) so embedded resources are included.","If you customized resource file names/namespaces, update the resourceName strings in TelemetryHookInstaller to match the actual embedded resource names.","Disable aggressive trimming/resource stripping for the CLI publish, or verify the resource appears in the assembly's manifest.","Run `aspire --version` to confirm you are on a complete, official build rather than a partial local artifact."],"exampleFix":"// before\n// csproj omits the hook scripts from embedded resources\n// after\n<ItemGroup>\n  <EmbeddedResource Include=\"Agents/Hooks/Scripts/*.sh;Agents/Hooks/Scripts/*.ps1\" />\n</ItemGroup>","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try\n{\n    await installer.InstallAsync(...);\n}\ncatch (InvalidOperationException ex) when (ex.Message.StartsWith(\"Embedded telemetry hook script\"))\n{\n    // the CLI build is missing embedded resources; reinstall the CLI\n}","preventionTips":["Use official CLI builds rather than partially published/trimmed local artifacts.","After resource file renames, confirm embedded resource names match code references.","Avoid IL trimming settings that strip EmbeddedResource entries from the CLI assembly."],"tags":["embedded-resource","assembly","cli","build"],"backgroundTag":"resource-not-found","analyzedSha":"25830f84bd145686607ad00c057b3f84e2e51d43","analyzedAt":"2026-09-16T11:10:06.193Z","contentChangedAt":"2026-09-16T11:10:06.193Z","schemaVersion":2},"datasetVersion":"2026-09-21T04:17:39.646Z"}