简体   繁体   English

C#汇编-快捷方式

[英]C# assembly - shortcuts

I have a C# project that has multiple folders: Folder1, Folder2. 我有一个C#项目,其中包含多个文件夹:Folder1,Folder2。

I added a shortcut in 'Folder1' to an xml file that is already in 'Folder2'. 我在“ Folder1”中向已经在“ Folder2”中的xml文件添加了快捷方式。 In this case when I compile the project the xml file will I have two copies in the assembly? 在这种情况下,当我编译项目时,xml文件中的程序集中会有两个副本吗?

You were not clear with your description - did you reference the file with a shortcut , or did you add it to Folder1 by using the VS Solution Explorer and adding an existing item as a link? 您不清楚您的描述-您是否使用快捷方式引用了该文件,还是通过使用VS解决方案资源管理器并将现有项添加为链接将其添加到Folder1?

The two methods are quite different. 两种方法完全不同。 If you simply went into the filesystem and added a shortcut, then that is not automatically part of the project unless you specifically add it. 如果您只是进入文件系统并添加了快捷方式,那么除非您专门添加它,否则它不会自动成为项目的一部分。 And if you did add it, then it obviously can't be compiled, the best you could do is just have it set to No Compile and copy to the output directory. 而且,如果确实添加了它,则显然无法对其进行编译,最好的办法就是将其设置为“不编译”并复制到输出目录。

If you added the file to folder one via the VS solution explorer and added it as a link, then it will be part of the project, and will be included twice, but it will be placed in Folder1 under the bin/debug or bin/release folder upon building. 如果您通过VS解决方案资源管理器将文件添加到文件夹1并将其添加为链接,则该文件将成为项目的一部分,并包含两次,但是将其放置在Folder / debug或bin /下的Folder1中。在构建时释放文件夹。 There will be no clash because they are in different folders, and they are not compiled, simply copied to the folder structure under the output directory. 不会发生冲突,因为它们位于不同的文件夹中,并且不会进行编译,只需将它们复制到输出目录下的文件夹结构中即可。

Edit: and it won't be part of the assembly unless you set it to be a Resource or Embedded Resource. 编辑:它将不属于程序集,除非您将其设置为资源或嵌入式资源。 If you do that then yes, it will be in the assembly, but under two different resource paths. 如果这样做,那么它将在程序集中,但是在两个不同的资源路径下。

在解决方案资源管理器中选定文件的属性(上下文菜单)中,将“生成操作”属性更改为“不编译”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM