无法通过Chocolatey安装ASP.NET MVC 3的解决方案求助
ASP.NET MVC 3 Docker安装404问题及解决方案
问题背景
此前通过Dockerfile使用Chocolatey安装ASP.NET MVC 3一直正常,近期出现404错误,推测是包内的exe下载路径失效,且该包已停止维护。尝试过PowerShell和CURL直接安装对应exe均失败,需要可行的安装方案。
相关信息
- Chocolatey关联包:aspnetmvc.install
最简Dockerfile
# escape=` FROM mcr.microsoft.com/dotnet/framework/runtime:4.8-windowsservercore-ltsc2022 SHELL ["cmd", "/S", "/C"] # Install Chocolatey RUN Echo "*********** Chocolatey Install" RUN powershell.exe Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1')) # Install MVC RUN Echo "*********** Install MVC" RUN choco install aspnetmvc --yes
错误日志
RUN choco install aspnetmvc --yes ---> Running in 59edd75191b8 Chocolatey v2.2.2 Installing the following packages: aspnetmvc By installing, you accept licenses for the packages. Progress: Downloading aspnetmvc.install 3.1.0.20140613... 19% Progress: Downloading aspnetmvc.install 3.1.0.20140613... 53% Progress: Downloading aspnetmvc.install 3.1.0.20140613... 86% Progress: Downloading aspnetmvc.install 3.1.0.20140613... 100% aspnetmvc.install v3.1.0.20140613 [Approved] aspnetmvc.install package files install completed. Performing other installation steps. This will take forever to install. Go outside or something...come back in about an hour or so. For serious yo... Attempt to get headers for http://www.microsoft.com/downloads/info.aspx?na=41&srcfamilyid=82cbd599-d29a-43e3-b78b-0f863d22811a&srcdisplaylang=en&u=http%3a%2f%2fdownload.microsoft.com%2fdownload%2fF%2f3%2f1%2fF31EF055-3C46-4E35-AB7B-3261A303A3B6%2fAspNetMVC3ToolsUpdateSetup.exe failed. The remote file either doesn't exist, is unauthorized, or is forbidden for url 'http://www.microsoft.com/downloads/info.aspx?na=41&srcfamilyid=82cbd599-d29a-43e3-b78b-0f863d22811a&srcdisplaylang=en&u=http%3a%2f%2fdownload.microsoft.com%2fdownload%2fF%2f3%2f1%2fF31EF055-3C46-4E35-AB7B-3261A303A3B6%2fAspNetMVC3ToolsUpdateSetup.exe'. Exception calling "GetResponse" with "0" argument(s): "The remote server returned an error: (404) Not Found." Downloading aspnetmvc from 'http://www.microsoft.com/downloads/info.aspx?na=41&srcfamilyid=82cbd599-d29a-43e3-b78b-0f863d22811a&srcdisplaylang=en&u=http%3a%2f%2fdownload.microsoft.com%2fdownload%2fF%2f3%2f1%2fF31EF055-3C46-4E35-AB7B-3261A303A3B6%2fAspNetMVC3ToolsUpdateSetup.exe' ERROR: The remote file either doesn't exist, is unauthorized, or is forbidden for url 'http://www.microsoft.com/downloads/info.aspx?na=41&srcfamilyid=82cbd599-d29a-43e3-b78b-0f863d22811a&srcdisplaylang=en&u=http%3a%2f%2fdownload.microsoft.com%2fdownload%2fF%2f3%2f1%2fF31EF055-3C46-4E35-AB7B-3261A303A3B6%2fAspNetMVC3ToolsUpdateSetup.exe'. Exception calling "GetResponse" with "0" argument(s): "The remote server returned an error: (404) Not Found." The install of aspnetmvc.install was NOT successful. Error while running 'C:\ProgramData\chocolatey\lib\aspnetmvc.install\tools\chocolateyInstall.ps1'. See log for details. Progress: Downloading aspnetmvc 3.0.0.2... 23% Progress: Downloading aspnetmvc 3.0.0.2... 62% Progress: Downloading aspnetmvc 3.0.0.2... 100% aspnetmvc v3.0.0.2 [Approved] aspnetmvc package files install completed. Performing other installation steps. The install of aspnetmvc was successful. Software installed to 'C:\ProgramData\chocolatey\lib\aspnetmvc' Chocolatey installed 1/2 packages. 1 packages failed. See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log). Failures - aspnetmvc.install (exited 404) - Error while running 'C:\ProgramData\chocolatey\lib\aspnetmvc.install\tools\chocolateyInstall.ps1'. See log for details. The command 'cmd /S /C choco install aspnetmvc --yes' returned a non-zero code: 404 Process exited with code 404
可行安装方案
方案1:直接使用微软存档安装包
原Chocolatey包的下载链接已失效,可在Dockerfile中直接下载微软存档的ASP.NET MVC 3工具更新安装包并静默安装:
# escape=` FROM mcr.microsoft.com/dotnet/framework/runtime:4.8-windowsservercore-ltsc2022 SHELL ["cmd", "/S", "/C"] # Install Chocolatey(若仍需用Chocolatey管理其他包) RUN Echo "*********** Chocolatey Install" RUN powershell.exe Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1')) # 下载并静默安装ASP.NET MVC 3 RUN Echo "*********** Install MVC 3" RUN powershell.exe -Command "Invoke-WebRequest -Uri 'https://download.microsoft.com/download/F/3/1/F31EF055-3C46-4E35-AB7B-3261A303A3B6/AspNetMVC3ToolsUpdateSetup.exe' -OutFile 'AspNetMVC3ToolsUpdateSetup.exe'" RUN AspNetMVC3ToolsUpdateSetup.exe /quiet /norestart RUN del AspNetMVC3ToolsUpdateSetup.exe
说明:
/quiet参数实现无交互静默安装,/norestart避免安装后自动重启容器,最后删除安装包减少镜像体积。
方案2:本地预下载安装包构建
如果网络访问受限,可提前将AspNetMVC3ToolsUpdateSetup.exe下载到本地,再通过COPY命令复制到容器内安装:
# escape=` FROM mcr.microsoft.com/dotnet/framework/runtime:4.8-windowsservercore-ltsc2022 SHELL ["cmd", "/S", "/C"] # 复制本地安装包到容器 COPY AspNetMVC3ToolsUpdateSetup.exe . # 静默安装并清理安装包 RUN AspNetMVC3ToolsUpdateSetup.exe /quiet /norestart RUN del AspNetMVC3ToolsUpdateSetup.exe
方案3:结合Chocolatey跳过失效子包
若需保留Chocolatey对aspnetmvc主包的管理,可跳过失效的aspnetmvc.install子包,手动安装工具更新:
# escape=` FROM mcr.microsoft.com/dotnet/framework/runtime:4.8-windowsservercore-ltsc2022 SHELL ["cmd", "/S", "/C"] # Install Chocolatey RUN Echo "*********** Chocolatey Install" RUN powershell.exe Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1')) # 安装aspnetmvc主包,跳过失效的install子包 RUN choco install aspnetmvc --yes --skip-packages=aspnetmvc.install # 手动安装MVC3工具更新 RUN powershell.exe -Command "Invoke-WebRequest -Uri 'https://download.microsoft.com/download/F/3/1/F31EF055-3C46-4E35-AB7B-3261A303A3B6/AspNetMVC3ToolsUpdateSetup.exe' -OutFile 'AspNetMVC3ToolsUpdateSetup.exe'" RUN AspNetMVC3ToolsUpdateSetup.exe /quiet /norestart RUN del AspNetMVC3ToolsUpdateSetup.exe
内容的提问来源于stack exchange,提问作者Alvin
相关产品推荐
相关产品推荐

