为什么“复制到输出目录”的语句选择改变位置? [英] Why does the verbiage for the "Copy to Output Directory" selection change between locations?

查看:668
本文介绍了为什么“复制到输出目录”的语句选择改变位置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

VS.NET中的解决方案资源管理器与 .csproj 文件中的预计值之间的配置值语法不一致。在解决方案资源管理器 a .config 或依赖文件将有多个选项

There is an inconsistency in the configuration value verbiage between Solution Explorer in VS.NET and the projected value within the .csproj file. In Solution Explorer a .config or dependency file will have multiple options in the Copy To Output Directory property that affect its build and deploy characteristics.

复制到输出目录 dropdown我选择了一个.config文件的选项:复制如果新的。但是在 .csproj 文件中设置为 PreserveNewest ,如下所示:

In the Copy To Output Directory dropdown I have selected the option for a .config file: Copy if newer. However in the .csproj file it is set as PreserveNewest as seen below:

<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>

我假设可以得出结论,因为它是(2)不同的地方,术语是不同的感。我还可以看到在 XML 文件中不允许使用空格,但是我仍然可能会看到类似下面的内容。

I suppose the conclusion can be made that since it is (2) different places the terminology being different makes sense. I also could see where the 'spaces' would not be allowed in the XML file, but then I still might expect to see something like the following.

<CopyToOutputDirectory>CopyIfNewer</CopyToOutputDirectory>

有没有在MSDN中定义的地方,以及这些友好名称如何映射到他们的物理配置值在 .csproj 文件中?

Is there somewhere that this is defined in the MSDN and how these 'friendly names' map to their physical configured value within the .csproj file?

推荐答案

没有这样的地方,你可以找到像这样的映射。但是,自动化和可扩展性参考可以清除一些问题。

I think there is no such place where you can find the mapping like this. However, Automation and Extensibility Reference can clear some things up.

例如,您可以看到FileProperties2接口有CopyToOutputDirectory属性,该属性接受 __ COPYTOOUTPUTSTATE 枚举值:

For example, you can see that FileProperties2 interface has CopyToOutputDirectory property and that the property accepts __COPYTOOUTPUTSTATE enumeration values:


  • COPYTOOUTPUTSTATE_Never = 0

  • COPYTOOUTPUTSTATE_Always = 1

  • COPYTOOUTPUTSTATE_PreserveNewestFile = 2

如果复制如果新的 UI值,则 PreserveNewest 是唯一的选项。

Here you can see that PreserveNewest is the only option that fits the Copy if newer UI value.

我的观点是:如果你对可能的选项有疑问,你总是可以在自动化引用中检查它,然而,我个人只使用它来编写NuGet powershell脚本来修改代码中的msbuild文件。最简单的方法是在UI中设置值,然后看到我们在msbuild文件中。

My point is: if you have doubts about possible options you always can check it in the automation reference, however, I personally use it only writing NuGet powershell scripts that modifies msbuild files in code. The simplest way is set the value in UI and see that we've got in msbuild file after that.

这篇关于为什么“复制到输出目录”的语句选择改变位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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