ASP.NET MVC:我怎样才能添加视图,脚本和内容文件,才能链接到整个项目共享? (通过"新增为链接"在VS) [英] ASP.NET MVC: How can I add views, scripts and content files as links in order to share across projects? (Via "Add as Link" in VS)

查看:195
本文介绍了ASP.NET MVC:我怎样才能添加视图,脚本和内容文件,才能链接到整个项目共享? (通过"新增为链接"在VS)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经得到了我想要分享一个共同的Layout.cshtml文件。当我将文件添加为项目的链接(通过添加现有项>添加为链接),我得到的,当我运行该应用程序无法发现错误。如果我设置生成操作为复制总是它将该文件复制到构建目录,但是我仍然得到一个错误,它无法找到该文件(或许我可以以某种方式指示VS将其复制到相应的目录?)。

I've got a common Layout.cshtml file that I want to share. When I add the file as a link in the project (via Add Existing Item > Add as Link) I get an error that it cannot be found when I run the application. If I set the build action to "Copy Always" it does copy the file to the build directory, however I still get an error that it cannot find the file (Perhaps I can somehow instruct VS to copy it to the appropriate directory?).

我碰到这个问题就来了: ASP.NET 2个项目分享同样的文件但答案是pretty复杂和丑陋,现在我有很多不同的结构和重构方法玩弄,所以我不想去通过一些大的生产只是为了移动几个不同的文件身边。

I came across this question: ASP.NET 2 projects to share same files however the answers are pretty complicated and ugly and right now I'm playing around with a lot of different structures and refactoring methods so I don't want to go through some big production just to move a few different files around.

所以,我怎么能轻松地共享这些类型的文件的两个应用程序之间?

So how can I easily share these kinds of files between the two applications?

谢谢!

推荐答案

看起来像它在MSBuild的或不支持的功能的错误。无论哪种方式,我终于发现了这个家伙的博客上发表了一个解决办法:

Looks like it's a bug in msbuild or an unsupported feature. Either way I finally found a workaround published on this guy's blog:

<一个href=\"http://consultingblogs.emc.com/jamesdawson/archive/2008/06/03/using-linked-files-with-web-application-projects.aspx\" rel=\"nofollow\">http://consultingblogs.emc.com/jamesdawson/archive/2008/06/03/using-linked-files-with-web-application-projects.aspx

这篇关于ASP.NET MVC:我怎样才能添加视图,脚本和内容文件,才能链接到整个项目共享? (通过&quot;新增为链接&QUOT;在VS)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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