.NET(Visual Studio中)项目之间共享资产 [英] .NET (Visual Studio) Share assets between projects

查看:330
本文介绍了.NET(Visual Studio中)项目之间共享资产的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我与Visual Studio工作。在那里,我有几个网络项目(.NET MVC 4)的解决方案。所有这些Web的项目都使用相同的JavaScript库。目前,我复制到库中每一个项目,但是这不能成为最后的解决方案。什么是所有的项目之间共享这些库(一般资产)的最佳方法?只是链接呢?或者是有可能创建一个项目,并在所有项目中引用它?

I'm working with Visual Studio. There I have a solution with several web-projects (.net MVC 4). All of these web-projects use the same javascript-libs. Currently I copied the library into each project, but this can't be the final solution. What is the best approach to share those library (assets in general) between all of the projects? Just link them? Or is it possible to create a project and reference it in all projects?

更新

链接从其他项目中的JavaScript文件是不是一个可行的解决方案为我会的文件链接成千上万(我用的是库之一是ExtJS的)什么的使不可能建立不结冰的Visual Studio项目...

"Link" the javascript files from another project is not a possible solution as I would have to link thousands of files (one of the libraries I am using is ExtJs) what makes it impossible to build a project without freezing visual studio...

可能的解决方法

目前我有一个(网络)MVC项目名为网络,并呼吁ClientScript一个(类库)项目,该项目包含了所有这些多个Web项目之间共享的JavaScript文件。作为连接所需的所有JavaScript文件是不是一个可行的解决方案(因为它的数以千计的文件的问题是什么原因导致视觉工作室冻结)的我所有需要的JavaScript文件复制到单个项目使用每个Web项目的生成事件(项目 - >属性 - >生成事件 - >生成后)
在Web项目我的后期生成命令行看起来是这样的:

Currently I have a (Web) MVC Project called "Web" and a (Class Library) Project called "ClientScript" which contains all the JavaScript files which are shared between several Web Projects. As linking all the needed JavaScript files is not a possible solution (because it's a matter of thousands of files what causes visual studio to freeze) I copy all the needed JavaScript files to the individual Projects using the Build Events in each Web Project (Project -> Properties -> Build Events -> Post-build). My Post-build command line in the Web Project looks like this:

start xcopy "$(SolutionDir)ClientScript\Frontend\*" "$(SolutionDir)Web\Scripts" /r /s /i /y /D /E

您构建Web项目中的所有更改的Javascript文件从该项目ClientScript复制到您的Web项目每一次。

Every time you build your Web Project all the changed Javascript files get copied from the ClientScript Project to your Web Project.

在开发我运行一个小的filewatcher的工具,当它改变时自动将文件从ClientScript项目文件的每一个Web项目中的Javascript。这样,我不用每次都构建Web项目,当我做出改变的JavaScript的之一。

While developing the Javascripts I run a small "filewatcher" tool which automatically copies a file from the ClientScript Project to every Web Project when it changes. This way I don't have to build the Web Project every time when I make a change to one of the Javascripts.

推荐答案

将JS文件放在一个文件夹,有可能高于一切,并将其添加到该项目,但使用​​链接选项。这是降下来的部分就OK按钮,在添加现有项...对话框。

Place the JS files in a single folder, likely above all others, and add them to the project but use the "Link" option. It's part of the drop down on the "OK" button in the "Add existing item..." dialog.

这篇关于.NET(Visual Studio中)项目之间共享资产的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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