Home News Error Packages Cannot Be Generated? Fix It Right Now

Error Packages Cannot Be Generated? Fix It Right Now



These instructions will help you if you find that error packets cannot be generated.



Why Can’t My Compilation Restore NuGet Packages?

NuGet restore may fail due to various issues. One of the most common problems is embedding a new project in your solution that requires a target framework that is not understood by the NuGet version your assembly is using. This issue usually does not occur on the development machine because Visual Studio updates the NuGet repair engine when new project types are added. We are exploring similar functionality for Azure artifacts. In the meantime, if you are unable to restore packages, you should first try to update NuGet to the latest version.


I’ve never seen this before and angrily started googling. However, he gave very few results, which is a bit strange forAzure DevOps – so many people are already sharing their experiences and best practices that you can usually find someone to fix any issues you might have!

error packages failed to build

In this particular case, however, I just did a few stitches in the dark and guess what value Azure DevOps requires from the “package directory”. Although I’m not sure if it mattered or not, the parameter name is lowercase for me.

After several attempts, I resolved the problem. Hope it works for you too!

 - Task:  [Email secured]   Entries:    restoreSolution: '$ (solution)'    Package directory: '..  packages'

This will restore NuGet packages to solution level. This may not always be what you want, but you can change this by changing the value of restoreSolution and optionally the package directory.

However, for my use case, this is fine, because I am actually creating one project with a solution with several different projects. The variable reference $ (solution) contains the name of the .csproj file.

In case anyone is interested, my entire YAML for this very simple build pipeline looks like this:

YAML example for creating ASP.NET projects
 # ASP.NET# Build and test ASP.NET projects.# Add steps to publish icons, save build artifacts, deploy artifacts, etc.:# https://docs.microsoft.com/azure/devops/pipelines/apps/aspnet/build-aspnet-4trigger:- Master# This particular agent was required to run the .NET Framework versionSwimming pool:  vmImage: 'VS2017-Win2016'Variables:  Solution: "** / [project name] .csproj"  buildPlatform: 'AnyCPU'  buildConfiguration: "Debug"Not:- Task:  [Email protected] - Task:  [Email protected]   Entries:    restoreSolution: '$ (solution)'    Package directory: '..  packages'- Task:  [Email protected]   Entries:    Solution: '$ (solution)'    msbuildArgs: '/ p: DeployOnBuild = true / p: WebPublishMethod = Package / p: PackageAsSingleFile = true / p: SkipInvalidConfigurations = true /p:PackageLocation="$(build.artifactStagingDirectory) "'    Platform: '$ (buildPlatform)'    Configuration: '$ (buildConfiguration)'- Task:  [Email protected]   Contributions:    PathtoPublish: '$ (Build.ArtifactStagingDirectory)'    Artifact name: 'drop'    PublishLocation: "Container"