【问题标题】:NuGet (non-)deployment of dll.config file in lib folder of System.Data.SQLite.Core Package?NuGet(非)部署 System.Data.SQLite.Core 包的 lib 文件夹中的 dll.config 文件?
【发布时间】:2020-06-28 07:44:44
【问题描述】:

问题

System.Data.SQLite的包作者将.dll.config文件打包成默认包含在输出目录中是什么意思(?)NuGet机制, 当同样在文件中添加注释时,您应该将文件复制到输出目录??

是否可以防止 NuGet/MSBuild/VisualStudio 将所述文件复制到输出目录?

也就是说,是否可以防止将来自nupkg\lib\net46 的“相关”文件复制到输出目录?

详情

System.Data.SQLite.Core NuGet 包包含System.Data.SQLite.dll 文件(除其他外),以​​及附加文件System.Data.SQLite.xmlSystem.Data.SQLite.dll.config

这三个文件位于nupkg 的所有\lib\<framework>\ 文件夹中。

因此,Visual Studio / MSBuild / NuGet 将这些文件复制到输出文件夹:

8>  Primary reference "System.Data.SQLite, Version=1.0.111.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139". (TaskId:102)
8>      Resolved file path is "c:\...\nuget\System.Data.SQLite.Core.1.0.111.0\lib\net46\System.Data.SQLite.dll". (TaskId:102)
8>      Reference found at search path location "{HintPathFromItem}". (TaskId:102)
8>      Found related file "c:\...\nuget\System.Data.SQLite.Core.1.0.111.0\lib\net46\System.Data.SQLite.xml". (TaskId:102)
8>      Found related file "c:\...\nuget\System.Data.SQLite.Core.1.0.111.0\lib\net46\System.Data.SQLite.dll.config". (TaskId:102)
...
8>          c:\kse\nuget\System.Data.SQLite.Core.1.0.111.0\lib\net46\System.Data.SQLite.dll.config
8>                  CopyLocal=true
8>                  FusionName=
8>                  HintPath=c:\...\nuget\System.Data.SQLite.Core.1.0.111.0\lib\net46\System.Data.SQLite.dll
8>                  OriginalItemSpec=c:\...\nuget\System.Data.SQLite.Core.1.0.111.0\lib\net46\System.Data.SQLite.dll
8>                  ResolvedFrom={HintPathFromItem}
8>                  Version=1.0.111.0

但是this file包含免责声明:

 * System.Data.SQLite.dll.config -
 *
 * WARNING: This XML configuration file is intended for use within the NuGet
 *          package directories only.  Please do not copy this file to any of
 *          the build output directories because it could interfere with the
 *          native library pre-loading feature.

--它不应该被复制。那么:我如何复制它?我应该关心吗?

注意System.Data.SQLite.dll.config seems to be better documented under a different path.

【问题讨论】:

标签: nuget app-config nuget-package-restore system.data.sqlite


【解决方案1】:

如果您使用 PackageReference 引用 NuGet 包,则可以使用 ExcludeAssets 属性将资产排除在导入项目中,如“控制依赖项资产”部分中的 here 所述。但是,这会排除一组资产,并且不允许控制单个文件,因此无法解决此问题。

除此之外,您可以使用自定义 MS Build 逻辑或尝试使用构建后事件删除 .config 文件,这两者在结果中都是相似的。

【讨论】:

    猜你喜欢
    • 2022-01-15
    • 1970-01-01
    • 2018-12-16
    • 2014-02-23
    • 1970-01-01
    • 2012-08-05
    • 1970-01-01
    • 2023-04-05
    • 1970-01-01
    相关资源
    最近更新 更多