私有设置对 MSBuild 项目文件中的 ProjectReference 有何作用? [英] What does the Private setting do on a ProjectReference in a MSBuild project file?

查看:24
本文介绍了私有设置对 MSBuild 项目文件中的 ProjectReference 有何作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我前几天在一个项目文件中看到了这个:

I saw this in a project file the other day:

<ProjectReference Include="Foo\Bar\Baz.csproj">
    <Project>{A GUID HERE}</Project>
    <Name>Baz</Name>
    <Private>False</Private> <!-- ??? -->
    <ReferenceOutputAssembly>False</ReferenceOutputAssembly>
</ProjectReference>

ProjectReference 中的每个节点似乎都是不言自明的(引用的项目文件、GUID、在解决方案资源管理器中显示的名称,以及当前项目是否应链接到引用的项目)除了 Private常见 MSBuild 项目项 页面没有记录这个值.(为 Reference 而不是 ProjectReference 记录了一个 Private 设置——但它有 NeverAlwaysPreserveNewest 设置,非真假)

Every node in a ProjectReference appears to be self explanatory (the referenced project file, GUID, name to show in the solution explorer, and whether or not the current project should link to the referenced project) except Private, and the Common MSBuild Project Items page doesn't document this value. (There's a Private setting documented for Reference rather than ProjectReference -- but it has Never, Always, and PreserveNewest settings, not true and false)

这个设置有什么作用?

推荐答案

Private 标记维护对 Visual Studio 引用文件夹中复制本地"复选框的用户覆盖.这控制是使用来自 GAC 的引用还是将引用的程序集复制到构建目录.

The Private tag maintains the user-override to the "Copy Local" checkbox in the Visual Studio References folder. This controls whether the reference is used from the GAC or whether it will copy the referenced assembly to the build directory.

虽然我找不到任何与此相关的 MSDN 文档(令人惊讶),但从行为和 来自Microsoft.Common.CurrentVersion.targets:1742应用它的地方:

这记录在 MSDN > 常见 MSBuild 项目项,从行为和 来自 Microsoft.Common.CurrentVersion.targets:1742 中的注释:

This is documented in MSDN > Common MSBuild project items, and is evident from behavior and from the comment in Microsoft.Common.CurrentVersion.targets:1742 where it is applied:

  <!--
    ============================================================

                                        ResolveAssemblyReferences

    Given the list of assemblies, find the closure of all assemblies that they depend on. These are
    what we need to copy to the output directory.

        [IN]
        @(Reference) - List of assembly references as fusion names.
        @(_ResolvedProjectReferencePaths) - List of project references produced by projects that this project depends on.

            The 'Private' attribute on the reference corresponds to the Copy Local flag in IDE.
            The 'Private' flag can have three possible values:
                - 'True' means the reference should be Copied Local
                - 'False' means the reference should not be Copied Local
                - [Missing] means this task will decide whether to treat this reference as CopyLocal or not.

        [OUT]
        @(ReferencePath) - Paths to resolved primary files.
        @(ReferenceDependencyPaths) - Paths to resolved dependency files.
        @(_ReferenceRelatedPaths) - Paths to .xmls and .pdbs.
        @(ReferenceSatellitePaths) - Paths to satellites.
        @(_ReferenceSerializationAssemblyPaths) - Paths to XML serialization assemblies created by sgen.
        @(_ReferenceScatterPaths) - Paths to scatter files.
        @(ReferenceCopyLocalPaths) - Paths to files that should be copied to the local directory.
    ============================================================
    -->

这篇关于私有设置对 MSBuild 项目文件中的 ProjectReference 有何作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆