显示我的nuget的源代码 [英] Show source code of my nuget

查看:291
本文介绍了显示我的nuget的源代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的团队和我建立了自己的框架,并在许多项目中使用了该框架.我们曾经将框架的项目包含在所有其他项目中,但是后来我们决定将框架放入nuget服务器上的nuget包宿主中,以便我们可以进行版本控制并在开发过程中更轻松地扩展框架.

My team and I build our own Framework we use in many project. We used to include the framework's project in all our others projects but then we decided to put our Framework into a nuget package host on our nuget server so we can had versioning and spread our framework more easily during our developments.

一切正常,但有一些明显的副作用.

Every-things is working fine except but there are some notable sides effects to this.

Visual Studio无法直接查看nuget的dll本身,因此例如VS搜索引擎无法查找我的nuget中存在的功能. 基于同样的原因,我在项目中再也看不到我们框架的源代码,只显示了元数据.

Visual studio is not able to look directly into the nuget's dll itself, so for example the VS search engine can't look for function that are present in my nuget. For the same reason I assume, I can't see the source code of our framework in my project anymore, only the metadata are shown.

我知道nuget包不显示其自身的源代码是正常现象,但我想知道是否可以将nuget包设置为信任模式",以便Visual Studio能够搜索函数内部,开发人员可以直接查看源代码(当然不能进行编辑).

I understand it's a normal behavior for a nuget package to not show it's own source code but I would like to know if it's possible to set nuget package to a "trusted mode", so that visual studio will be able to search for function inside it and developpers able to look directly at the source code (without being able to edit it of course).

非常感谢.

推荐答案

以便Visual Studio能够在其中搜索功能,而开发人员可以直接查看源代码(当然不能对其进行编辑).

so that visual studio will be able to search for function inside it and developpers able to look directly at the source code (without being able to edit it of course).

如果我知道您正确的话,您想访问nuget软件包中的代码,但无法编辑?如果是,则可以尝试创建符号包,使使用者可以在Visual Studio调试器中进入您的包代码.

If I aware of you correct, you want to access the code in the nuget package but could not edit? If yes, you can try to create symbol packages which allow consumers to step into your package code in the Visual Studio debugger.

我们的工作方式(和工作方式):

The way we do it (and works):

  1. 创建"* .symbols.nupkg".

  1. Create "*.symbols.nupkg".

将符号包部署到SymbolSource服务器.

Deploy symbol package to SymbolSource server.

配置IDE,程序包使用者可以添加 https://nuget.smbsrc.net/到您在Visual Studio中的符号源.

Configure IDE, Package consumers can add https://nuget.smbsrc.net/ to your symbol sources in Visual Studio.

使用NuGet(从我们的SymbolSource服务器)将所需的库添加到项目中. 调试.

Add required Library to project using NuGet (from our SymbolSource server). Debug.

有关详细信息,您可以参考创建符号包.

For the detail info, you can refer to Creating symbol packages.

如果这些软件包不适合在NuGet Gallery/SymbolSource上发布,则可以将* .nupkg和* .symbols.nupkg文件放在网络共享上的NuGet本地供稿中.有关此方法的详细信息,可以参考类似的问题:

If these packages are not suitable for publishing on NuGet Gallery/SymbolSource, you can put the *.nupkg and *.symbols.nupkg files on a NuGet local feed on a network share. For the detail for this method, you can refer to the similar issue:

此外,在这种情况下,您不必担心开发人员将要编辑源代码,因为所有软件包都已下载到本地软件包文件夹中,除非重新发布,否则编辑不会影响网络共享上的源代码.

Besides, in this condition, you do not have to worry about developers going to edit the source code, because all packages are downloaded to local packages folder, edit would not affect the source code on network share until you re-publish it.

更新详细信息:

您应该添加一个断点,然后按F11键进入源代码:

You should add a breakpoint and press F11 to step into the source code:

通过F12更新检查dll中的源代码:

根据 MSDN文档:

调试器在以下位置查找源文件:

The debugger looks for source files in the following locations:

>1. Files that are open in the IDE of the Visual Studio instance that launched the debugger.

>2. Files in the solution that is open in the VS instance.

>3. Directories that are specified in the "Common Properties" / "Debug Source Files" page in the properties of the solution.

>4. The source information of the .pdb of the module. This can be the location of the source file when the module was built, or it can be a command to a source server.

因此,如果要通过F12直接访问dll文件中的源代码,则应在解决方案中添加源代码.您可以在解决方案中创建一个新项目来容纳源文件,并将该项目添加为参考项目.这将使您的解决方案/项目变得混乱,但是由于将其检查到源代码管理中,因此所有团队成员都将能够自动调试到源文件中.

So if you want to access the source code in dll file by F12 directly, you should add the source code in the solution. You can create a new project in the solution to house the source files and add this project as reference project. This will clutter up your solution/project, but since it will be checked into source control, all team members will automatically be able to debug into the source files.

此外,还建议使用 ReSharper ,您可以通过ReSharper/选项/启用它.外部源,然后向上移动符号文件中的源".然后在选项卡来自符号文件的源"中,单击高级",然后可以在其中映射源文件夹.

Besides, ReSharper should be recommended, you can enable it by going to ReSharper / Options / External Sources, and move up "Sources from symbol files". Then in the tab "Sources from symbol files", click "Advanced" and there you can map source folders.

这篇关于显示我的nuget的源代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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