visual-studio 将文件从一个 Visual Studio 解决方案移动到另一个
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2189586/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Moving files from one Visual Studio solution to another
提问by Berryl
What I usually do is create a new file in the solution where I want to use it (same name), copy & paste the contents of a class from the source solution to the target, fix the namespace & imports as needed.
我通常做的是在要使用它的解决方案中创建一个新文件(同名),将类的内容从源解决方案复制并粘贴到目标,根据需要修复命名空间和导入。
The only other way I know to do it is open the source file in the target solution and then just save a copy into that folder, which can get confusing with two files open with the same name in one solution.
我知道的唯一另一种方法是在目标解决方案中打开源文件,然后将副本保存到该文件夹中,这可能会与在一个解决方案中打开的两个同名文件混淆。
Does anyone have an easier way to do this?
有没有人有更简单的方法来做到这一点?
回答by Jay
You can just copy and paste the files themselves.
您可以自己复制和粘贴文件。
When you have your solution open, look at the top of the solution explorer and you'll see an icon that looks like a page with a page outline behind it and a yellow page (not a very intuitive icon). This is the "show all files" button. Click that and you'll see all the files in your currently selected project (it is project-specific). Highlight any files that you want to include, right-click, and select "Include in Project."
当您打开解决方案时,查看解决方案资源管理器的顶部,您会看到一个图标,看起来像一个页面,后面有一个页面轮廓和一个黄色页面(不是一个非常直观的图标)。这是“显示所有文件”按钮。单击它,您将看到当前选定项目中的所有文件(它是特定于项目的)。突出显示要包含的任何文件,右键单击并选择“包含在项目中”。


回答by Hans Passant
You could just copy the file with Explorer. Or better yet, start refactoring your projects so that you'll create assemblies that are usable by multiple client projects.
您可以使用资源管理器复制文件。或者更好的是,开始重构您的项目,以便创建可供多个客户端项目使用的程序集。

