commandlineparser / commandlineparser/commandline
.NET 7 (RC1) trimming results in error
- Linguagem predominante
- C#
- Estrelas
- 4.8k
- Forks
- 478
- Métricas de merge de PRs
- Nenhum PR com merge em 30d
Descrição
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.
Guia de contribuição
Nenhum guia de contribuição indexado para este repositório
Direção de pesquisa
Reproduce the failure with the provided dotnet publish command using .NET 7, then compare it with trimming disabled and TrimMode=partial. Read the linked trimming guidance and inspect how the library handles the options that produce errors. Done means trimmed publishing runs without the reported option-setting errors while preserving normal command-line behavior.
Escrita pelo modelo de indexação a partir do texto da issue.
Avaliação
- Stack de tecnologia
- csharp
- Domínio
- cli
- Tipo de issue
- Bug
- Dificuldade
- 4/5
- Tempo estimado
- 3-5 dias
- Status de atividade
- Estagnada
- Clareza
- Razoavelmente clara
- Facilidade para iniciantes
- 38/100