Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

.NET 7 (RC1) trimming results in error

未关闭
#848 16 条评论 7 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
38/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
csharp
领域
cli

调研方向

使用 .NET 7 和提供的 dotnet publish 命令重现该故障,然后将其与禁用 trimming 以及 TrimMode=partial 的情况进行比较。阅读链接的 trimming 指南,并检查该库如何处理会产生错误的选项。当启用 trimming 的发布能够运行且不再出现设置选项时报告的错误,同时保留正常的命令行行为时,即视为完成。

由索引模型根据 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.

主要语言
C#
星标
4.8k
派生
478
PR 合并指标
30 天内没有已合并 PR

环境准备

我们还没有检查这个项目的环境配置文件。先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

commandlineparser/commandline 的其他 Issue

查看 commandlineparser/commandline 的全部 Issue

相似的 Issue

更多 C# Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。