我正在尝试使用VS2015中的添加为链接"功能在项目中共享一些视图,但是即使在网站上运行正常,链接视图在VS中也会显示为损坏.
I'm trying to share some views across projects by using the "Add as Link" feature in VS2015 but the linked view appears broken in VS even though it works fine on the site.
是否有一种方法可以使智能感知和转到定义"等功能适用于链接的View?
我可以使用新的解决方案/项目来重现此内容:
I can reproduce this with a new solution/project:
- 将Home/Index.cshtml移至其他文件夹(当前我正在使用解决方案"文件夹,但移动文件的位置似乎并不重要)
- 从Home/删除Index.cshtml
- 从主页/右键单击并添加现有项目"
- 从解决方案文件夹中选择Index.cshtml,但从下拉菜单中选择添加为链接"
- 在链接的Index.cshtml上选择属性复制到输出目录=始终复制"
该网站可以正常运行,但在VS2015中,该视图随后会出现损坏,并且没有智能感知.
The site will work fine but in VS2015 the view then appears broken and no intellisense works.
这将是在多个项目中共享视图的好方法,但是如果VS认为视图被破坏,则会使开发变得痛苦.
This would be a great way to share a view across multiple projects but if VS thinks the view is broken it makes developing a pain.
有什么建议吗?有没有更好的方法可以在项目之间共享视图?
Any suggestions? Is there a better way to share views across projects?
推荐答案这是我让它工作的痛苦方式:
Here's the painful way I got it to work:
现在,我可以在模板化项目中进行所有编辑,而不必到处维护多个副本.
Now I can do all my edits in the templated project without having to maintain multiple copies everywhere.
两个大缺点:
- 我必须在对任何链接的对象进行编辑之后进行构建,然后才能看到所做的更改.
- 我只需要在[ SharedItems ]项目中打开实际的.cshtml文件.打开链接的文件会中断Intellisense,直到您将其关闭并直接将其打开. Resharper的搜索无处不在"功能尤其令人讨厌,因为它建议链接的文件.
- I have to build after making edits to any linked object before I can see the changes.
- I have to open the actual .cshtml files in the [SharedItems] project only. Opening a linked file breaks Intellisense until you close it and open it directly. This is especially annoying with Resharper's Search Everywhere feature because it suggests linked files.
更多推荐
为视图添加为链接intellisense
发布评论