{"id":514,"date":"2021-10-06T07:20:29","date_gmt":"2021-10-06T07:20:29","guid":{"rendered":"https:\/\/yer.ac\/blog\/?p=514"},"modified":"2021-10-06T07:22:08","modified_gmt":"2021-10-06T07:22:08","slug":"fixing-hostfxr-dll-could-not-be-found-within-windows-docker-container-net-installed-from-dotnet-install-ps1","status":"publish","type":"post","link":"https:\/\/yer.ac\/blog\/2021\/10\/06\/fixing-hostfxr-dll-could-not-be-found-within-windows-docker-container-net-installed-from-dotnet-install-ps1\/","title":{"rendered":"Fixing &#8220;hostfxr.dll could not be found&#8221; within Windows Docker container (.NET installed from dotnet-install.ps1)"},"content":{"rendered":"\n<p>This is here mostly for my own reference for next time I need to fix this, but may be useful to someone else. <\/p>\n\n\n\n<p>Installing .NET (5, Core, etc.) via the Microsoft Supplied &#8220;dotnet-install.ps1&#8243;(<a href=\"https:\/\/docs.microsoft.com\/en-us\/dotnet\/core\/tools\/dotnet-install-script\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/docs.microsoft.com\/en-us\/dotnet\/core\/tools\/dotnet-install-script<\/a>) installs the frameworks fine, but then running .net core code within that windows container would sometimes yield an error like <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>A fatal error occurred, the required library hostfxr.dll could not be found.\nIf this is a self-contained application, that library should exist in &#91;C:\\Users\\ContainerAdmin\\....<em>omitted<\/em> path..\\].\nIf this is a framework-dependent application, install the runtime in the default location &#91;C:\\Program Files\\dotnet] or use the DOTNET_ROOT environment variable to specify the runtime location.<\/code><\/pre>\n\n\n\n<p>The problem here is that whilst the framework is installed, its not only installed into the <em>ContainerAdmin <\/em>user directory by default (Meaning issues with <em>ContainerUser <\/em>running code), but also that neither the PATH nor DOTNET_SETUP system variables have been altered.<\/p>\n\n\n\n<p>This can be confirmed by either running the images terminal in something like Portainer, or doing a docker exec, and simply typing <code>$env:Path<\/code>  and <code>$env:DOTNET_ROOT<\/code> into the terminal. The first will most likely not contain the .Net install location, and the latter will yield an empty\/null result.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Quick fix \/ Proving the issue<\/h2>\n\n\n\n<p>To prove this is the case, we can simply execute the command(s):<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$env:Path += \";C:\\Users\\ContainerAdministrator\\AppData\\Local\\Microsoft\\dotnet\\\"\r\n$env:DOTNET_ROOT = \"C:\\Users\\ContainerAdministrator\\AppData\\Local\\Microsoft\\dotnet\\\"<\/code><\/pre>\n\n\n\n<p>and now, if the library is installed it should run the .net code fine.<\/p>\n\n\n\n<p>My next step was adding these to their own PowerShell file to be included and ran (as per above) as part of my Dockerfile build. <strong>It seems that whilst this code executes during docker build, it doesn&#8217;t actually set the paths correctly though<\/strong>. Maybe it is linked to the library being installed into users? Either way it didn&#8217;t want to work unless I executed the code manually.  (Someone feel free to correct me on this!)<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Changing default installation &amp; Setting paths via Dockerfile <\/h2>\n\n\n\n<p>I think there are 2 issues here. One is that the dotnet library is being installed into a users directly, and the other is that the paths are not being set properly.<\/p>\n\n\n\n<p><strong>Changing the install location<\/strong><\/p>\n\n\n\n<p>When running dotnet-install.ps1, we can pass an <code>InstallDir<\/code> parameter through. I suggest a commonly accessible location like &#8220;C:\\Dotnet&#8221;, so that the command looks like:<\/p>\n\n\n\n<p>.<code>\\dotnet-install.ps1\u00a0-Channel\u00a0Current\u00a0-runtime\u00a0aspnetcore\u00a0<strong>-InstallDir\u00a0\"C:\\dotnet\"<\/strong><\/code><\/p>\n\n\n\n<p><strong>Changing the environmental variables within the Dockerfile<\/strong><\/p>\n\n\n\n<p>By making use of the <code>SET \/M<\/code> command. <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>RUN setx \/M PATH $($Env:PATH + ';C:\\dotnet')\r\nRUN setx \/M DOTNET_ROOT 'C:\\dotnet'<\/code><\/pre>\n\n\n\n<p>The first will append the install location to the path (Hence the ; at the start), and the second will set the DOTNET_ROOT variable.<\/p>\n\n\n\n<p>Now rebuilding your image should ensure the framework is globally accessible.<\/p>\n\n\n\n<p>Hopefully this helps <em>someone<\/em> as I spent too long and waded through too many similar github issue tickets before finding the full solution!<\/p>\n\n\n\n<p>A snippet from the Dockerfile below for reference:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"586\" height=\"114\" data-attachment-id=\"517\" data-permalink=\"https:\/\/yer.ac\/blog\/2021\/10\/06\/fixing-hostfxr-dll-could-not-be-found-within-windows-docker-container-net-installed-from-dotnet-install-ps1\/image-30\/\" data-orig-file=\"https:\/\/i0.wp.com\/yer.ac\/blog\/wp-content\/uploads\/2021\/10\/image.png?fit=586%2C114&amp;ssl=1\" data-orig-size=\"586,114\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"image\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/i0.wp.com\/yer.ac\/blog\/wp-content\/uploads\/2021\/10\/image.png?fit=300%2C58&amp;ssl=1\" data-large-file=\"https:\/\/i0.wp.com\/yer.ac\/blog\/wp-content\/uploads\/2021\/10\/image.png?fit=586%2C114&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/yer.ac\/blog\/wp-content\/uploads\/2021\/10\/image.png?resize=586%2C114&#038;ssl=1\" alt=\"\" class=\"wp-image-517\" srcset=\"https:\/\/i0.wp.com\/yer.ac\/blog\/wp-content\/uploads\/2021\/10\/image.png?w=586&amp;ssl=1 586w, https:\/\/i0.wp.com\/yer.ac\/blog\/wp-content\/uploads\/2021\/10\/image.png?resize=300%2C58&amp;ssl=1 300w\" sizes=\"auto, (max-width: 586px) 100vw, 586px\" \/><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>This is here mostly for my own reference for next time I need to fix this, but may be useful to someone else. Installing .NET (5, Core, etc.) via the Microsoft Supplied &#8220;dotnet-install.ps1&#8243;(https:\/\/docs.microsoft.com\/en-us\/dotnet\/core\/tools\/dotnet-install-script) installs the frameworks fine, but then running .net core code within that windows container would sometimes yield an error like The problem &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[42,41],"tags":[2,31,43,10],"class_list":["post-514","post","type-post","status-publish","format-standard","hentry","category-docker","category-powershell","tag-devops","tag-docker","tag-dotnet","tag-powershell"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.3 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Fixing &quot;hostfxr.dll could not be found&quot; within Windows Docker container (.NET installed from dotnet-install.ps1) - yer.ac | Adventures of a developer, and other things.<\/title>\n<meta name=\"description\" content=\"Fixing dotnet code not being ran or the &quot;dotnet&quot; command not being recognised within a docker container after running dotnet-install.ps1\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/yer.ac\/blog\/2021\/10\/06\/fixing-hostfxr-dll-could-not-be-found-within-windows-docker-container-net-installed-from-dotnet-install-ps1\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Fixing &quot;hostfxr.dll could not be found&quot; within Windows Docker container (.NET installed from dotnet-install.ps1) - yer.ac | Adventures of a developer, and other things.\" \/>\n<meta property=\"og:description\" content=\"Fixing dotnet code not being ran or the &quot;dotnet&quot; command not being recognised within a docker container after running dotnet-install.ps1\" \/>\n<meta property=\"og:url\" content=\"https:\/\/yer.ac\/blog\/2021\/10\/06\/fixing-hostfxr-dll-could-not-be-found-within-windows-docker-container-net-installed-from-dotnet-install-ps1\/\" \/>\n<meta property=\"og:site_name\" content=\"yer.ac | Adventures of a developer, and other things.\" \/>\n<meta property=\"article:published_time\" content=\"2021-10-06T07:20:29+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-10-06T07:22:08+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/yer.ac\/blog\/wp-content\/uploads\/2021\/10\/image.png\" \/>\n<meta name=\"author\" content=\"yer.ac\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"yer.ac\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/yer.ac\\\/blog\\\/2021\\\/10\\\/06\\\/fixing-hostfxr-dll-could-not-be-found-within-windows-docker-container-net-installed-from-dotnet-install-ps1\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/yer.ac\\\/blog\\\/2021\\\/10\\\/06\\\/fixing-hostfxr-dll-could-not-be-found-within-windows-docker-container-net-installed-from-dotnet-install-ps1\\\/\"},\"author\":{\"name\":\"yer.ac\",\"@id\":\"https:\\\/\\\/yer.ac\\\/blog\\\/#\\\/schema\\\/person\\\/4638b9d868c7d3747bd3bb01fbc8153d\"},\"headline\":\"Fixing &#8220;hostfxr.dll could not be found&#8221; within Windows Docker container (.NET installed from dotnet-install.ps1)\",\"datePublished\":\"2021-10-06T07:20:29+00:00\",\"dateModified\":\"2021-10-06T07:22:08+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/yer.ac\\\/blog\\\/2021\\\/10\\\/06\\\/fixing-hostfxr-dll-could-not-be-found-within-windows-docker-container-net-installed-from-dotnet-install-ps1\\\/\"},\"wordCount\":421,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/yer.ac\\\/blog\\\/#\\\/schema\\\/person\\\/4638b9d868c7d3747bd3bb01fbc8153d\"},\"image\":{\"@id\":\"https:\\\/\\\/yer.ac\\\/blog\\\/2021\\\/10\\\/06\\\/fixing-hostfxr-dll-could-not-be-found-within-windows-docker-container-net-installed-from-dotnet-install-ps1\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/yer.ac\\\/blog\\\/wp-content\\\/uploads\\\/2021\\\/10\\\/image.png\",\"keywords\":[\"DevOps\",\"docker\",\"dotnet\",\"PowerShell\"],\"articleSection\":[\"Docker\",\"PowerShell\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/yer.ac\\\/blog\\\/2021\\\/10\\\/06\\\/fixing-hostfxr-dll-could-not-be-found-within-windows-docker-container-net-installed-from-dotnet-install-ps1\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/yer.ac\\\/blog\\\/2021\\\/10\\\/06\\\/fixing-hostfxr-dll-could-not-be-found-within-windows-docker-container-net-installed-from-dotnet-install-ps1\\\/\",\"url\":\"https:\\\/\\\/yer.ac\\\/blog\\\/2021\\\/10\\\/06\\\/fixing-hostfxr-dll-could-not-be-found-within-windows-docker-container-net-installed-from-dotnet-install-ps1\\\/\",\"name\":\"Fixing \\\"hostfxr.dll could not be found\\\" within Windows Docker container (.NET installed from dotnet-install.ps1) - yer.ac | Adventures of a developer, and other things.\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/yer.ac\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/yer.ac\\\/blog\\\/2021\\\/10\\\/06\\\/fixing-hostfxr-dll-could-not-be-found-within-windows-docker-container-net-installed-from-dotnet-install-ps1\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/yer.ac\\\/blog\\\/2021\\\/10\\\/06\\\/fixing-hostfxr-dll-could-not-be-found-within-windows-docker-container-net-installed-from-dotnet-install-ps1\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/yer.ac\\\/blog\\\/wp-content\\\/uploads\\\/2021\\\/10\\\/image.png\",\"datePublished\":\"2021-10-06T07:20:29+00:00\",\"dateModified\":\"2021-10-06T07:22:08+00:00\",\"description\":\"Fixing dotnet code not being ran or the \\\"dotnet\\\" command not being recognised within a docker container after running dotnet-install.ps1\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/yer.ac\\\/blog\\\/2021\\\/10\\\/06\\\/fixing-hostfxr-dll-could-not-be-found-within-windows-docker-container-net-installed-from-dotnet-install-ps1\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/yer.ac\\\/blog\\\/2021\\\/10\\\/06\\\/fixing-hostfxr-dll-could-not-be-found-within-windows-docker-container-net-installed-from-dotnet-install-ps1\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/yer.ac\\\/blog\\\/2021\\\/10\\\/06\\\/fixing-hostfxr-dll-could-not-be-found-within-windows-docker-container-net-installed-from-dotnet-install-ps1\\\/#primaryimage\",\"url\":\"https:\\\/\\\/yer.ac\\\/blog\\\/wp-content\\\/uploads\\\/2021\\\/10\\\/image.png\",\"contentUrl\":\"https:\\\/\\\/yer.ac\\\/blog\\\/wp-content\\\/uploads\\\/2021\\\/10\\\/image.png\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/yer.ac\\\/blog\\\/2021\\\/10\\\/06\\\/fixing-hostfxr-dll-could-not-be-found-within-windows-docker-container-net-installed-from-dotnet-install-ps1\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/yer.ac\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Fixing &#8220;hostfxr.dll could not be found&#8221; within Windows Docker container (.NET installed from dotnet-install.ps1)\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/yer.ac\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/yer.ac\\\/blog\\\/\",\"name\":\"yer.ac | Adventures of a developer, and other things.\",\"description\":\"Blog to keep track of things I am upto\",\"publisher\":{\"@id\":\"https:\\\/\\\/yer.ac\\\/blog\\\/#\\\/schema\\\/person\\\/4638b9d868c7d3747bd3bb01fbc8153d\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/yer.ac\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/yer.ac\\\/blog\\\/#\\\/schema\\\/person\\\/4638b9d868c7d3747bd3bb01fbc8153d\",\"name\":\"yer.ac\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/67ed010c9cc7986d40647e061c6dcdb06d818776591c7e954055adb629621113?s=96&d=retro&r=pg\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/67ed010c9cc7986d40647e061c6dcdb06d818776591c7e954055adb629621113?s=96&d=retro&r=pg\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/67ed010c9cc7986d40647e061c6dcdb06d818776591c7e954055adb629621113?s=96&d=retro&r=pg\",\"caption\":\"yer.ac\"},\"logo\":{\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/67ed010c9cc7986d40647e061c6dcdb06d818776591c7e954055adb629621113?s=96&d=retro&r=pg\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Fixing \"hostfxr.dll could not be found\" within Windows Docker container (.NET installed from dotnet-install.ps1) - yer.ac | Adventures of a developer, and other things.","description":"Fixing dotnet code not being ran or the \"dotnet\" command not being recognised within a docker container after running dotnet-install.ps1","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/yer.ac\/blog\/2021\/10\/06\/fixing-hostfxr-dll-could-not-be-found-within-windows-docker-container-net-installed-from-dotnet-install-ps1\/","og_locale":"en_US","og_type":"article","og_title":"Fixing \"hostfxr.dll could not be found\" within Windows Docker container (.NET installed from dotnet-install.ps1) - yer.ac | Adventures of a developer, and other things.","og_description":"Fixing dotnet code not being ran or the \"dotnet\" command not being recognised within a docker container after running dotnet-install.ps1","og_url":"https:\/\/yer.ac\/blog\/2021\/10\/06\/fixing-hostfxr-dll-could-not-be-found-within-windows-docker-container-net-installed-from-dotnet-install-ps1\/","og_site_name":"yer.ac | Adventures of a developer, and other things.","article_published_time":"2021-10-06T07:20:29+00:00","article_modified_time":"2021-10-06T07:22:08+00:00","og_image":[{"url":"https:\/\/yer.ac\/blog\/wp-content\/uploads\/2021\/10\/image.png","type":"","width":"","height":""}],"author":"yer.ac","twitter_card":"summary_large_image","twitter_misc":{"Written by":"yer.ac","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/yer.ac\/blog\/2021\/10\/06\/fixing-hostfxr-dll-could-not-be-found-within-windows-docker-container-net-installed-from-dotnet-install-ps1\/#article","isPartOf":{"@id":"https:\/\/yer.ac\/blog\/2021\/10\/06\/fixing-hostfxr-dll-could-not-be-found-within-windows-docker-container-net-installed-from-dotnet-install-ps1\/"},"author":{"name":"yer.ac","@id":"https:\/\/yer.ac\/blog\/#\/schema\/person\/4638b9d868c7d3747bd3bb01fbc8153d"},"headline":"Fixing &#8220;hostfxr.dll could not be found&#8221; within Windows Docker container (.NET installed from dotnet-install.ps1)","datePublished":"2021-10-06T07:20:29+00:00","dateModified":"2021-10-06T07:22:08+00:00","mainEntityOfPage":{"@id":"https:\/\/yer.ac\/blog\/2021\/10\/06\/fixing-hostfxr-dll-could-not-be-found-within-windows-docker-container-net-installed-from-dotnet-install-ps1\/"},"wordCount":421,"commentCount":0,"publisher":{"@id":"https:\/\/yer.ac\/blog\/#\/schema\/person\/4638b9d868c7d3747bd3bb01fbc8153d"},"image":{"@id":"https:\/\/yer.ac\/blog\/2021\/10\/06\/fixing-hostfxr-dll-could-not-be-found-within-windows-docker-container-net-installed-from-dotnet-install-ps1\/#primaryimage"},"thumbnailUrl":"https:\/\/yer.ac\/blog\/wp-content\/uploads\/2021\/10\/image.png","keywords":["DevOps","docker","dotnet","PowerShell"],"articleSection":["Docker","PowerShell"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/yer.ac\/blog\/2021\/10\/06\/fixing-hostfxr-dll-could-not-be-found-within-windows-docker-container-net-installed-from-dotnet-install-ps1\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/yer.ac\/blog\/2021\/10\/06\/fixing-hostfxr-dll-could-not-be-found-within-windows-docker-container-net-installed-from-dotnet-install-ps1\/","url":"https:\/\/yer.ac\/blog\/2021\/10\/06\/fixing-hostfxr-dll-could-not-be-found-within-windows-docker-container-net-installed-from-dotnet-install-ps1\/","name":"Fixing \"hostfxr.dll could not be found\" within Windows Docker container (.NET installed from dotnet-install.ps1) - yer.ac | Adventures of a developer, and other things.","isPartOf":{"@id":"https:\/\/yer.ac\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/yer.ac\/blog\/2021\/10\/06\/fixing-hostfxr-dll-could-not-be-found-within-windows-docker-container-net-installed-from-dotnet-install-ps1\/#primaryimage"},"image":{"@id":"https:\/\/yer.ac\/blog\/2021\/10\/06\/fixing-hostfxr-dll-could-not-be-found-within-windows-docker-container-net-installed-from-dotnet-install-ps1\/#primaryimage"},"thumbnailUrl":"https:\/\/yer.ac\/blog\/wp-content\/uploads\/2021\/10\/image.png","datePublished":"2021-10-06T07:20:29+00:00","dateModified":"2021-10-06T07:22:08+00:00","description":"Fixing dotnet code not being ran or the \"dotnet\" command not being recognised within a docker container after running dotnet-install.ps1","breadcrumb":{"@id":"https:\/\/yer.ac\/blog\/2021\/10\/06\/fixing-hostfxr-dll-could-not-be-found-within-windows-docker-container-net-installed-from-dotnet-install-ps1\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/yer.ac\/blog\/2021\/10\/06\/fixing-hostfxr-dll-could-not-be-found-within-windows-docker-container-net-installed-from-dotnet-install-ps1\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/yer.ac\/blog\/2021\/10\/06\/fixing-hostfxr-dll-could-not-be-found-within-windows-docker-container-net-installed-from-dotnet-install-ps1\/#primaryimage","url":"https:\/\/yer.ac\/blog\/wp-content\/uploads\/2021\/10\/image.png","contentUrl":"https:\/\/yer.ac\/blog\/wp-content\/uploads\/2021\/10\/image.png"},{"@type":"BreadcrumbList","@id":"https:\/\/yer.ac\/blog\/2021\/10\/06\/fixing-hostfxr-dll-could-not-be-found-within-windows-docker-container-net-installed-from-dotnet-install-ps1\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/yer.ac\/blog\/"},{"@type":"ListItem","position":2,"name":"Fixing &#8220;hostfxr.dll could not be found&#8221; within Windows Docker container (.NET installed from dotnet-install.ps1)"}]},{"@type":"WebSite","@id":"https:\/\/yer.ac\/blog\/#website","url":"https:\/\/yer.ac\/blog\/","name":"yer.ac | Adventures of a developer, and other things.","description":"Blog to keep track of things I am upto","publisher":{"@id":"https:\/\/yer.ac\/blog\/#\/schema\/person\/4638b9d868c7d3747bd3bb01fbc8153d"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/yer.ac\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/yer.ac\/blog\/#\/schema\/person\/4638b9d868c7d3747bd3bb01fbc8153d","name":"yer.ac","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/67ed010c9cc7986d40647e061c6dcdb06d818776591c7e954055adb629621113?s=96&d=retro&r=pg","url":"https:\/\/secure.gravatar.com\/avatar\/67ed010c9cc7986d40647e061c6dcdb06d818776591c7e954055adb629621113?s=96&d=retro&r=pg","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/67ed010c9cc7986d40647e061c6dcdb06d818776591c7e954055adb629621113?s=96&d=retro&r=pg","caption":"yer.ac"},"logo":{"@id":"https:\/\/secure.gravatar.com\/avatar\/67ed010c9cc7986d40647e061c6dcdb06d818776591c7e954055adb629621113?s=96&d=retro&r=pg"}}]}},"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/paP5IW-8i","jetpack-related-posts":[{"id":303,"url":"https:\/\/yer.ac\/blog\/2019\/09\/05\/dotnet-pack-project-reference-and-nuget-dependency\/","url_meta":{"origin":514,"position":0},"title":"Include both Nuget Package References and project reference DLL using &#8220;dotnet pack&#8221; \ud83d\udce6","author":"yer.ac","date":"September 5, 2019","format":false,"excerpt":"Recently I have been trying to generate more Nuget packages for our dotnet core projects, utilizing the dotnet pack command. One issue I have been encountering is that the command was either referencing the required nuget packages, or the project reference DLLs, never both. The current problem. If you have\u2026","rel":"","context":"In &quot;Development&quot;","block_context":{"text":"Development","link":"https:\/\/yer.ac\/blog\/category\/development\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/yer.ac\/blog\/wp-content\/uploads\/2019\/09\/image-1.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/yer.ac\/blog\/wp-content\/uploads\/2019\/09\/image-1.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/yer.ac\/blog\/wp-content\/uploads\/2019\/09\/image-1.png?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":315,"url":"https:\/\/yer.ac\/blog\/2019\/10\/16\/ensuring-dotnet-test-trx-coverage-files-end-up-in-sonarqube\/","url_meta":{"origin":514,"position":1},"title":"Ensuring &#8220;dotnet test&#8221; TRX &#038; Coverage files end up in SonarQube","author":"yer.ac","date":"October 16, 2019","format":false,"excerpt":"I have written before about using SonarQube to do static analysis, but one issue I never came back to was ensuring that code coverage files generated via a build pipeline end up being picked up by the Sonar Scanner to assess code coverage. Note that the following I am actually\u2026","rel":"","context":"In &quot;DevOps&quot;","block_context":{"text":"DevOps","link":"https:\/\/yer.ac\/blog\/category\/devops\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/yer.ac\/blog\/wp-content\/uploads\/2019\/10\/image.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":527,"url":"https:\/\/yer.ac\/blog\/2023\/03\/23\/polymorphic-serialization-deserialziation-of-interface-implementations-in-net6\/","url_meta":{"origin":514,"position":2},"title":"Polymorphic Serialization &#038; Deserialziation of Interface implementations in dotnet","author":"yer.ac","date":"March 23, 2023","format":false,"excerpt":"I will preface this by saying this is not a good idea and was more of a \"I wonder..\", as you lose the benefit of a descriptive model (especially in swagger), and its somewhat brittle if you add more types. Honestly it started as a \"It would be nice if\u2026","rel":"","context":"In &quot;Development&quot;","block_context":{"text":"Development","link":"https:\/\/yer.ac\/blog\/category\/development\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":351,"url":"https:\/\/yer.ac\/blog\/2020\/01\/06\/using-docker-containers-for-easy-local-wordpress-development%f0%9f%90%b3\/","url_meta":{"origin":514,"position":3},"title":"Using Docker Containers for easy local WordPress development\ud83d\udc33","author":"yer.ac","date":"January 6, 2020","format":false,"excerpt":"Creating WordPress development environment using Docker containers.","rel":"","context":"In &quot;Development&quot;","block_context":{"text":"Development","link":"https:\/\/yer.ac\/blog\/category\/development\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/yer.ac\/blog\/wp-content\/uploads\/2020\/01\/image-1.png?fit=648%2C465&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/yer.ac\/blog\/wp-content\/uploads\/2020\/01\/image-1.png?fit=648%2C465&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/yer.ac\/blog\/wp-content\/uploads\/2020\/01\/image-1.png?fit=648%2C465&ssl=1&resize=525%2C300 1.5x"},"classes":[]},{"id":151,"url":"https:\/\/yer.ac\/blog\/2019\/05\/29\/remote-nlog-logging-with-azure-functions-part-two-persisting-data-into-azure-cosmos-db\/","url_meta":{"origin":514,"position":4},"title":"Remote NLOG logging with Azure Functions (Part two) &#8211; Persisting data into Azure Cosmos DB.","author":"yer.ac","date":"May 29, 2019","format":false,"excerpt":"Last time, I got a very basic C# Azure Function hooked up to accept a request from an NLOG web service target. This time, I will be attempting to persist(insert) the incoming log information into an Azure Cosmos database container, direct from my Azure Function in VS Code. Disclaimer: This\u2026","rel":"","context":"In &quot;Azure&quot;","block_context":{"text":"Azure","link":"https:\/\/yer.ac\/blog\/category\/development\/azure\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/yer.ac\/blog\/wp-content\/uploads\/2019\/05\/image-12.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/yer.ac\/blog\/wp-content\/uploads\/2019\/05\/image-12.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/yer.ac\/blog\/wp-content\/uploads\/2019\/05\/image-12.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/yer.ac\/blog\/wp-content\/uploads\/2019\/05\/image-12.png?resize=700%2C400&ssl=1 2x, https:\/\/i0.wp.com\/yer.ac\/blog\/wp-content\/uploads\/2019\/05\/image-12.png?resize=1050%2C600&ssl=1 3x"},"classes":[]},{"id":576,"url":"https:\/\/yer.ac\/blog\/2025\/08\/18\/vibing-in-kiro-to-create-a-self-serve-portainer-wrapper\/","url_meta":{"origin":514,"position":5},"title":"Vibing in Kiro to create a self-serve Portainer wrapper.","author":"yer.ac","date":"August 18, 2025","format":false,"excerpt":"On a Friday afternoon with half an hour to spare, I tested Kiro, Amazon\u2019s new agentic IDE, against a real-world problem: giving my team a simple way to start and stop Docker services in Portainer. With nothing more than a rough prompt, a PowerShell script, and a few \u201cTrust command\u201d\u2026","rel":"","context":"In &quot;AI&quot;","block_context":{"text":"AI","link":"https:\/\/yer.ac\/blog\/category\/development\/ai\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/yer.ac\/blog\/wp-content\/uploads\/2025\/08\/Untitled-1.png?fit=1200%2C649&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/yer.ac\/blog\/wp-content\/uploads\/2025\/08\/Untitled-1.png?fit=1200%2C649&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/yer.ac\/blog\/wp-content\/uploads\/2025\/08\/Untitled-1.png?fit=1200%2C649&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/yer.ac\/blog\/wp-content\/uploads\/2025\/08\/Untitled-1.png?fit=1200%2C649&ssl=1&resize=700%2C400 2x, https:\/\/i0.wp.com\/yer.ac\/blog\/wp-content\/uploads\/2025\/08\/Untitled-1.png?fit=1200%2C649&ssl=1&resize=1050%2C600 3x"},"classes":[]}],"_links":{"self":[{"href":"https:\/\/yer.ac\/blog\/wp-json\/wp\/v2\/posts\/514","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/yer.ac\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/yer.ac\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/yer.ac\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/yer.ac\/blog\/wp-json\/wp\/v2\/comments?post=514"}],"version-history":[{"count":5,"href":"https:\/\/yer.ac\/blog\/wp-json\/wp\/v2\/posts\/514\/revisions"}],"predecessor-version":[{"id":520,"href":"https:\/\/yer.ac\/blog\/wp-json\/wp\/v2\/posts\/514\/revisions\/520"}],"wp:attachment":[{"href":"https:\/\/yer.ac\/blog\/wp-json\/wp\/v2\/media?parent=514"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/yer.ac\/blog\/wp-json\/wp\/v2\/categories?post=514"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/yer.ac\/blog\/wp-json\/wp\/v2\/tags?post=514"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}