{"record":{"id":"d2c1fe0af17ff1ab","repo":"microsoft/aspire","slug":"embedded-resource-microvenv-py-not-found","errorCode":null,"errorMessage":"Embedded resource 'microvenv.py' not found.","messagePattern":"Embedded resource 'microvenv\\.py' not found\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Hosting.CodeGeneration.Python/PythonLanguageSupport.cs","lineNumber":304,"sourceCode":"\n            if (!process.WaitForExit(5000))\n            {\n                return false;\n            }\n\n            return process.ExitCode == 0;\n        }\n        catch\n        {\n            return false;\n        }\n    }\n\n    private static string LoadMicrovenvScript()\n    {\n        using var stream = Assembly.GetExecutingAssembly()\n            .GetManifestResourceStream(\"Aspire.Hosting.CodeGeneration.Python.Resources.microvenv.py\")\n            ?? throw new InvalidOperationException(\"Embedded resource 'microvenv.py' not found.\");\n        using var reader = new StreamReader(stream);\n        return reader.ReadToEnd();\n    }\n}\n","sourceCodeStart":286,"sourceCodeEnd":309,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Hosting.CodeGeneration.Python/PythonLanguageSupport.cs#L286-L309","documentation":"When creating a Python virtual environment for generated Python AppHosts, the code loads the embedded `microvenv.py` bootstrap script from the Aspire.Hosting.CodeGeneration.Python assembly. `LoadMicrovenvScript` throws this InvalidOperationException if the embedded resource `Aspire.Hosting.CodeGeneration.Python.Resources.microvenv.py` is missing from the assembly. This indicates a broken or incomplete build/packaging of the library.","triggerScenarios":"Code path that creates a Python environment (via LoadMicrovenvScript, invoked during Python AppHost provisioning) running against an assembly that does not contain the microvenv.py embedded resource.","commonSituations":"Using a stripped or third-party rebuild of the package; a broken NuGet package cache or partially extracted package; building the repo with resources excluded by custom build settings.","solutions":["Clear the NuGet cache for the package and restore the official Aspire.Hosting.CodeGeneration.Python package (dotnet nuget locals all --clear, then restore).","If building from source, do a clean rebuild so Resources/microvenv.py is embedded again (verify the csproj lists it as EmbeddedResource).","Verify the resource exists in the deployed assembly with a tool like ILSpy/ildasm before filing a bug.","Report the issue with package version and RID if the official package is missing the resource."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"var hasMicrovenv = typeof(PythonLanguageSupport).Assembly\n  .GetManifestResourceNames()\n  .Contains(\"Aspire.Hosting.CodeGeneration.Python.Resources.microvenv.py\");","typeGuard":null,"tryCatchPattern":"try {\n  string script = LoadMicrovenvScript();\n} catch (InvalidOperationException ex) when (ex.Message.Contains(\"microvenv.py\")) {\n  // reinstall the package / fail with a clear 'broken install' message\n}","preventionTips":["Restore official packages; clear NuGet cache after partial installs.","Do not strip Resources/*.py from builds when customizing the repo.","Verify embedded resources after packaging changes."],"tags":["python","venv","embedded-resource","packaging"],"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"}