Visual Studio 2015-Web项目上缺少“共享项目参考"选项卡 [英] Visual Studio 2015 - Shared Projects Reference Tab Missing on Web Project

查看:113
本文介绍了Visual Studio 2015-Web项目上缺少“共享项目参考"选项卡的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从MSDN订阅升级到了Visual Studio 2015,因为我很高兴阅读共享项目...当我们要做的就是重用代码时,不再需要在依赖项中管理21382个nuget程序包.

I upgraded to Visual Studio 2015 from our MSDN subscription because I was pretty excited to read about Shared Projects... No more managing 21382 nuget packages in our dependencies when all we want to do is reuse code.

因此,我构建了一个包含一些代码的测试共享项目.然后,我在.Net 4.6上向该项目添加一个新的空Web应用程序.现在,我希望可以转到参考文献,并在参考文献窗口中看到一个共享的项目"选项卡,但是我没有看到.

So I built a test shared project with some code in it. Then I add a new empty web application on .Net 4.6 to the project. Now I expected to go to references and see a "Shared Projects" tab on the references window, but I do not see one.

现在,我可以将类库添加到相同的解决方案中,并且可以看到选项卡并可以添加共享引用.但是,我无法将共享项目添加到Web应用程序中.

Now I can add a class library to the same solution and I see the tab and can add the shared reference. However I cannot add the shared project to my web application.

我真希望我可以使用这个概念与多个MVC项目共享视图.

I was rather hoping I could use this concept to share views with multiple MVC projects.

我在这里缺少什么吗,还是共享项目与Web项目不兼容?

Am I missing something here, or are shared projects not compatible with Web Projects?

我看到的唯一方法是为我构建的每个Web应用程序都有两个项目. 1代表代码,1代表内容.

The only way I see around this is to have two projects for every web application I build. 1 for the code, and 1 for the content.

例如

XYZ.SomeWebSite.Code (Class Library Project Type) -> references Shared Project
XYZ.SomeWebSite (Web Project Type)

无论如何,我将无法将视图,文本文件,css文件,javascript文件等推送到Web应用程序中.

However going this route, I would not be able to push views, text files, css files, javascript files, etc into the web application.

推荐答案

[临时答案]

我能够通过手动编辑Web应用程序的csproj文件来解决此问题.

I was able to work around the problem by manually editing the csproj file for my web application.

以下是步骤:

  1. 卸载Web应用程序项目
  2. 通过右键单击项目并单击编辑..."来编辑* .csproj文件.
  3. 现在查找ProjectTypeGuids元素.

  1. Unload the web application project
  2. Edit the *.csproj file by right clicking the project and clicking edit...
  3. Now look for the ProjectTypeGuids element.

{349C5851-65DF-11DA-9384-00065B846F21}; {fae04ec0-301f-11d3-bf4b-00c04f79efbc}

{349C5851-65DF-11DA-9384-00065B846F21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}

第一个guid是ASP.Net MVC 5项目的guid,第二个guid用于C#.

The first guid is the guid for an ASP.Net MVC 5 Project, and the 2nd guid is for C#.

您需要做的就是暂时删除第一个guid和分号,仅保留c#guid(第二个).

All you need to do is temporarily remove the first guid and the semicolon, leaving just the c# guid (the 2nd one).

重新加载项目并添加共享的项目.添加完所有内容后,请编辑项目文件,然后将第一个GUID和分号放回去.

Reload the project and add your shared projects. Once they are all added, edit the project file and put the first guid and the semicolon back.

重新加载项目.

共享项目"参考将仍然存在,它将建立并链接到您的Web应用程序.

The Shared Project reference will still be there, and it will build and link into your web application.

(可选)您可以手动添加共享项目引用,格式如下

Optionally, you can just manually add the shared project referrence, the format is like this

<Import Project="..\XYZ.UPlugin\XYZ.Plugin.projitems" Label="Shared" />

这篇关于Visual Studio 2015-Web项目上缺少“共享项目参考"选项卡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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