简体   繁体   English

如何在Visual Studio 2012中导出类库

[英]How to export class libraries in Visual Studio 2012

In Eclipse when I implement a class library and I'm ready to deploy, I usually export and package it into a JAR file that later you can just add to the build path in another project. 在Eclipse中,当我实现一个类库并且我已经准备好部署时,我通常会将其导出并打包成一个JAR文件,稍后您可以将其添加到另一个项目的构建路径中。 Is there an equivalent feature in Visual Studio? Visual Studio中是否有相同的功能? Is there a proper way to "publish" a class library and package it into a dll file to later add as a reference in another project? 是否有一种正确的方法来“发布”类库并将其打包到dll文件中以便稍后作为参考添加到另一个项目中? Or do you just usually go and dig for it in the bin folder yourself? 或者你经常自己去bin文件夹中挖掘它?

Most VS projects compile into a DLL. 大多数VS项目都编译成DLL。 If you want your DLL to be "published" to some particular location when you build, you can use build events which can also package up your dll (you could call a batch script, for example, that takes care of that for you). 如果您希望在构建时将DLL“发布”到某个特定位置,则可以使用构建事件 ,这些事件也可以打包您的dll(例如,您可以调用批处理脚本来处理这个问题)。

Is there a proper way to "publish" a class library and package it into a dll file to later add as a reference in another project? 是否有一种正确的方法来“发布”类库并将其打包到dll文件中以便稍后作为参考添加到另一个项目中? Or do you just usually go and dig for it in the bin folder yourself? 或者你经常自己去bin文件夹中挖掘它?

Sure, just add the bin\\debug\\yourdll.dll or bin\\release\\yourdll.dll as a reference in your other project, or otherwise to the location you moved it to in your build event. 当然,只需将bin\\debug\\yourdll.dllbin\\release\\yourdll.dll作为参考添加到您的其他项目中,或者添加到您在构建事件中将其移动到的位置。 No need to go digging for it every time. 无需每次都去挖掘它。

  1. Change the output type to 'release' or 'Debug'. 将输出类型更改为“release”或“Debug”。
  2. Go to Build, Build Solution (Or f5) 转到构建,构建解决方案(或f5)
  3. Navigate to: The Solution Bin folder for release or debug. 导航到:用于发布或调试的Solution Bin文件夹。

    3a. 3A。 You can quickly navigate to the solution folder by right clicking the solution in the 您可以通过右键单击解决方案来快速导航到解决方案文件夹
    'Solution explorer' and selecting 'Open folder in File Explorer'. “解决方案资源管理器”并选择“文件浏览器中的打开文件夹”。 The compiled DLL file will be in that directory. 已编译的DLL文件将位于该目录中。 (bin\\release or bin\\debug) (bin \\ release或bin \\ debug)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM