我已经在Visual Studio 2017中针对ASP.NET Core 2.2.8 Runtime构建并发布了ASP.NET Core应用程序。当我将(xcopy)部署到RedHat并尝试在Kestrel中运行时,出现以下错误:
Unhandled Exception: System.BadImageFormatException: Could not load file or assembly 'Microsoft.AspNetCore.Server.Kestrel.Core, Version=2.2.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The module was expected to contain an assembly manifest.
这是我的.csproj文件中的内容:
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
<Platforms>x64</Platforms>
<MicrosoftNETPlatformLibrary>Microsoft.NETCore.App</MicrosoftNETPlatformLibrary>
</PropertyGroup>
<ItemGroup>
<Content Update="appsettings.json;web.config">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.App" Version="2.2.8" />
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.2.8" />
<PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.2.0" PrivateAssets="All" />
</ItemGroup>
<ItemGroup>
<PackageReference Update="Microsoft.NETCore.App" Version="2.2.8"/>
</ItemGroup>
</Project>
我在RedHat文档中发现RedHat不提供ASP.NET Core 2.2 Hosting Bundle。相反,RedHat建议执行自包含的构建并将所有文件(大约400个)复制到您的应用程序文件夹中。 RedHat通过将Hosting Bundle包含在.NET Core RPM中,用3.0解决了这一问题。
ASP.NET Core共享框架在RHEL上不可用。部署的ASP.NET Core应用程序必须包括ASP.NET Core软件包。
https://access.redhat.com/documentation/en-us/net_core/2.2/html/release_notes_for_rpms/known_issues