commandlineparser / commandlineparser/commandline
.NET 7 (RC1) trimming results in error
- 主要語言
- C#
- 星號
- 4.8k
- 分支
- 478
- PR 合併指標
- 30 天內沒有已合併 PR
描述
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.
貢獻指南
這個儲存庫沒有索引到貢獻指南
研究方向
使用 .NET 7 和提供的 dotnet publish 命令重現該故障,然後將其與停用 trimming 以及 TrimMode=partial 的情況進行比較。閱讀連結的 trimming 指南,並檢查該程式庫如何處理會產生錯誤的選項。當啟用 trimming 的發佈能夠執行且不再出現設定選項時回報的錯誤,同時保留正常的命令列行為時,即視為完成。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- csharp
- 領域
- cli
- Issue 類型
- 缺陷
- 難度
- 4/5
- 預估耗時
- 3-5 天
- 活躍度
- 停滯
- 描述清晰度
- 基本清楚
- 新手友好度
- 38/100