vb.net 如何创建共享代码项目 (.shproj)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/24294608/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-17 17:43:25  来源:igfitidea点击:

How do I create a Shared Code project (.shproj)

c#.netvb.netvisual-studiovisual-studio-2013

提问by vossad01

How I add a .shprojto my Visual Studio solution and reference it from other projects?

我如何将.shproj添加到我的 Visual Studio 解决方案并从其他项目中引用它?

Showing the Shared Project

显示共享项目

I know that Visual Studio 2013 Update 2 added a new project type for "Shared Code." This type of project does not produce a dll itself. Instead the files from the Shared project are included as source files in the assemblies that reference it.

我知道 Visual Studio 2013 Update 2 为“共享代码”添加了一个新的项目类型。此类项目本身不会生成 dll。相反,共享项目中的文件作为源文件包含在引用它的程序集中。

I know it exists because I have seen one in an open source project. However, looking through the project templates in Visual Studio I could not find a "Shared" project type.

我知道它存在是因为我在一个开源项目中看到过一个。但是,在 Visual Studio 中查看项目模板时,我找不到“共享”项目类型。

采纳答案by vossad01

Edit:According to the Visual Studio 2015 Preview documentation, VS 2015 adds templates for shared projects and a UI for managing the references, so the below should no longer be necessary after upgrading.

编辑:根据Visual Studio 2015 预览文档,VS 2015 添加了共享项目的模板和用于管理引用的 UI,因此升级后不再需要以下内容。

There does not seem to be a way to create one directly. It appears currently that Shared Code projects are automatically created when you create a Universal App project as shown in this introduction to creating a Universal App.

似乎没有一种方法可以直接创建一个。当前似乎在创建通用应用程序项目时会自动创建共享代码项目,如创建通用应用程序的介绍中所示

Therefore, to create one in your solution: Add a new project type "Blank App (Universal App)." Delete the Windows 8 and Windows Phone projects it created leaving only the Shared project.

因此,要在您的解决方案中创建一个:添加一个新项目类型“ Blank App (Universal App)”。删除它创建的 Windows 8 和 Windows Phone 项目,只留下共享项目。

回答by hortman

Check out the Shared Project Reference Managerextension.

查看共享项目引用管理器扩展。



Note:注意:确保你有VS2013 update 2 or aboveVS2013 更新 2 或更高版本才能工作。

回答by Victor Chelaru

An alternative to vossad01's approach is to create a shared code project, then open up the .csproj file and see what the project looks like in the .csproj. Visual Studio's csproj files are simply XML files so you can open, copy, and paste the shared code project into your own csproj.

vossad01 的另一种方法是创建一个共享代码项目,然后打开 .csproj 文件并查看该项目在 .csproj 中的样子。Visual Studio 的 csproj 文件只是 XML 文件,因此您可以打开、复制共享代码项目并将其粘贴到您自己的 csproj 中。