question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

.NET 7 (RC1) trimming results in error

See original GitHub issue

I’ve just upgraded my project to .NET 7 and seen that it results in an error (when running):

Error setting value to option 'u, url': Check if Option or Value attribute values are set properly for the given type.
Error setting value to option 't, threads': Check if Option or Value attribute values are set properly for the given type.
etc..

https://github.com/KoalaBear84/OpenDirectoryDownloader/

If I build it with the following it fails (when running):

dotnet publish OpenDirectoryDownloader --configuration Release --framework net7.0 --runtime win-x64 -p:PublishTrimmed=true

If I remove the -p:PublishTrimmed=true it works. This tells me it could be because of the trimming that will trim something that is important for this library.

Also tried with -p:TrimMode=Link and -p:TrimMode=CopyUsed, but it doesn’t make a difference, but found out that -p:TrimMode=partial (Only worked with a lowercase p here) does, as it restores the behaviour of .NET 6.

https://learn.microsoft.com/en-us/dotnet/core/deploying/trimming/trimming-options?pivots=dotnet-7-0#trimming-granularity

Maybe this can be resolved at the library side, but I don’t have experience with that. https://learn.microsoft.com/en-us/dotnet/core/deploying/trimming/prepare-libraries-for-trimming

It would be nice if it can be solved, as more users will try/upgrade to .NET 7. Until then this issue will be helpful for everyone looking for a quick workaround.

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:4
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

4reactions
dermoench42commented, Apr 10, 2023

Tell the code-analyser to create all members of the options by an attribute (CliOptions is my options class):

[DynamicDependency(DynamicallyAccessedMemberTypes.All, typeof(CliOptions))] public static int Main( string[] args){ …

would fix that. Could that be set up somewhere inside commandLineParser?

0reactions
ericnewton76commented, Mar 7, 2023

Can somebody work up a DotNetFiddle for this? fork from https://dotnetfiddle.net/mh9CjX

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error when using auth with prerendering after trimming
NET 7 RC1 where, after trimming the app for production, I run into this error: crit: Microsoft.AspNetCore.Components.WebAssembly.Rendering.
Read more >
Performance Improvements in .NET 7
NET 7 is fast. Really fast. This post deep-dives into hundreds of performance improvements that contributed to that reality.
Read more >
Getting "NETSDK1045 The current .NET SDK does not ...
I had installed .NET 7, but this error happened every time I tried to run it. The issue was resolved after I updated...
Read more >
NET 7 Feature Breakdown Of The WebAssembly Build Tool
The .NET WebAssembly build tool is used to compile .NET code to WebAssembly (WASM) and other runtime features.
Read more >
.NET 7 Native.AOT, Trimming and Data Access : r/dotnet
I've been experimenting with .NET 7 Native.AOT for deploying trimmed micro-services to AWS Lambda/API Gateway, The results have been ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found