commandlineparser / commandlineparser/commandline
.NET 7 (RC1) trimming results in error
- Langage dominant
- C#
- Étoiles
- 4.8k
- Forks
- 478
- Métriques de merge des PR
- Aucune PR mergée en 30 j
Description
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.
Guide de contribution
Aucun guide de contribution indexé pour ce dépôt
Piste de recherche
Reproduisez l’échec avec la commande dotnet publish fournie en utilisant .NET 7, puis comparez-le avec le trimming désactivé et TrimMode=partial. Lisez les instructions de trimming liées et examinez la manière dont la bibliothèque gère les options qui produisent des erreurs. Le travail est terminé lorsque la publication avec trimming s’exécute sans les erreurs signalées lors de la définition des options, tout en préservant le comportement normal de la ligne de commande.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- csharp
- Domaine
- cli
- Type d'issue
- Bug
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Activité
- À l'abandon
- Clarté
- Plutôt claire
- Accessibilité débutants
- 38/100