Extract NuGet packager in Azure DevOps - azure-devops

I am trying to extract Nuget Package in Azure DevOps as part of build. I don't have dedicated plugin in Azure DevOps to unpack Nuget package. I just use zip extractor.
I see some errors,
stderr: 2019-10-25T14:28:54.9806038Z ERROR: Can't allocate required
memory!
I have attached pic as well

How many nuget packages are in your project? As my test, I upload two nuget packages in my project.
If I set the Archive file patterns as *.nupkg
I will get the same error message as yours.
But if I add two Extract files tasks and set the Archive file patterns as below.
The task will run successed.
Hope this will help.

Add the NuGet Restore Task before your build step.

Related

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.

Build is successful on my local but not on vsts azure DevOps

I can successfully build my project on local. When I do via VSTS then build is not successful. I get an error message that a dll cannot be found in my sub project. And it is Rapportage.Logic. The missing dll is used by Rapportage.Logic
Does anyone know the reason?
Most of the time this type of error comes down to:
files present/edited on developer machine but not commited (usually the .csproj file)
subtle differences between Visual Studio build and MSBuild.
I would try the following:
copy the MSBuild command from Azure DevOps logs (the line containing MSBuild.exe)
change the paths in the command to match your dev environment (e.g d:\a\1\s to c:\code\myproject)
run this command
If this command fails with the same error as the build you the problem is a difference between MSbuild and Visaul Studio.
If it succeeds, you most likely have missed a commit.
Build is successful on my local but not on vsts azure DevOps
It depends on how you add ReportViewer references.
If you add the ReportViewer reference manually, you need add the ReportViewer reference to the solution/project folder, then add the reference from that folder. In this case, the path of references are not hard-coded paths. Besides, you need add those/this ReportViewer reference to the source control and submit to the Azure devops repos.
If you add the ReportViewer reference by nuget, you need add the nuget restore task to restore those nuget packages. I could see you are using nuget restore task from your build log (The second image.), but on the build definition, I did not see you have add that task (The 3rd, 4th images.). So, make sure you have restore those packages when you build on the Azure devops, and you could check the restore task if those nuget packages are restored.
Hope this helps.

Cake nuget addin problem with Azure Artifacts

We are started migration from TeamCity+Proget to Azure Pipelines and Azure Artifacts. For builds we use cake scripts and it's a part of problem.
In our cake scripts a lot of #addin nuget:?package=My.Private.Package
Unfortunately cake nuget cannot authenticate on Azure Artifacts, which is required by it. #addin is run before other code inside cake scripts, so i cant add any internal authentication.
Also problem is that we are using Hosted Agents.
So my idea is for resolving it, is download nuget packages from Azure Artifacts (with Download Package steps), unzip them (cause its downloaded as zip files), pack again to nupkg files and somehow add to local cache.
So i got few questions:
1. Maybe somebody know better way to resolve authentication problem between cake addin nuget and Azure Artifacts?
2. If not, how to add to local cache nuget packages from .nupkg files on Hosted Agents without adding it to csproj/sln files. (Dev team is totally against it, cause those packages needed for build and not a part of application).
Will be appreciate for any ideas. Thanks

Create NuGet package from folder

I need to package an Azure function app that we've built in TeamCity as a Nuget package for deployment via Octopus Deploy. Standard practice would be to use MSBuild and OctoPack but with Azure Functions this will not work as the function.json files are created after the build is complete and they would therefore not be included in any package that OctoPack creates.
So I need to build first and then create a package from the \bin\Release\net471 folder. Would be grateful to hear peoples opinions on the best way to acheive this?
In the end I went with octo.exe using a start directory of \bin\Release\net471 which saved me having to create a nuspec file as I would have had to if using the NuGet CLI or dotnet pack

Where is the nuget packages folder located on a hosted build server using TFS?

I need to execute a command line utility from a package that is downloaded as part of nuget package restore in the TFS build process.
On my local computer that is stored in c:\users\me.nuget*
I've tried every permutation of that on TFS without success. I've also tried \mydir\packages with no success as well.
The biggest problem is that I have to run the package restore step before being able to see any sort of feedback from the log. That's some slow debugging.
Any ideas? Thanks ahead.
With the latest nuget/msbuild the packages folder is held under the active user's profile directory, so an appropriate Powershell command is
Get-ChildItem $(UserProfile)\.nuget\packages
This currently evaluates on the VSTS 2017 Hosted build agent to C:\Users\VssAdministrator\.nuget\packages but by using the variable you are insulated from any changes made.
Just an addition to #Paul Hatcher's answer:
I also faced the same problem in Azure DevOps build pipeline where a specific package and nuget packages directory could not be found.
It is a Xamarin.Forms app based on a .net standard library where no packages folder exists. I later noticed in build logs that the packages are restored to nuget folder under user's profile. However this particular case is not documented on https://learn.microsoft.com/en-us/azure/devops/pipelines/build/variables?view=vsts#agent-variables.
That means #Paul Hatcher's answer is also valid if you try to reference nuget package folder directly from your build pipeline. This ($(UserProfile).nuget\packages) should actually be a (standard) predefined build variable.
The Nuget package cache folder is in C:\Users\buildguest.nuget\packages, but it will be cleaned after build if you are using Hosted build server.
The simple way to verify:
Add NuGet restore or .Net Core Restore build step to restore packages
Add PowerShell build step to list files in C:\Users\buildguest.nuget\packages
Code:
Get-ChildItem -Path C:\Users\buildguest\.nuget\packages
Queue build and check the PowerShell step log (the packages’ will be listed in the log)
Remove/disable NuGet restore or .Net Core Restore build step > Save build definition
Queue build
The build will be failed, because the path does not exist.
So, the packages need to be restored before build solution/project if aren’t existing. You can add packages to source control and map to build agent to deal with the issue of too long time takes to restore packages.