我应该采取哪些步骤在 32 位环境/运行时构建和运行 .net core Web API 应用程序? [英] What steps should I take to build and run .net core Web API application in 32-bit environment/runtime?

查看:14
本文介绍了我应该采取哪些步骤在 32 位环境/运行时构建和运行 .net core Web API 应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们使用以下技术开发了一个 .NET Core Web API 应用程序:

-NET 核心 (3.1)

-Visual Studio 2019

不幸的是,我们必须将上述应用程序部署到以下环境:

-32 位环境

-Windows Server 2008 R2 企业版(Service Pack 1)

-IIS 7.5 版

-8 GB 内存

因此,在我的 Visual Studio 2019 中,我启动了该应用程序,并采取了以下步骤:

在 VS 中强制 x86 转到属性 > 构建并将平台目标从任何 CPU 更改为 x86

在.NET Core应用程序的Project根目录下创建一个Directory.Build.targets:

<块引用>

<物业集团条件="'$(OS)' == 'Windows_NT' 和'$(PlatformTarget)' == 'x86' 和'$(TargetFrameworkIdentifier)' == '.NETCoreApp' 和'$(SelfContained)' != 'true'"><RunCommand>$(MSBuildProgramFiles32)dotnetdotnet</RunCommand></PropertyGroup></项目>

从 Visual Studio 2019 Developer Command Prompt v16.4.6,我导航到 .NET Core 应用程序的项目根目录.

我跑了:

>>

<块引用>

dotnet clean………………………………………………………………………………………………………………………………………………………………………………网络构建C:程序Filesdotnetsdk3.1.101Microsoft.Common.CurrentVersion.targets(2726,5):错误 MSB4216:无法运行ResolveComReference"任务,因为MSBuild 无法创建或连接到具有运行时CLR4"的任务主机和架构x86".请确保 (1) 请求的运行时和/或架构在机器上可用,并且 (2)所需的可执行文件C:Program Filesdotnetsdk3.1.101MSBuild.exe"存在并且可以运行.[D: blah blah.csproj]6 警告1 错误已用时间 00:00:04.63'

谁能告诉我如何在 32 位环境中构建和运行这个应用程序?

解决方案

@akseli @omajid @perry-qian-msft @yongqing-yu 抱歉,这不起作用,我们不得不放弃使用 .NET核心技术(不得不迁移到 .NET Framework 4.7.2),因为它会正常工作一段时间,然后给我们 500 错误,然后是一些 401 错误. 我认为它有一些东西使用配置,因为我们正在使用:

-NET 核心 (3.1)

-在 IIS 服务器中的进程内

因此,在独立的 IIS 服务器中,我们不应该在它自己的应用程序池中运行 .NET Core (3.1) 应用程序作为非托管代码",因为它都是进程内和 .NET Core (3.1) 可以在 IIS 上运行.无论如何,我们没有时间解决这个问题,所以我们迁移到 .NET Framework 4.7.2

@akseli @omajid @perry-qian-msft @yongqing-yu 谢谢大家的回复.我的团队技术主管通过在 Visual Studio 2019 中将 .NET Core Web API 应用程序的构建设置指定为任何 CPU"找到了解决方案.(在 Visual Studio 2019 中,右键单击 .NET Core Web API 应用程序,然后从下拉上下文菜单,然后当窗口窗格出现时,您选择构建选项卡.)

此外,在 IIS 服务器上,我的团队技术主管确保部署的 .NET Core Web API 应用程序的应用程序池具有以下设置(重要的是要记住它是非托管代码":

We developed an a .NET Core Web API application using the following technologies:

-NET Core (3.1)

-Visual Studio 2019

Unfortunately, we have to deploy said application to the following environment:

-32-bit Environment

-Windows Server 2008 R2 Enterprise (Service Pack 1)

-IIS Version 7.5

-8 GB RAM

Therefore, within my Visual Studio 2019, I brought up the application, and took the following steps:

Force x86 in VS go to the Properties > Build and change Platform target from Any CPU to x86

Created a Directory.Build.targets in the the .NET Core application's Project root directory:

<Project>

      <PropertyGroup

      Condition="'$(OS)' == 'Windows_NT' and

                 '$(PlatformTarget)' == 'x86' and

                 '$(TargetFrameworkIdentifier)' == '.NETCoreApp' and

                 '$(SelfContained)' != 'true'"

                  >

       <RunCommand>$(MSBuildProgramFiles32)dotnetdotnet</RunCommand>

      </PropertyGroup>

< /Project >

From Visual Studio 2019 Developer Command Prompt v16.4.6, I navigated to the .NET Core application's Project root directory.

I ran:

> >

dotnet clean
...........................
.............

dotnet build


C:Program
Filesdotnetsdk3.1.101Microsoft.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 Filesdotnetsdk3.1.101MSBuild.exe"
exists and can be run.
[D: blah blah.csproj]
    6 Warning(s)
    1 Error(s)

Time Elapsed 00:00:04.63'

Could someone please tell me how I can build and run this application in a 32-bit environment?

解决方案

@akseli @omajid @perry-qian-msft @yongqing-yu Sorry, this failed to work, we had to move away from using .NET Core technology( and had to migrate over to .NET Framework 4.7.2) because it would work properly for a little while, and then give us 500 error, and then later some 401 error. I think it has something to do with the configuration because we are using:

-NET Core (3.1)

-In-Process within IIS Server

therefore, Within the standalone IIS Server, we should Not have to run the .NET Core (3.1) application within it's own application pool as "Not Managed Code" because it's all In-Process and .NET Core (3.1) can run on IIS. In any case, we do Not have time to resolve this problem so we migrate over to .NET Framework 4.7.2

@akseli @omajid @perry-qian-msft @yongqing-yu All Thank you for all your responses. My Team Tech Lead found the solution by specifying the .NET Core Web API Application's Build Settings to "Any CPU" Within Visual Studio 2019. ( Within Visual Studio 2019, Right-click on .NET Core Web API Application, and then choose properties from the drop-down context menu, and then when the window pane shows up on, you select the Build Tab. )

Also, on the IIS Server, my Team Tech Lead ensured that that deployed .NET Core Web API Application's Application pool had the following settings( important to keep in mind that it is "Not Managed Code":

这篇关于我应该采取哪些步骤在 32 位环境/运行时构建和运行 .net core Web API 应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆