79264315

Date: 2024-12-09 08:47:17
Score: 2
Natty:
Report link

I've been working on making our .NET Core app use app-local ICU to avoid future inconsistencies, following Microsoft's documentation. Here’s the relevant part of our .csproj file:

enter code here

<PackageReference Include="Microsoft.ICU.ICU4C.Runtime" Version="72.1.0.3" />
<InvariantGlobalization>true</InvariantGlobalization>
<ItemGroup>
<IcuAssemblies Include="icu\*.so*" />
<RuntimeTargetsCopyLocalItems Include="@(IcuAssemblies)" AssetType="native" 
 CopyLocal="true"
 DestinationSubDirectory="runtimes/linux-x64/native/"
 DestinationSubPath="%(FileName)%(Extension)"
 RuntimeIdentifier="linux-x64" NuGetPackageId="Microsoft.ICU.ICU4C.Runtime" />
</ItemGroup>
<ItemGroup>
<RuntimeHostConfigurationOption Include="System.Globalization.UseNls" 
 Value="false" />
<RuntimeHostConfigurationOption Include="System.Globalization.AppLocalIcu" 
 Value="72.1" />
</ItemGroup>

This setup works fine on Windows 10/11 and our build server running RHEL 9. However, when we deploy the app to Amazon Linux 2 (AL2), it crashes on startup. The journalctl log from systemd shows the following:

enter code here

 test-server.internal myApp[2736]: at MyApp.Program.Main(String[] args) in 
 MyApp\Program.cs:line 15
 test-server.internal systemd[1]: myApi.service: main process exited, 
 code=killed, status=6/ABRT
 test-server.internal systemd[1]: Unit myApi.service entered failed state.
 test-server.internal systemd[1]: myApi.service failed.

I also noticed other warnings/errors related to the systemd service file, but removing the ICU-related settings (RuntimeHostConfigurationOption) allows the app to run just fine. Here’s what I’ve already checked:

  1. The publish/runtimes/linux-x64/native directory contains the correct ICU files (libicuuc.so.72, libicudata.so.72, etc.).
  2. Running ldd on the .so files resolves all dependencies on AL2.
  3. Running the app manually (outside of systemd) still fails when using app-local ICU, so it doesn't seem like a systemd issue.
  4. I’ve confirmed the app works fine with the default ICU globalization settings on AL2. My systemd service file looks like this:

enter code here

[Unit]
Description=MyApp .NET Core WebApp
After=network.target
Wants=network.target

[Service]
WorkingDirectory=/path/to/app
ExecStart=/usr/bin/dotnet /path/to/app/MyApp.dll
Restart=always
RestartSec=10
Environment=ASPNETCORE_ENVIRONMENT=Training
Environment=ASPNETCORE_URLS=http://*:5000

[Install]
WantedBy=multi-user.target

Also I need to know What could cause the app to crash on Amazon Linux 2 with app-local ICU? and are there any extra steps or dependencies required for AL2 that aren’t mentioned in the Microsoft docs?

Reasons:
  • Blacklisted phrase (0.5): I need
  • Long answer (-1):
  • Has code block (-0.5):
  • Ends in question mark (2):
  • Low reputation (1):
Posted by: mohammad javad amin