When a dotnet is published with -p:PublishTrimmed=true parameter the App fails to start with below error,
Unhandled exception. System.IO.FileNotFoundException: Could not load file or assembly 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. The system cannot find the file specified.
File name: 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
at Microsoft.Extensions.Hosting.GenericHostWebHostBuilderExtensions.ConfigureWebHost(IHostBuilder builder, Action`1 configure)
at Microsoft.Extensions.Hosting.GenericHostBuilderExtensions.ConfigureWebHostDefaults(IHostBuilder builder, Action`1 configure)
at API.Program.CreateHostBuilder(String[] args) in /src/API/Program.cs:line 17
at API.Program.Main(String[] args) in /src/API/Program.cs:line 13
The terminal process "C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe -Command docker run --rm -it -p 5000:5000/tcp api:latest" terminated with exit code: 1.
Steps to reproduce the behavior:
- Run the app using publish command and flag
-p:PublishTrimmed=false
dotnet publish "Exchange.Ingestion.API.csproj" -c Release -o /app/publish -p:PublishTrimmed=false
This will run the app without any issues.
- Run the app using publish command and flag
-p:PublishTrimmed=true
dotnet publish "Exchange.Ingestion.API.csproj" -c Release -o /app/publish -p:PublishTrimmed=true
App will fail to start with error,
Unhandled exception. System.IO.FileNotFoundException: Could not load file or assembly 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. The system cannot find the file specified.
File name: 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
at Microsoft.Extensions.Hosting.GenericHostWebHostBuilderExtensions.ConfigureWebHost(IHostBuilder builder, Action`1 configure)
at Microsoft.Extensions.Hosting.GenericHostBuilderExtensions.ConfigureWebHostDefaults(IHostBuilder builder, Action`1 configure)
at API.Program.CreateHostBuilder(String[] args) in /src/API/Program.cs:line 17
at API.Program.Main(String[] args) in /src/API/Program.cs:line 13
The terminal process "C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe -Command docker run --rm -it -p 5000:5000/tcp api:latest" terminated with exit code: 1.
Expected behavior
App should start to run and trace logs.
Runtime environment:
- Instrumentation mode: auto
- Tracer version: 1.26.3
- OS: Containarised with
mcr.microsoft.com/dotnet/sdk:5.0.102-1-alpine3.12-amd64
- CLR: .NET CORE 5
Additional context
When a dotnet is published with
-p:PublishTrimmed=trueparameter the App fails to start with below error,Steps to reproduce the behavior:
.Net 5 console app with dd-trace-dotnet library Version 1.26.3.
-p:PublishTrimmed=falsedotnet publish "Exchange.Ingestion.API.csproj" -c Release -o /app/publish -p:PublishTrimmed=falseThis will run the app without any issues.
-p:PublishTrimmed=truedotnet publish "Exchange.Ingestion.API.csproj" -c Release -o /app/publish -p:PublishTrimmed=trueApp will fail to start with error,
Expected behavior
App should start to run and trace logs.
Runtime environment:
mcr.microsoft.com/dotnet/sdk:5.0.102-1-alpine3.12-amd64Additional context