构建Xamarin.Forms源码打包Nuget时出现NU5050错误怎么解决?
我尝试从源码构建Xamarin.Forms以调试其他问题,XF仓库提供的构建脚本在打包Nuget包之前的环节全部运行正常,在名为_NugetPack的最终阶段抛出以下报错:
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
我绕过构建脚本直接执行Nuget命令也复现了相同错误,执行的命令如下:nuget pack ..nuspec\Xamarin.Forms.nuspec -Version 9.9.9 -Properties Configuration=Debug
最初我怀疑问题和我使用的Nuget版本有关,所用版本为5.0.0+0-sha.809e75547,后续排查确认和版本无关。
问题根因及解决方法
- Tizen平台相关的配置存在两条完全重复的条目,导致同一份文件被两次指定输出到同一个路径
- 其余报错的文件条目是因为通配符匹配规则触发了重复输出,即使仅存在一个匹配目录也会触发该问题
- 直接注释掉nuspec配置文件里的重复条目即可解决该报错
内容的提问来源于stack exchange,提问作者Gertjan Brouwer

