MSBuild プロジェクト ファイルの ProjectReference で Private 設定を行うとどうなるのでしょうか? 質問する

MSBuild プロジェクト ファイルの ProjectReference で Private 設定を行うとどうなるのでしょうか? 質問する

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

<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 プロジェクト項目このページにはこの値は記載されていません。(ではなくPrivateの設定が記載されていますが、 、、 の設定があり、 true と false の設定はありません)ReferenceProjectReferenceNeverAlwaysPreserveNewest

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

ベストアンサー1

Privateアイテムのメタデータは、ProjectReferenceVisual Studio のソリューション エクスプローラーの参照ノードの [ローカルにコピー] プロパティに対応します。

参照を出力フォルダーにコピーするかどうかを制御します。

  • true参照をコピーする必要があることを意味します
  • false参照をコピーしてはならないことを意味する

これは文書化されている一般的な MSBuild プロジェクト項目、およびMSBuildソース自体Microsoft.Common.CurrentVersion.targets:

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

                  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.

============================================================
-->

おすすめ記事