我有一个具有以下结构的nuspec文件
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd">
<metadata>
<id>XLabs.Forms</id>
<version>2.2.0-pre05</version>
<title>XLabs - Forms</title>
<authors>XLabs Team</authors>
<owners>XLabs Team</owners>
<licenseUrl>https://github.com/XLabs/Xamarin-Forms-Labs/blob/master/LICENSE</licenseUrl>
<projectUrl>https://github.com/XLabs/Xamarin-Forms-Labs</projectUrl>
<iconUrl>https://raw.githubusercontent.com/XLabs/Xamarin-Forms-Labs/master/Design/Icons/nuget/icon_nuget.png</iconUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>This package contains the cross-platform XLabs Forms framework and controls.</description>
<summary>XLabs is a open source project that aims to provide a powerfull and cross platform set of controls tailored to work with Xamarin Forms.</summary>
<releaseNotes>Updated for Xamarin Forms 2.2</releaseNotes>
<copyright>Copyright © 2016 XLabs Team</copyright>
<tags>Xamarin XLabs Forms Controls GridView ListView</tags>
<dependencies>
<group>
<dependency id="XLabs.Platform" version="[2.2.0-pre05]" />
<dependency id="Xamarin.Forms" version="2.2.0.31" />
</group>
</dependencies>
</metadata>
<files>
<!-- Assemblies: Android -->
<file src="..\..\source\Forms\XLabs.Forms\bin\$configuration$\XLabs.Forms.dll" target="lib\monoandroid" />
<file src="..\..\source\Forms\XLabs.Forms\bin\$configuration$\XLabs.Forms.pdb" target="lib\monoandroid" />
<file src="..\..\source\Forms\XLabs.Forms.Droid\bin\$configuration$\XLabs.Forms.Droid.dll" target="lib\monoandroid" />
<file src="..\..\source\Forms\XLabs.Forms.Droid\bin\$configuration$\XLabs.Forms.Droid.pdb" target="lib\monoandroid" />
<!-- Assemblies: iOS -->
<file src="..\..\source\Forms\XLabs.Forms\bin\$configuration$\XLabs.Forms.dll" target="lib\Xamarin.iOS10" />
<file src="..\..\source\Forms\XLabs.Forms\bin\$configuration$\XLabs.Forms.pdb" target="lib\Xamarin.iOS10" />
<file src="..\..\source\Forms\XLabs.Forms.iOS\bin\$configuration$\XLabs.Forms.iOS.pdb" target="lib\Xamarin.iOS10" />
<file src="..\..\source\Forms\XLabs.Forms.iOS\bin\$configuration$\XLabs.Forms.iOS.dll" target="lib\Xamarin.iOS10" />
</files>
</package>
它让我有点疯狂:)用这个nuspec创建的nupkg文件应该只安装在Xamarin iOS或基础Xamarin Android项目中吗?不是这样,它安装在任何类型的项目(PCL,Windows 10,Windows 8等)中。我不知道还有什么办法可以限制软件包,以便它只能安装在我需要的目标中。
任何人都可以看到我可能做错了吗?
更新:这是我尝试过的最新版本的nuspec文件仍然无法正常工作。以下将创建一个安装在Windows 8,Windows Mobile和PCL项目中的软件包,即使它只包含Android基础程序集
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd">
<metadata>
<id>XLabs.Forms</id>
<version>2.2.0-pre05</version>
<title>XLabs - Forms</title>
<authors>XLabs Team</authors>
<owners>XLabs Team</owners>
<licenseUrl>https://github.com/XLabs/Xamarin-Forms-Labs/blob/master/LICENSE</licenseUrl>
<projectUrl>https://github.com/XLabs/Xamarin-Forms-Labs</projectUrl>
<iconUrl>https://raw.githubusercontent.com/XLabs/Xamarin-Forms-Labs/master/Design/Icons/nuget/icon_nuget.png</iconUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>This package contains the cross-platform XLabs Forms framework and controls.</description>
<summary>XLabs is a open source project that aims to provide a powerfull and cross platform set of controls tailored to work with Xamarin Forms.</summary>
<releaseNotes>Updated for Xamarin Forms 2.2</releaseNotes>
<copyright>Copyright © 2016 XLabs Team</copyright>
<tags>Xamarin XLabs Forms Controls GridView ListView</tags>
<dependencies>
<group targetFramework="monoandroid">
<dependency id="XLabs.Core" version="[2.2.0-pre05]" />
<dependency id="XLabs.IoC" version="[2.2.0-pre05]" />
<dependency id="XLabs.Platform" version="[2.2.0-pre05]" />
<dependency id="XLabs.Serialization" version="[2.2.0-pre05]" />
<dependency id="Xamarin.Forms" version="2.2.0.31" />
</group>
</dependencies>
</metadata>
<files>
<!-- Content Files -->
<file src="..\..\docs\XLabs.Forms.Readme.md" target="content\XLabs.Forms.Readme.md" />
<!-- Assemblies: Android -->
<file src="..\..\source\Forms\XLabs.Forms\bin\$configuration$\XLabs.Forms.dll" target="lib\monoandroid" />
<file src="..\..\source\Forms\XLabs.Forms\bin\$configuration$\XLabs.Forms.pdb" target="lib\monoandroid" />
<file src="..\..\source\Forms\XLabs.Forms.Droid\bin\$configuration$\XLabs.Forms.Droid.dll" target="lib\monoandroid" />
<file src="..\..\source\Forms\XLabs.Forms.Droid\bin\$configuration$\XLabs.Forms.Droid.pdb" target="lib\monoandroid" />
</files>
</package>
答案 0 :(得分:0)
我认为这是因为你有一个没有目标框架的组依赖。组依赖将导致NuGet安装Xamarin.Forms和XLabs.Platform NuGet包,而lib目录中的程序集将不会被使用,除非您要安装到iOS或Android项目中。
我会尝试为iOS和Android添加目标框架。
<group targetFramework="Xamarin.iOS10">
<dependency id="XLabs.Platform" version="[2.2.0-pre05]" />
<dependency id="Xamarin.Forms" version="2.2.0.31" />
</group>
<group targetFramework="MonoAndroid">
<dependency id="XLabs.Platform" version="[2.2.0-pre05]" />
<dependency id="Xamarin.Forms" version="2.2.0.31" />
</group>
答案 1 :(得分:0)
原来问题在于这一行
<!-- Content Files -->
<file src="..\..\docs\XLabs.Forms.Readme.md" target="content\XLabs.Forms.Readme.md" />
由于它没有目标名字对象,因此对所有目标框架都有效。一旦我删除它,一切都开始工作。我认为nuspec文件格式在其文档中需要更多细节:)