简体   繁体   中英

What steps should I take to build and run .net core Web API application in 32-bit environment/runtime?

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)\dotnet\dotnet</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 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'

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

What steps should I take to build and run .net core Web API application in 32-bit environment/runtime?

It is quite strange. First , just as akseli and omajid said, try to install Net Core 3.1 x86 sdk version .

Then, try the following steps:

Steps

1) change build platform target to x86 in 32-bit environment.

2) when you migrate the project into 32-bit environment, please delete .vs hidden folder which exists under the solution folder, bin , obj folder.

3) open Developer Command Prompt for VS2019 in 32-bit environment(it call the msbuild.exe under C:\Program Files\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\MSBuild.exe ) to build your project.

4) try to use msbuild rather than dotnet build since MSBuild is more powerful and has a wider range of compilations.

msbuild xxx.csproj -t:build

msbuild xxx.csproj -t:clean

4) or add these node in your xxx.csproj file then build your project

<PropertyGroup Condition="'$(MSBuildRuntimeType)' == 'Core'">
  <GenerateResourceMSBuildArchitecture>CurrentArchitecture</GenerateResourceMSBuildArchitecture>
  <GenerateResourceMSBuildRuntime>CurrentRuntime</GenerateResourceMSBuildRuntime>
</PropertyGroup>

Any feedback will be expected.

@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": 在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM