Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to host both regular and symbols packages in a NuGet local feed on a network share?

First off, I am still very new to NuGet. I have a number of internal C# desktop applications I develop at work, with some common code shared between them. I have been in the process of switching from using project references to creating private NuGet packages and hosting them in a local feed situated in a shared network folder. I've only been at it for a few days now, but I have successfully managed to turn a handful of my library projects into packages and use them in other projects so far.

The issue is that, while I can use the code these packages provide in my other solutions which depend upon them, I do not get IntelliSense support or the ability to debug within the package itself. It turns out that only the assembled DLL is distributed in the normal packages, and from what I've gathered from searching online, I also need to create symbol packages which do include the files needed for IntelliSense and debugging.

How can I do this - using both regular packages and symbol packages - when using only a network share folder as a local feed? Many answers online suggest using a separate symbols server. However, I can't publicly publish this code to symbolsource.org and I am not currently able to get a server from my employer for hosting one (which eliminates solutions such as NuGet.Server, ProGet, etc.). Is what I'm looking for even possible?

I already looked at the official documentation on creating symbol packages and local feeds, as well as this related question. But none of those has the information I am looking for.

EDIT: I did get the IntelliSense support for my packages' code working by remembering to turn on XML documentation generation at build time, using information from this question. Still not sure about the debug support, though.

like image 403
Knowledge Cube Avatar asked Aug 10 '17 18:08

Knowledge Cube


People also ask

What is a local NuGet feed?

Local NuGet package feeds are simply hierarchical folder structures on your local network (or even just your own computer) in which you place packages. These feeds can then be used as package sources with all other NuGet operations using the CLI, the Package Manager UI, and the Package Manager Console.

Where NuGet packages are stored locally?

The global-packages folder is where NuGet installs any downloaded package. Each package is fully expanded into a subfolder that matches the package identifier and version number. Projects using the PackageReference format always use packages directly from this folder.

Can NuGet packages be private?

For all such purposes, NuGet supports setting up private package sources in the following ways: Local feed: Packages are simply placed on a suitable network file share, ideally using nuget init and nuget add to create a hierarchical folder structure (NuGet 3.3+).


1 Answers

How can I do this - using both regular packages and symbol packages - when using only a network share folder as a local feed?

I`m afraid the answer is no. When I host both regular and symbols packages in a NuGet local feed on a network share, then I installed that package to my test project, go to debug, Visual Studio could not load the .pdb file. Because the .pdb file is wrapped in the symbol package, Visual Studio could not access it directly. So the suggestion is that "using a separate symbols server.".

Since you can't publicly publish this code to symbolsource.org and can not currently able to get a server from your employer for hosting one, I would like provide you a lightweight solution here:

  1. Put the pdb and source code file in the NuGet package alongside the dll.
  2. Add the source code to the Debug Source Files for the solution that references the package.

This means you'll be able to step through code and view exceptions, but you might have to find a file on disk and open it before you can set a break point. Obviously you need to be careful that the source is at the right revision.

More detail on step 1:

If you're currently packaging without a Nuspec, you'll need to create a Nuspec, then add the pdb to the list of files in the lib folder and source file in the src folder. "NuGet spec" may be a useful command for generating the initial spec as defined in NuGet docs. Below is my .nuspec file, you can check it:

<?xml version="1.0"?>
  <package >
    <metadata>
     <id>MyTestPackage</id>
     <version>1.0.3</version>
     <authors>Admin</authors>
     <owners>Admin</owners>
     <requireLicenseAcceptance>false</requireLicenseAcceptance>
     <description>Package description</description>
     <releaseNotes>Summary of changes made in this release of the package.</releaseNotes>
     <copyright>Copyright 2017</copyright>
     <tags>Tag1 Tag2</tags>
   </metadata>

   <files>
     <file src="bin\Debug\MyTestPackage.dll" target="lib\Net46" />
     <file src="bin\Debug\MyTestPackage.pdb" target="lib\Net46" />
     <file src="Class1.cs" target="src" />
   </files>
</package>

More detail on step 2:

When you have a solution open, right click on Solution, select Properties...Common Properties...Debug Source Files, and add the root source directory for the relevant binary reference.

enter image description here

Or see MSDN. Note, you can't open the solution properties while debugging.

With this settings in the .nuspec, you only need to set this regular package in a NuGet local feed on a network share. Install this package, then you can to debug within the package itself.

Besides, SymbolSource released a community edition called SymbolSource Server Basic now.

like image 165
Leo Liu-MSFT Avatar answered Oct 22 '22 04:10

Leo Liu-MSFT