【发布时间】:2020-05-26 20:29:10
【问题描述】:
我们使用以下技术开发了一个 .NET Core Web API 应用程序:
-NET Core (3.1)
-Visual Studio 2019
很遗憾,我们不得不将上述应用部署到以下环境:
-32 位环境
-Windows Server 2008 R2 Enterprise (Service Pack 1)
-IIS 7.5 版
-8 GB 内存
因此,在我的 Visual Studio 2019 中,我启动了该应用程序,并采取了以下步骤:
在 VS 中强制 x86 转到属性 > 构建并将平台目标从任何 CPU 更改为 x86
在 .NET Core 应用程序的项目根目录中创建了一个 Directory.Build.targets:
<Project> <PropertyGroup Condition="'$(OS)' == 'Windows_NT' and '$(PlatformTarget)' == 'x86' and '$(TargetFrameworkIdentifier)' == '.NETCoreApp' and '$(SelfContained)' != 'true'" > <RunCommand>$(MSBuildProgramFiles32)\dotnet\dotnet</RunCommand> </PropertyGroup> < /Project >
从 Visual Studio 2019 Developer Command Prompt v16.4.6,我导航到 .NET Core 应用程序的项目根目录。
我跑了:
> >
dotnet clean ........................... ............. dotnet build C:\Program Files\dotnet\sdk\3.1.101\Microsoft.Common.CurrentVersion.targets(2726,5): error MSB4216: Could not run the "ResolveComReference" task because MSBuild could not create or connect to a task host with runtime "CLR4" and architecture "x86". Please ensure that (1) the requested runtime and/or architecture are available on the machine, and (2) that the required executable "C:\Program Files\dotnet\sdk\3.1.101\MSBuild.exe" exists and can be run. [D:\ blah blah.csproj] 6 Warning(s) 1 Error(s) Time Elapsed 00:00:04.63'
谁能告诉我如何在 32 位环境中构建和运行这个应用程序?
【问题讨论】:
-
您确定在运行 dotnet build 的机器上安装了 .net Core 3.1 x86 SDK 吗? (dotnet.microsoft.com/download/dotnet-core/3.1)
-
您是否尝试过下载 x86 SDK 并使用它(不是 x64 SDK)来构建和发布网络应用程序?
标签: iis .net-core x86 msbuild 32-bit