Gertjan Brouwer
Gertjan Brouwer

Reputation: 1016

Nuget pack Error NU5050 when building Xamarin.Forms

I am attempting to build Xamarin.Forms from source to debug another issue. The XF repository provides a build script which works up until packing the builds into a Nuget package. The final stage called _NugetPack fails with this error:

Attempting to build package from 'Xamarin.Forms.temp.nuspec'. Error NU5050: Attempted to pack multiple files into the same location(s). The following destinations were used multiple times: lib\netstandard2.0\Xamarin.Forms.Core.xml, lib\netstandard2.0\Xamarin.Forms.Xaml.xml, lib\MonoAndroid10.0\Xamarin.Forms.Core.xml, lib\MonoAndroid10.0\Xamarin.Forms.Xaml.xml, lib\Xamarin.iOS10\Xamarin.Forms.Core.xml, lib\Xamarin.iOS10\Xamarin.Forms.Xaml.xml, lib\tizen40\Xamarin.Forms.Platform.Tizen.dll

When calling Nuget directly (without using the build script):

nuget pack ..nuspec\Xamarin.Forms.nuspec -Version 9.9.9 -Properties Configuration=Debug

The same error is thrown. I therefore suspect this not being an issue with the Xamarin.Froms build script, but with my nuget.

Nuget Version: 5.0.0+0-sha.809e75547

Edit I think I figured out the problem. In case of the Tizen one, there are simply 2 of the same lines, thus having duplicate outputs. The others are using ** for globbing. While there is simply 1 directory, thus getting duplicate outputs again. Commenting these out works now.

Upvotes: 2

Views: 2196

Answers (1)

lauxjpn
lauxjpn

Reputation: 5254

This seems to be related to an open issue, documented under Nuget pack allows multiple files with the same path to be added to a package #4388.

There are two ways to solve this issue:

Remove the duplicate source file entries

The Xamarin.Forms.nuspec file contains duplicate source file entries, for example:

<file src="..\build\docs\Xamarin.Forms.Core.xml" target="lib\netstandard2.0" />
<file src="..\build\docs\**\Xamarin.Forms.Core.xml" target="lib\netstandard2.0" />

<file src="..\build\docs\Xamarin.Forms.Xaml.xml" target="lib\netstandard2.0" />
<file src="..\build\docs\**\Xamarin.Forms.Xaml.xml" target="lib\netstandard2.0" />

The src attributes with the ** wildcards references the same file as the explicit ..\build\docs\Xamarin.Forms.Core.xml value.

So to solve the issue, either remove the wildcard entries or the explicit ones, and nuget pack will run fine.

Downgrade Nuget.exe

You can also work around the issue by downloading and using a slightly older version of Nuget.exe like v5.8.1, e.g. by adding its directory to your PATH environment variable, that does not check for duplicate source files yet.

Upvotes: 3

Related Questions