无法在 docker 容器上安装 VS 2022 的情况下构建面向 4.7.2 的 .NET Framework Web 应用程序
Cannot build .NET Framework web app targeting 4.7.2 with VS 2022 installed on a docker container
我无法成功构建基本的 ASP.NET 网络应用目标框架 4.7.2。
我用 Windows Server Core 2019. On this image I installed VS 2022 Enterprise 的基础映像构建了一个 docker 映像,并采用了 Azure 开发、.NET 桌面开发、ASP.NET 和 Web 开发模块,包括推荐的模块。
对于 dotnet 核心解决方案,一切正常,但对于 dotnet 框架,我收到这样的错误:
packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\build\net46\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props(31,5): Error MSB3758: An error has occurred during compilation. error CS0014: Required file 'alink.dll' could not be found
packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\build\net46\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props(31,5): Error MSB4175: The task factory "CodeTaskFactory" could not be loaded from the assembly "C:\Program Files\Microsoft Visual Studio22\Enterprise\MSBuild\Current\Bin\Microsoft.Build.Tasks.Core.dll". The task factory must return a value for the "TaskType" property.
我另外安装了 .NET Frameworks:4.5、4.6、4.6.1、4.7.1、4.8,但没有用。
在本地,我可以毫无问题地构建它。我检查了图像是否安装了 VS 2022 没有任何问题,它看起来也很好。所有环境变量也已到位。我认为这个问题与一些缺少的带有 SDK 的 .NET Frameworks 有关,但它仍然存在。
安装 Redistributable C++ 2012-2022 也没有帮助。我正在使用 MSBuild 17。
我可能还缺少什么?
我想为 Azure DevOps 创建一个代理,我使用 the Dockerfile from Microsoft 文档作为参考。一个区别是,在启动脚本之前,我 运行 我的自定义脚本使用我之前指定的模块静默安装 VS 2022。
我使用 Azure DevOps 管道构建解决方案和 VSBuild@1 任务。
我终于能够解决我遇到的问题了。事实证明,基础 windows server core
映像不包含所有必需的先决条件,也不包含 Visual Studio。解决方案是使用带有 sdk 4.8
的扩展 windows server core
图像。这很奇怪,因为 Visual Studio 已经为 sdk 4.8 提供了一切。我认为扩展图像一定有一些其他的东西,VS 安装没有。
我无法成功构建基本的 ASP.NET 网络应用目标框架 4.7.2。 我用 Windows Server Core 2019. On this image I installed VS 2022 Enterprise 的基础映像构建了一个 docker 映像,并采用了 Azure 开发、.NET 桌面开发、ASP.NET 和 Web 开发模块,包括推荐的模块。 对于 dotnet 核心解决方案,一切正常,但对于 dotnet 框架,我收到这样的错误:
packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\build\net46\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props(31,5): Error MSB3758: An error has occurred during compilation. error CS0014: Required file 'alink.dll' could not be found
packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\build\net46\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props(31,5): Error MSB4175: The task factory "CodeTaskFactory" could not be loaded from the assembly "C:\Program Files\Microsoft Visual Studio22\Enterprise\MSBuild\Current\Bin\Microsoft.Build.Tasks.Core.dll". The task factory must return a value for the "TaskType" property.
我另外安装了 .NET Frameworks:4.5、4.6、4.6.1、4.7.1、4.8,但没有用。 在本地,我可以毫无问题地构建它。我检查了图像是否安装了 VS 2022 没有任何问题,它看起来也很好。所有环境变量也已到位。我认为这个问题与一些缺少的带有 SDK 的 .NET Frameworks 有关,但它仍然存在。
安装 Redistributable C++ 2012-2022 也没有帮助。我正在使用 MSBuild 17。 我可能还缺少什么?
我想为 Azure DevOps 创建一个代理,我使用 the Dockerfile from Microsoft 文档作为参考。一个区别是,在启动脚本之前,我 运行 我的自定义脚本使用我之前指定的模块静默安装 VS 2022。 我使用 Azure DevOps 管道构建解决方案和 VSBuild@1 任务。
我终于能够解决我遇到的问题了。事实证明,基础 windows server core
映像不包含所有必需的先决条件,也不包含 Visual Studio。解决方案是使用带有 sdk 4.8
的扩展 windows server core
图像。这很奇怪,因为 Visual Studio 已经为 sdk 4.8 提供了一切。我认为扩展图像一定有一些其他的东西,VS 安装没有。