Bart Coppens
Bart Coppens

Reputation: 208

Nuget Pack fails with code NU5012 after upgrade to PackageReference

In our Azure Pipeline, we use the NuGet pack command to pack assemblies and publish them on a private feed. This worked without problems until we upgraded the csproj files to use PackageReference instead of packages.config using the migration procedure (https://learn.microsoft.com/en-us/nuget/consume-packages/migrate-packages-config-to-package-reference).

After migration our pipeline started to fail. Specifically the NuGet pack step fails with the message:

"##[error]The nuget command failed with exit code(1) and error(Error NU5012: Unable to find 'd:\a\1\s[SOLUTION NAME]\MigrationBackup[_SOLUTION DIR]\Base[PROJECT DIR]\bin\Release[PROJECT].dll'. Make sure the project has been built."

Upvotes: 0

Views: 1215

Answers (1)

Bart Coppens
Bart Coppens

Reputation: 208

Turns out the solution was simple: Visual Studio creates a MigrationBackup folder under the solution when migrating from package.config to packagereference. Removing this MigrationBackup folder solved the issue. After the folder was removed the nuget pack command in the pipeline worked correctly again.

Note: don't just remove the solution locally, remove the solution from the repo in DevOps (take a local backup beforehand)

Upvotes: 4

Related Questions