来自 PCL 的 NuGet 包 [英] NuGet package from PCL
问题描述
我有一个 PCL 库,我想作为 NuGet 包分发.
PCL 应用程序库属性页面的屏幕截图:
csproj 文件:
v4.5 <TargetFrameworkProfile>Profile111</TargetFrameworkProfile><ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
重现我的问题的步骤:
从以下位置克隆两个存储库:
2.将该软件包安装到两个项目中:
从GitHub下载这两个测试项目,用Visual Studio 2017打开,然后将创建的包复制到本地nuget提要:
打开包管理器控制台,使用以下命令安装包:
install-package My.Package -source D:\LocalServer
因此 nuget 包在两个项目中都正确安装.
注意:我在您的控制台应用程序的项目文件中看到了以下代码:
<PackageReference Include="My.Package"><版本>1.0.0</版本></PackageReference></项目组> 请删除它,这不是添加 nuget 包的正确方法.
I have a PCL library I want to distribute as NuGet package.
Screenshot of the PCL application library properties page:
csproj file:
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion> <TargetFrameworkProfile>Profile111</TargetFrameworkProfile> <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
Steps to reproduce my problem:
Clone both repos from:
Build the NugetPackage project +
nuget spec
+nuget pack
- Create a local nuget package repository pointing to the project folder.
- Open the NugetConsole solution and try installing the package in both projects.
Some references I used:
- https://docs.microsoft.com/en-us/nuget/schema/target-frameworks
- https://docs.microsoft.com/en-us/nuget/schema/nuspec
- https://portablelibraryprofiles.stephencleary.com/
- http://blog.stephencleary.com/2012/05/framework-profiles-in-net.html
解决方案How can I make a nuget package from a PCL library and use it in a PCL library?
I have downloaded your nuget package and test projects, I can created the nuget package and installed it to the both projects. Following are my detailed steps:
1. Create nuget package:
Download the nuget project, then build the project+
nuget spec
+nuget pack
:Here is the
.nuspec
file:<?xml version="1.0"?> <package > <metadata> <id>My.Package</id> <version>1.0.0</version> <authors>Tester</authors> <owners>Tester</owners> <requireLicenseAcceptance>false</requireLicenseAcceptance> <description>Package description</description> <releaseNotes>Summary of changes made in this release of the package.</releaseNotes> <copyright>Copyright 2018</copyright> <tags>Tag1 Tag2</tags> </metadata> <files> <file src="bin\**" target="lib\portable-net45+wp8\" /> </files> </package>
Note: Since you are planning use this package into PCL library, so the target should be
.net45
+Profile49
, according to the document Portable Class Library (PCL) profiles, nuget target should be portable-net45+wp8:2. Install that package to both projects:
Download those two test projects from GitHub, and open it with Visual Studio 2017, then copy the created package to the local nuget feed:
Open Package manager Console, install the package with following command:
install-package My.Package -source D:\LocalServer
So the nuget package is correct install in both projects.
Note: I have seen following code in your project file of console application:
<ItemGroup> <PackageReference Include="My.Package"> <Version>1.0.0</Version> </PackageReference> </ItemGroup>
Please remove it, this is not a correct way to add nuget package.
这篇关于来自 PCL 的 NuGet 包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!