MSBuild ProjectReference:private(“Copy Local”) - 允许的值和行为是什么?
TL; DR是否有任何官方文档详细描述<private>
/“Copy Local”选项如何工作与MSBuild?那么应该考虑哪些价值呢?MSBuild ProjectReference:private(“Copy Local”) - 允许的值和行为是什么?
当你add a project reference从Visual Studio中一个又一个项目,这将增加一个<ProjectReference Include=".....csproj">
到.csproj
的MSBuild文件。
当您将add a file reference从Visual Studio中的一个项目添加到文件系统中的程序集文件时,它会将<Reference Include="Foo"> <HintPath>....Foo.dll</HintPath> ...
添加到.csproj
MSBuild文件中。
在两种箱子,为Visual Studio的设置Copy Local = True|False
,一个子元素<Private>True</Private>
或<Private>False</Private>
将增加。
Reference
和ProjectReference
似乎下进行记录:
<ProjectReference> Represents a reference to another project. Item Name Description ------------------------- Name ... Project ... Package ... <Reference> Represents an assembly (managed) reference in the project. Item Name Description -------------------------- HintPath Optional string. Relative or absolute path of the assembly. Name ... ... Private Optional string. Determines whether to copy the file to the output directory. Values are: 1. Never 2. Always 3. PreserveNewest
你会注意到,
-
ProjectReference
完全不
记录的
-
Reference
未列出True
或False
作为可能的值。
<private>
项目
所以,咦?是否有任何官方文档(我会比较满意博客条目),详细描述<private>
选项的工作原理? 文档只是死了错,还是有更多的东西?
实例从我的VS 2013快片断这里:
...
<ItemGroup>
<Reference Include="ClassLibrary2">
<HintPath>C:\Somewhere\ClassLibrary2.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
...
<ItemGroup>
<ProjectReference Include="..\ClassLibrary1\ClassLibrary1.csproj">
<Project>{861dd746-de2e-4961-94db-4bb5b05effe9}</Project>
<Name>ClassLibrary1</Name>
<Private>False</Private>
</ProjectReference>
...
参考,ProjectReference项目,为私人所接受的值是:真或假
此属性的MSBuild与对应VS中的项目引用属性为“复制本地”。
我通过在VS中手动设置参考属性并查看xml得到了上述答案。我找不到私人项目元数据的官方文档。
检查文档https://msdn.microsoft.com/en-us/library/bb629388.aspx将接受的值显示为Never,Always和PreserveNewest。这些似乎是错误的,只适用于内容,无和其他文件项目上使用的CopyLocal元数据。
有趣的一点(仍然无法找到确切的问题)。唯一一个我发现的地方,那里使用私有值是Microsoft.Common中的第3612行。targets =''(@ MSBuildProjectReferenceExistent)'!=''和'$(_ GetChildProjectCopyToOutputDirectoryItems)'=='true'和'% 'true'“ – 2014-10-08 10:04:18
或者,也许这个元数据也正在转换为MSBuild任务中更常见的”CopyLocal“ - 我不确定我想要反编译并逐一扫描它们。 无论如何,我同意 - 这是没有文档,没有太多关于它的信息在.targets文件中给出... – 2014-10-08 10:09:14
@AlexeyShcherbak - 感谢您的信息。我试图编辑一下,以便在这里有一个实际的问题:-) – 2014-10-08 10:10:49