如何以现代通用的方式打包一个具有以下特性的.NET库?
- 为.NET Framework 4.6和Universal Windows Platform提供一些共享功能。
- 为每个平台提供一些特定功能(例如专用类或API,包括UWP的XAML用户控件),并可能依赖于外部库的特定平台。
- 架构无关(AnyCPU)。
- 其可移植子集可以被其他针对兼容API表面的可移植库使用。
如何以现代通用的方式打包一个具有以下特性的.NET库?
\---lib
+---dotnet
| MyPortableLibrary.dll
| MyPortableLibrary.pdb
| MyPortableLibrary.XML
|
+---net46
| MyDotNetLibrary.dll
| MyDotNetLibrary.pdb
| MyDotNetLibrary.XML
| MyPortableLibrary.dll
| MyPortableLibrary.pdb
| MyPortableLibrary.XML
|
\---uap10.0
| MyPortableLibrary.dll
| MyPortableLibrary.pdb
| MyPortableLibrary.XML
| MyUwpLibrary.dll
| MyUwpLibrary.pdb
| MyUwpLibrary.pri
| MyUwpLibrary.XML
|
\---MyUwpLibrary
HashControl.xaml
MyUwpLibrary.xr.xml
<?xml version="1.0"?>
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata minClientVersion="3.2">
<id>Example.MyMultiSurfaceLibrary</id>
<version>1.0.0</version>
<authors>Firstname Lastname</authors>
<description>Example of a multi-platform library that exposes different API surfaces to .NET 4.6 and UWP and also includes a portable component.</description>
<dependencies>
<!-- UWP has more dependencies than other platforms (Newtonsoft.Json). -->
<group targetFramework="uap10.0">
<dependency id="Newtonsoft.Json" version="8.0.1" />
<dependency id="System.Linq" version="4.0.0" />
<dependency id="System.Numerics.Vectors" version="4.1.0" />
<dependency id="System.Resources.ResourceManager" version="4.0.0" />
<dependency id="System.Runtime" version="4.0.20" />
</group>
<!-- All other platforms - just the dependencies of the portable library here. -->
<group>
<dependency id="System.Linq" version="4.0.0" />
<dependency id="System.Numerics.Vectors" version="4.1.0" />
<dependency id="System.Resources.ResourceManager" version="4.0.0" />
<dependency id="System.Runtime" version="4.0.20" />
</group>
</dependencies>
</metadata>
<files>
<file src="..\bin\Release\MyPortableLibrary.*" target="lib\net46" />
<file src="..\bin\Release\MyPortableLibrary.*" target="lib\uap10.0" />
<file src="..\bin\Release\MyPortableLibrary.*" target="lib\dotnet" />
<file src="..\..\MyDotNetLibrary\bin\Release\MyDotNetLibrary.*" target="lib\net46" />
<!-- Double wildcard also ensures that the subdirectory is packaged. -->
<file src="..\..\MyUwpLibrary\bin\Release\MyUwpLibrary**" target="lib\uap10.0" />
</files>
</package>