DocumentFormat.OpenXml Nuget 包有很多依赖项,例如 Microsoft.NetCore.Platforms

DocumentFormat.OpenXml Nuget package have many dependencies like Microsoft.NetCore.Platforms

我正在我的应用程序中做一些 Ms excel 自动化,但是在轮询 DocumentFormat.OpenXml Nuget 包时,许多依赖项随之下载,例如:

尽管我的目标是 .Net 框架而不是 .Net 核心或标准,但还有很多其他的。事实上,我的 class 图书馆项目中不需要那些额外的参考资料。为什么要安装这些依赖项?他们是否有任何方法只允许下载没有这些依赖项的指定包?

Why those dependencies were installed? and is their any method that allows download only the specified package without those dependencies?

这是nuget包本身的问题。当您检查包在 nuget.org 上的依赖项时:

我们可以知道包向 .net framework 项目添加了错误的依赖项 (.NET Standard 1.3)。

我曾经在 github 上报告过 similar issue

要解决此问题,您可以使用版本 2.7.2 而不是 2.8.1 或只删除那些额外的引用。

注意:为了最终解决这个问题,我们需要将这个问题报告给作者并等待作者更新这个包:

https://github.com/OfficeDev/Open-XML-SDK/issues

希望对您有所帮助。