【问题标题】:dotnet publish, contentFiles, and transitive nuget dependenciesdotnet publish、contentFiles 和传递性 nuget 依赖项
【发布时间】:2018-02-08 18:03:39
【问题描述】:

dotnet publish 是否可以将 contentFiles 复制到传递包依赖项的输出?

在这种情况下,我有三个项目:

  1. 内容,其 nuspec 包含:
<contentFiles>
  <files include="any/any/someContent.txt" buildAction="None" copyToOutput="true" flatten="false"/>
</contentFiles>
  1. Lib,其中有一个 PackageReference 到 Content nuget
  2. ConsoleApp,其中有一个 PackageReference 到 Lib nuget

Lib 项目在项目资源管理器中显示 contentFiles 并在构建时复制到输出,但 ConsoleApp 项目两者都没有。

我需要 dotnet publish ConsoleApp.csproj 在发布输出中包含来自 Content nuget 的 someContent.txt

一些与上下文相关的帖子:

【问题讨论】:

    标签: msbuild nuget .net-core


    【解决方案1】:

    contentFiles 默认为私有资产。您需要将引用中的PrivateAssets 元数据从Lib 更改为Content,使其不包含contentFiles,如下所示:

    <ProjectReference Include="...">
        <PrivateAssets>analyzers;build</PrivateAssets>
    </ProjectReference>
    

    更多信息在这里:https://docs.microsoft.com/en-us/nuget/consume-packages/package-references-in-project-files#controlling-dependency-assets

    【讨论】:

    • 这对这种情况有帮助吗? stackoverflow.com/q/65051835/227436我尝试实现设置,但似乎没有帮助。
    • 我认为应该。您是否将引用中的PrivateAssetsDLaB.Xrm.Source 更改为DLaB.Common.Source
    • 没有。我只包括内容
    • DLaB.Xrm.Source 项目中,您应该将引用更改为DLaB.Common.Source,如下所示:&lt;ProjectReference Include="path/to/DLaB.Common.Source.csproj" PrivateAssets="analyzers;build" /&gt;
    • 我的 DLaB.Xrm.Source 实际上是一个 .Net 项目,而不是 dotnetcore
    猜你喜欢
    • 2022-01-20
    • 2021-07-29
    • 2019-03-19
    • 1970-01-01
    • 1970-01-01
    • 2017-06-03
    • 2013-02-17
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多