MSBuild ProjectReference:私有(“复制本地")-允许的值和行为是什么? [英] MSBuild ProjectReference:private ("Copy Local") - what are the allowed values and behaviour?

查看:382
本文介绍了MSBuild ProjectReference:私有(“复制本地")-允许的值和行为是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

TL; DR 是否有任何正式文档详细描述<private>/本地复制"选项与MSBuild 一起工作的方式?以及应该包含哪些价值?

TL;DR Is there any official documentation that describes in detail how the <private> / "Copy Local" option works with MSBuild? And what values are supposed to go into it?

添加项目参考从Visual Studio中的一个项目到另一个项目,它将在.csproj MSBuild文件中添加一个<ProjectReference Include=".....csproj">.

When you add a project reference from one project in Visual Studio to another, it will add a <ProjectReference Include=".....csproj"> to the .csproj MSBuild file.

添加文件参考从Visual Studio中的一个项目到文件系统中的程序集文件,它将在.csproj MSBuild文件中添加一个<Reference Include="Foo"> <HintPath>....Foo.dll</HintPath> ....

When you add a file reference from one project in Visual Studio to an assembly file in the file system, it will add a <Reference Include="Foo"> <HintPath>....Foo.dll</HintPath> ... to the .csproj MSBuild file.

在两种情况下,对于Visual Studio设置Copy Local = True|False,将添加子元素<Private>True</Private><Private>False</Private>.

In both cases, for the Visual Studio Setting Copy Local = True|False, a sub-element <Private>True</Private> or <Private>False</Private> will be added.

ReferenceProjectReference似乎记录在常见的MSBuild项目项:

<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

您会注意到,

  1. ProjectReference 根本没有记录 <private>项目
  2. Reference 不会列出 TrueFalse作为可能的值.
  1. ProjectReference doesn't document the <private> Item at all
  2. Reference does not list Trueor False as possible values.

所以.是吗?是否有任何正式文档(我会很高兴有一个好的博客文章)详细描述<private>选项的工作原理? 文档是完全错误的还是其他内容?

So. Huh? Is there any official documentation (I'll be more than happy with a good blog entry) that describes in detail how the <private> option works? Are the doc's just dead wrong or is there something more to it?

我的VS 2013 Express的示例代码片段在这里:

Example snippet from my VS 2013 Express here:

...
  <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>
...

推荐答案

对于Reference和ProjectReference项目,Private的接受值为:True或False

For Reference and ProjectReference items, the accepted values for Private are: True or False

msbuild中的此属性与VS中作为复制本地"的项目引用属性相对应.

This property in msbuild corresponds with the project reference property in VS as Copy Local.

通过在VS中手动设置参考属性并查看xml,我得到了以上答案.我找不到私人物品元数据的官方文档.

I got the above answer by manually setting the reference properties in VS and viewing the xml. I couldn't find official documentation of the Private item metadata.

> https://msdn.microsoft.com/en-us/library/bb629388上检查文档.aspx 将接受的值显示为Never,Always和PreserveNewest.这些似乎是错误的,仅适用于用于Content,None和其他文件项的CopyLocal元数据.

Checking the docs at https://msdn.microsoft.com/en-us/library/bb629388.aspx shows the accepted values as Never, Always, and PreserveNewest. These seem to be wrong and only available for the CopyLocal metadata, which is used on Content, None, and other file items.

这篇关于MSBuild ProjectReference:私有(“复制本地")-允许的值和行为是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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