Publish *.snupkg symbol package to private feed in VSTS - azure-devops

I want to package and publish a .net standard based code as a nuget package using VSTS build. I have created a private nuget feed (in VSTS Artifacts) to which I would like to publish nuget package along with symbols package.
I tried using dotnet CLI tasks to build and publish but it only publish .nupkg and not *.snupkg to the nuget feed.
I googled alot but I only found articles related to publishing to nuget.org and not to a private feed.

Publish *.snupkg symbol package to private feed in VSTS
You can publish the .snupkg symbol package to NuGet.org, or to any NuGet server that opts into this experience. But azure devops private feed does not have this experience.
You can get the detailed info from this wiki NuGet Package Debugging & Symbols Improvements:
When publishing packages, both the symbols package and the .nupkg will be easily published to NuGet.org, or to any NuGet server that opts into this experience.
Reason:
As we know, when we consume .snupkg in Visual Studio, we add a new symbol server location under Symbol file (.pdb) locations:
But Visual Studio can only parse the symbol file (.pdb) directly rather than the .snupkg package, so we need a NuGet server to help us read the .pdb file from the .snupkg package. Azure devops feed is more inclined to be a shared repository of packages.
So, we have to publish *.snupkg symbol package to NuGet.org, or to any NuGet server that opts into this experience.
If you do not want share your package on the nuget.org, You can host your own NuGet server or you can use a lightweight solution to resolve this issue (You can debug the nuget package with private feed).
Hope this helps.

You may well want to just embed the symbol PDB in the main NuGet package itself. IMO that's the best approach here today - it's much simpler, removing the need for the symbol server at all and works well with all repository types, private VSTS/Azure DevOps feeds public repos. The only downside is that clients have to download modestly bigger NuGet packages even if they don't use the debug info, but that seems minor.
Adding the PDB in the NuGet package is normally just a matter of adding this to your project file:
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
See NuGet #4142 and Include pdb files into my nuget (nupkg) files.

Azure Artifacts does not currently support .snupkgs but it does have a symbol server to which you can publish if you're building using Azure Pipelines. This doc walks through setting up a pipeline that publishes symbols.

You can publish the snupkg files to Azure DevOps, but at this point, you cannot consume them from with VS to debug. Here is how I did it:
1) setup a "Use .Net Core" task to upgrade the .net sdk to the version that supports this (as below)
2) setup a custom dotnet pack command (as below)
3) push it to Azure using the dotnet push command (as below)
This results in the snupkg being pushed to Azure DevOps Artifacts, thus:

Related

Azure DevOps NuGet Feed with Symbols

For debugging I need to push my NuGet packages including Symboles to our self-hosted Azure Devops Server.
Therefore I use the dotnet pack task with the flags --include-symbols and --include-source in my build pipeline. As output I get two files package.1.0.0.nupkg and package.1.0.0.symbols.nupkg.
When I try to push the package.1.0.0.symbols.nupkg package in my release pipeline, I get the feedback:
409 (Conflict - The feed already contains "package.1.0.0".
(DevOps activity ID: 766B8BC7-9AE6-4998-A246-47397236122F)).
I found Publish *.snupkg symbol package to private feed in VSTS on stack. The feedback is that the Azure DevOps Server do not support NuGet Symbols and they suggest to use a symbol server.
Is it a possible workaround to simply rename the package.1.0.0.symbols.nupkg to package.1.0.0.nupkg and push this package to the feed? Is Visual Studio with able to open the debugger inside the sources of these kind of package?
Is there another way to provide NuGet Symbols for debugging on a Azure DevOps Server?
There are multiple questions in your post, let us try to solve them one by one.
Is it a possible workaround to simply rename the
package.1.0.0.symbols.nupkg to package.1.0.0.nupkg and push this
package to the feed?
The answer is no. The error 409 (Conflict - The feed already contains "package.1.0.0" means that you already have one package package.1.0.0.nupkg or package.1.0.0.symbols.nupkg with version 1.0.0 in your feed. So you could not push another package with same version in that feed. Package version in the feed is unique. In order to protect the package from stepping on each other because of the same version of the package.
So, to resolve that error, you need to update the package version, like 1.0.1 (Deleting the old version of the package from the feed will not solve this error).
Is Visual Studio with able to open the debugger inside the sources of
these kind of package?
The short answer is yes. The details will be explained in the next question.
Is there another way to provide NuGet Symbols for debugging on a Azure
DevOps Server?
The answer is yes, we need to configure Visual Studio to enable debugging remote packages. You could refer below Official document and detailed blog:
Debug with symbols in Visual Studio
ASP.NET Core Debugging Nuget Packages with AzureDevOps | VSTS Symbol Server
But when I use nuget install package then only the package.dll is part
of the content which get downloaded from the Azure DevOps Artifacts.
Why is that?
This is expected behavior for installing the package. Because most of the time when we install and use the nuget package, we do not need the debug package, so the installation package will only add the dll we need to the project and will not configure the Symbols package. If we want to debug the package, we have to configure the Symbols package like above links.
The feedback is that the Azure DevOps Server do not support NuGet
Symbols and they suggest to use a symbol server.
The feedback you mentioned in the question is for *.snupkg symbol package not the symbols package. Azure DevOps Server should support publish NuGet Symbols packages, not debug packages, we have to manually configure Visual studio to use the Azure DevOps Server.
BTW, since there are many questions in your post and they are more general, my answer is not very specific. If you have any questions about any specific questions, you are welcome to open a new post with detailed questions.

Ensuring a NuGet package can only be installed from a specific feed

I have an Azure Pipelines job setup to authenticate to a private NuGet feed in Azure Artifacts, and then build my .NET project that relies on a NuGet package in the feed. However, my private package is a pretty common name. How can I ensure that it only installs that specific package from my private feed, and doesn't try to fallback to the NuGet general gallery? I do not want it to pull in an incorrect package that has the same name and version name as my private package.
Once you configure multiple sources/feeds, NuGet will look for a package in all these sources together with no guarantee of where the package will be downloaded from. However, you could make the AzDo artifacts feed as the only configured feed and then upstream other sources from it. This way NuGet will get all packages from the configured AzDo artifacts source and AzDo artifacts will source other packages not available with it from the upstreamed sources in the order defined. More info can be found here: https://learn.microsoft.com/en-us/azure/devops/artifacts/concepts/upstream-sources?view=azure-devops

Does nuget push to Azure DevOps artifact include symbols?

I have a class library that I often need to debug/step-into that I distribute and use as a nuget package to Azure DevOps Artifacts feed.
To create the package, I run the following commands using nuget.exe v5.4:
nuget spec
I then enter data in the .nuspec file. Then I run:
nuget pack myLibrary.csproj -Symbols -SymbolPackageFormat snupkg
This generates both the nuget package file and the snupkg symbol file in the current working directory.
I then push this up to our Artifacts feed using the VSTS Credential Provider:
nuget push -Source "MyPackageSource" -ApiKey VSTS myLibrary.nupkg
This general spec, pack, push method works fine.
It was my understanding that pushing the .nupkg file would also push up the .snupkg symbol file with it as long as it's in the same directory as per this documentation:
You can also push both primary and symbol packages at the same time
using the below command. Both .nupkg and .snupkg files need to be
present in the current folder.
nuget push MyPackage.nupkg
However, after installing the package, I am not able to step-into the package code. I also don't see anything new in the package install folder. Just the standard nupkg and the dll. How do I push up the symbols and subsequently get them to install?
You can check your logs to be sure (the log should tell you the snupkg was pushed, just as it does for nupkg files, if it was indeed pushed).
My understanding is that Azure DevOps doesn't support snupkg packages, so I expect that it does not get pushed. However, Azure Pipeline has a built-in "Index Sources & Publish Symbols task" which you can use. Rather than creating a symbols package, just point it directly to your pdbs.

Azure Dev Ops, Private Nuget feed, options to develop / test nuget packages?

I am looking for practical options to develop and test private nuget packages.
We have a set of "core" code that is delivered securely through an Azure Artifact Feed. We have various "consuming" applications that use the core nuget packages.
As a small-medium team, one person may be developing the core nuget as well as consuming it.
Today we check-in / merge the code for the nuget package. Make sure the Pull request is approved / passes. Then the build updates the Azure Artifact feed.
Then we come back to the "consuming" app and can update the package. Works great if you fix / add the feature the first time. However, slows down productivity when treating this as an iterative development approach.
Looking for simple options for a small team. Random thoughts on options:
Push nuget "alpha" package straight from developer's machine to Azure Artifact feed. Symbol server too?
Do something with an Azure build to allow "feature" branches to publish to Azure Artifact feed somehow?
Push to local nuget feed. Include pdbs so it can be debugged?
Temporarily break the nuget reference directly for local copy of dll(s)?
Re-think using nuget packages as a whole?
Push nuget "alpha" package straight from developer's machine to Azure Artifact feed. Symbol server too?
It depends on whether you need to debug it. If you need do debug this "alpha" package, you have to push the symbol package to the symbol server.
Note: You do not need to push the "alpha" package to the symbol server, just the symbol package.
Do something with an Azure build to allow "feature" branches to
publish to Azure Artifact feed somehow?
There is a task Push NuGet packages, we could use it to publish to Azure Artifact feed during build, no matter which branch it is on. It depends on whether you have enough permissions for the Azure Artifact feed, you can check it from Artifacts->Settings->Feed settings->Permissions:
Push to local nuget feed. Include pdbs so it can be debugged?
No, you also have to include the source code. Check this thread for some more details.
And there is a lightweight solution how to debugged nuget package on local feed on a network share.
Temporarily break the nuget reference directly for local copy of
dll(s)?
Re-think using nuget packages as a whole?
The answer is yes, when we develop the project on the local, use project reference is better than nuget, check my another post for some more details:
Ticket: Project reference VS NuGet.
Hope this helps.

How do I set up Azure Dev Ops to build Dev Express XAF-XPO project?

I want to set up continuous integration and deployment for an XAP Mobile app in Azure Devops.
In order to get CI/CD I need to set up the Azure Pipeline to install the right packages.
There is some information in the docs on Hosting your own NuGet feeds
and Get started with NuGet packages in Azure DevOps
Dev Express explained that they do not currently provide a Nuget feed for XAF, but I can make my own Delegate's DCNugetPackageBuilder
Using DXNugetPackageBuilder to make Nuget packages
As per the instructions I downloaded the .pdb files extracted them to c:\tmp\symbols
I also downloaded DXNugetPackageBuilder and edited buildPackages.bat according to instructions.
Next I ran build.ps1 in elevated Powershell
This created the .nupkg files at C:\tmp\Nuget
By default this uses the files located at
C:\Program Files (x86)\DevExpress 18.1\Components\Bin\Framework
and the .pdb files located at
c:\tmp\symbols
Using Nuget.Exe and the Credential Provider to push the packages to the feed
The Connect To Feed screen mentions I need to download Nuget.exe and the credential provider
Here are the docs on the Credentials Provider
I unzipped the VSTS CredentialProviders Nuget.Exe is included.
The next step is to follow the instructions given by the "add this feed" section of the Connect To Feed screen.
For example
nuget.exe push -Source "SBDDevExpress" -ApiKey VSTS c:\tmp\Nuget\DevExpress.Data.18.1.6.0.nupkg
I ran into an access denied issue that got solved here
then I was able to push all the packages I wanted.
Set the Nuget Package Source
In VS2017 with my solution open I used Tools -> Nuget Package Manager -> Package Manager Settings
I added package settings with the Azure endpoint set up as a package source.
Errors building
When I run the build pipeline I get errors like
The type or namespace DevExpress could not be found are you missing a directive or assembly reference?
From studying Updater.cs and Module.cs
It seems I am missing the following namespaces from the Nuget feed.
DevExpress.ExpressApp.DC;
DevExpress.ExpressApp.Updating;
DevExpress.Persistent.BaseImpl.PermissionPolicy;
[Update]
DevExpress suggested I compare the dlls generated in the bin folder with my package feed.
I found several missing files and pushed their packages.
I now have
XafMobile.Module\Properties\licenses.licx(1.0): Error LC0003: Unable to resolve type 'DevExpress.ExpressApp.ModuleBase"
I can see from the source code that ModuleBase is a public class in DevExpress.ExpressApp
I am wondering if this is something to do with reflection.
There is some mention of it at Dev Express support
[Update]
I tried removing the licence files and syncing the project.
Now the errors show as missing assembly references
Also When I rebuild my solution the license files are missing from the properties folders
I wonder if this helps explain it
[Update]
Manuel Grunder [DevExpress MVP] and DXNugetPackageBuilder author explained that
"
When working with nuget.packages you need to reference them via nuget as well
as he explains here
"
As is explained here
"When working with nuget.packages you need to reference them via nuget as well. Thats the reason why it did not work in the first place."