我想复制一份我的项目。我宁愿不从头开始添加文件和引用等。请注意,我指的不是用于部署的复制。只是简单的复制。
VS中有这样的工具吗?我使用的是vs2008
我想复制一份我的项目。我宁愿不从头开始添加文件和引用等。请注意,我指的不是用于部署的复制。只是简单的复制。
VS中有这样的工具吗?我使用的是vs2008
当前回答
完全不建议复制项目,因为一些内部形成的配置文件,如.csproj, .vspscc等可能(而且很可能)指向属于以前解决方案的位置和系统或TFS中的其他路径/位置的引用。除非你是阅读这些文件和修复引用的专家,否则不要试图复制项目。
您可以创建一个与您打算复制的相同类型的框架项目,这将创建一个适当的.csproj, .vspscc文件。现在你可以自由地复制类文件,脚本和其他内容从以前的项目,因为他们不会影响。这将确保平稳的构建和版本控制(如果您对此感兴趣的话)。
说了这么多,让我给你一个循序渐进复制项目的方法:
Go to the project you want to copy in solution explorer and right-click. Now select 'Open Folder in File Explorer' (Assuming you have the solution mapped to a local path on your disk). Select the Projects you want to replicate as whole folders(along with all dependencies,bin .vspscc file, .csproj file) Paste them in your desired location (it could be your same solution folder or even another solution folder. If it is within the same solution folder, then you would be required to rename it, also the .csproj and other internal files to the new name). No go back to Visual Studio, Right-Click on Solution > Add > Existing Project... Browse and select the Project file (.csproj file) now from the location you placed it in and select 'open' This file now appears in the solution explorer for you to work.
你现在可能不得不解决一些构建错误,可能是重复/缺失的引用和东西,但否则它是原始的逻辑和结构,因为你期望它是。
其他回答
我的解决方案有点不同——包所在的计算机死了,所以我被迫在另一台计算机上重新创建它。
我所做的(在VS 2008中)是在我的目录中打开以下文件:
- <package name>.djproj
- <package name>.dtproj.user
- <package name>.dtxs
- <package name>.sln
- Package.dtsx
当我这样做的时候,一个弹出窗口问我是否sln文件将是一个新的解决方案,当我点击“是”一切工作完美。
如果你想要一个副本,最快的方法就是保存项目。然后在文件系统中复制整个文件。回到Visual Studio并打开副本(通过右键单击solution => add existing project =>打开复制的项目)。从那里,我很可能会建议重新命名项目/解决方案(安全重命名项目的步骤在下面的链接中),这样你就不会有两个相同的名称,但这是复制的最快方法。
在尝试以上解决方案&创建副本MVC项目
对于MVC项目,请更新。csproj文件中的端口号,您可以借助iis applicationhost。配置检查端口号。相同的端口号将导致IIS中程序集加载问题。
我遵循这些步骤,并使用名为Resharper的开发工具,顺便说一句,它非常棒:
So,
Copy the existing project folder to the destination you want Go to source control and with right click just to the root folder you want and pick "Add items to folder...".Then, a wizard will come up to choose the files to copy (there is no need for some files and the wizard guides you for that reason by default). Change the name of the solution file (*.sln) Change the names of the sub-projects if exist. Use Resharper to change the binding namespaces name (I will automatic do the dirty job with safety).The alternative way is to manually change all namespaces with the new name. The same action with method names. Check solution's properties if you want to change.
就是这样。你准备好了!!
只需要创建一个模板;
从您的项目选择:项目-导出模板
向导将允许您定义
模板名称 模板描述 图标 预览图像
然后它将你的项目压缩到“我的导出模板”目录。 您还可以选择在创建新项目时使模板可用。
当你使用你的模板创建一个新的项目,命名空间将是正确的` your_new_project_name'贯穿每个文件,所有引用正确,一切完美:)
你可以将。zip文件发送给任何人,他们必须复制(而不是解压缩)。zip文件到Templates\ProjectTemplates目录中供他们使用。
我做了一个ASP。NET MVC模板与文件夹,布局页面,视图模型等安排只是我喜欢他们。
注意: 如果你在你的项目中有一个空文件夹,它不会被添加到模板中,所以我只是添加了一个空类,适用于每个文件夹,和一个示例图片的图像文件夹。