你怎么多个项目之间共享脚本一个解决方案? [英] How do you share scripts among multiple projects in one solution?

查看:215
本文介绍了你怎么多个项目之间共享脚本一个解决方案?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在情况下,这个问题不明确。我有一个解决方案3 MVC项目。每次我创建一个新的项目把它添加了所有我永远需要.js文件的脚本文件夹中。我不希望有这样的创建每次为每个应用。有没有办法从溶液中的中央文件夹中引用脚本,以便所有的应用程序/项目可以与所有常见的脚本当中?

In case the question wasn't clear. I have 3 MVC projects in one Solution. Every time I create a new project it adds the "Scripts" folder with all the .js files I'll ever need. I don't want to have this created every time for every application. Is there a way to reference scripts from a central folder in the solution so all applications/projects can share one common script folder with all the scripts common among them?

编辑:
请解释的优点和这样做的利弊,如果有任何...现在我很好奇。

推荐答案

下面是我会建议:

右键单击该解决方案,并创建一个新解决方案文件夹的名为常见的JavaScript文件(或任何你觉得像调用它。

Right click the solution and create a New Solution Folder called Common Javascript Files (or whatever you feel like calling it.

右键单击该解决方案,请点击打开文件夹在Windows资源管理器的,
或者手动导航存在的Visual Studio的其他版本:(

Right click on the Solution, click Open Folder in Windows Explorer, or navigate there manually for other versions of Visual Studio :(

在解决方案目录,创建一个目录具有相同名称的解决方案文件夹(文件夹的解决方案通常不匹配在源$ C ​​$ C级目录,但是这会为理智的缘故)。

In the solution directory, create a directory with the same name as the solution folder (solution folders do not normally match directories at the source code level but this will for sanity sake).

在这个新的目录中,添加了需要解决方案之间共享文件。

In this new directory, add files that need to be shared between solutions.

在Visual Studio中,单击解决方案文件夹并选择的添加的 - 现有项目的。

In Visual Studio, click the solution folder and select Add - Existing Item.

在文件选择对话框,定位到创建的目录previous,选择文件(S)添加到目录,然后单击的添加的。

In the file selection dialog, navigate to the directory previous created, select the file(s) added to the directory and click Add.

在需要共享的文件中的每个项目,右键点击(在项目内或目录)的项目,然后单击添加的 - 现有项目

In each Project that needs a shared file, right click on the project (or directory within the project) and click Add - Existing Item.

浏览到共享目录,选择文件和点击下拉箭头,然后点击添加链接

Navigate to the shared Directory, Select the files and click the drop down arrow then click Add As Link.

现在在项目中的文件基本上是捷径到解决方案文件夹中的文件。但他们被视为该项目(包括.CS或Visual Basic的文件,他们将被编译为实际存在的项目文件),实际的文件。

Now the files in the projects are essentially short cuts to the files in the Solution Folder. But they are treated as actual files in the project (this includes .CS or Visual Basic files, they will be compiled as files that actually exist in the project).

赞成


  • 文件是真正的跨项目在共享的设计时间

  • 只需要为每个项目中的文件可以添加,它不是全有或全无

  • 不需要在IIS任何配置(虚拟目录等)

  • 如果该解决方案是TFS源代码管理,可以将目录添加到TFS源代码和共享文件将源控制。

  • 将在项目中选择编辑文件时,将编辑实际文件。

  • 删除链接的文件不会删除该文件。

  • 这不仅限于JS文件,链接文件可以的任何的文件,你可能需要(图像,CSS,XML,CS,CSHTML等)

  • Files are truly shared across projects at Design time
  • Only the files needed for each project can be added, it's not all or nothing
  • Does not require any configuration in IIS (virtual directory etc)
  • If the solution is in TFS Source control, you can add the Directory to the TFS Source and the shared files will be source controlled.
  • Editing a file by selecting it in the Project, will edit the actual file.
  • Deleting a Linked file does not delete the file.
  • This is not limited to JS files, linked files can be ANY file you might need (Images, Css, Xml, CS, CSHTML, etc)

缺点


  • 每个部署得到它自己的文件。

  • 有理解是解决方案文件夹不存在的解决方案目录目录时是一个小的学习曲线。

这篇关于你怎么多个项目之间共享脚本一个解决方案?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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