web-dev-qa-db-ja.com

MSBuildプロジェクトファイルのProjectReferenceでプライベート設定は何をしますか?

先日、プロジェクトファイルでこれを見ました。

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

ProjectReferenceのすべてのノードは、Privateを除き、自明です(参照プロジェクトファイル、GUID、ソリューションエクスプローラーに表示する名前、および現在のプロジェクトを参照プロジェクトにリンクするかどうか) 、および 一般的なMSBuildプロジェクト項目 ページにはこの値が記載されていません。 (PrivateではなくReferenceについて文書化されたProjectReference設定がありますが、NeverAlways、およびPreserveNewest設定があり、trueではありません。およびfalse)

この設定は何をしますか?

92
Billy ONeal

Privateタグは、Visual Studio Referencesフォルダーの[ローカルのコピー]チェックボックスへのユーザーオーバーライドを維持します。これは、GACから参照を使用するか、参照先のアセンブリをビルドディレクトリにコピーするかを制御します。

この効果に関するMSDNドキュメントは見つかりませんが(驚き)、動作と が適用されているMicrosoft.Common.CurrentVersion.targets:1742 のコメントから明らかです。

これは、 MSDN>一般的なMSBuildプロジェクト項目 に記載されており、動作と 適用されているMicrosoft.Common.CurrentVersion.targets:1742 のコメントから明らかです。 :

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

                                        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.
    ============================================================
    -->
106
Mitch