Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/302.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 在Windows Server Core Docker上安装.NET Framework 3.5_C#_.net_Docker_Dockerfile - Fatal编程技术网

C# 在Windows Server Core Docker上安装.NET Framework 3.5

C# 在Windows Server Core Docker上安装.NET Framework 3.5,c#,.net,docker,dockerfile,C#,.net,Docker,Dockerfile,我正在努力在docker容器上安装.NETFramework 3.5。我已经安装了4.5,但需要3.5才能运行一个服务。这是我的Dockerfile: 来自microsoft/windowsservercore SHELL[“powershell”] 运行安装WindowsFeature NET-Framework-45-ASPNET;\ 安装WindowsFeature Web-Asp-Net45 运行dism/online/enable feature/featurename:NetFX3/

我正在努力在docker容器上安装.NETFramework 3.5。我已经安装了4.5,但需要3.5才能运行一个服务。这是我的Dockerfile:

来自microsoft/windowsservercore
SHELL[“powershell”]
运行安装WindowsFeature NET-Framework-45-ASPNET;\
安装WindowsFeature Web-Asp-Net45
运行dism/online/enable feature/featurename:NetFX3/all
复制启动
复印服务
运行“C:\Windows\Microsoft.NET\Framework\v4.0.30319\installutil.exe”WCS.WindowsService.exe
运行mkdir Temp\Logs
入口点C:\Startup\setupBatch.bat
复制ContainerApi ContainerApi
运行删除网站-名称为“默认网站”
运行新网站-名称“ContainerApi”-端口80\
-物理路径“C:\ContainerApi'-ApplicationPool.NET v4.5”
暴露80
CMD[“ping”、“-t”、“localhost”]
当我尝试构建这个时,它在第
行RUN dism

错误:0x800f081f

找不到源文件。
使用“源”选项指定恢复功能所需文件的位置。有关指定源位置的详细信息,请参见

现在,即使我在docker(docker exec)中运行
dism/online/enable-feature/featurename:NetFX3/all
,它仍然会给我同样的错误


有人需要帮助吗?

我采取了以下步骤来解决此问题:

  • 已获取Windows Server 2016核心ISO文件。已在本地计算机上装入该文件
  • 将{mount}:/sources/sxs文件夹解压缩到zip文件(sxs.zip)中。确保.NET Framework 3.5 cab文件(microsoft-windows-netfx3-ondemand-package.cab)存在于sxs文件夹中。在我的例子中,这是sxs文件夹中唯一存在的文件
  • 将sxs.zip文件复制到我的容器中。我使用图像的dockerfile复制了它
  • 将文件解压缩到容器中的C:\sources\sxs文件夹
  • 使用安装WindowsFeature powershell命令安装该功能

    Install-WindowsFeature -Name NET-Framework-Features -Source C:\sources\sxs -Verbose
    

  • 希望这有帮助。我还发现下面的博客有助于理解随需应变功能。

    适用于那些仍然需要在一张图片中使用.Net3.5和.Net4.X(我的情况是4.7.2)版本的用户

    请注意,MSFT意识到了这一需求,并为此场景提供了一个基本映像

    在dockerfile中使用mcr.microsoft.com/dotnet/framework/sdk:3.5-20191008-windowsservercore-ltsc2019中的


    省去了我所有的安装麻烦

    我知道我必须避免+1或“谢谢”的评论,但是先生,你是一个生命的救世主,如果按照这些确切的指示去做,它仍然会失败。这可能不是正确的解决方案。这个基本图像对我来说很好。我不希望在映像构建过程中获得ISO映像并运行其他命令,因此这是一个完美的解决方案,可以满足我的需要。警告:此基础映像没有应用安全修补程序,因此(过期的安全性)在具有2020年2月安全修补程序的主机上不起作用: