title author date CreateTime categories
win10 uwp 如何打包Nuget给其他人
lindexi
2018-08-10 19:16:50 +0800
2018-2-13 17:23:3 +0800
Win10 UWP

本文告诉大家,如果自己有做一些好用的库,如何使用 Nuget 打包之后上传,分享给大家。

首先需要知道一些 Nuget 打包需要知道的,请看 win10 uwp 上传Nuget 让别人用我们的库

但是 UWP 的包和上面说的有一些不同,需要对打包做一些修改。

可以到 csdn 下载 Nuget 的程序或者到https://www.nuget.org/downloads下载

创建空白的spec

使用 Nuget 命令在空白的文件夹进行创建空白的包,使用命令nuget spec

假如下载的 Nuget 放在 E:\ ,空白文件是 "E:\1" 那么使用的命令就是进入空白文件夹,然后需要写 Nuget 的路径才可以使用。按win+R输入 cmd 打开命令行,然后输入下面代码

E: 进入E盘
cd 1 进入1文件夹
然后把 Nuget 拉进命令行
E:\nuget.exe spec

这时可以看到命令行输出 成功创建

E:\1>E:\nuget.exe spec
已成功创建“Package.nuspec”。

可以看到现在存在 Package.nuspec文件,打开他可以看到下面的东西

<?xml version="1.0"?>
<package >
<metadata>
<id>Package</id>
<version>1.0.0</version>
<authors>lindexi</authors>
<owners>lindexi</owners>
<licenseUrl>http://LICENSE_URL_HERE_OR_DELETE_THIS_LINE</licenseUrl>
<projectUrl>http://PROJECT_URL_HERE_OR_DELETE_THIS_LINE</projectUrl>
<iconUrl>http://ICON_URL_HERE_OR_DELETE_THIS_LINE</iconUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>Package description</description>
<releaseNotes>Summary of changes made in this release of the package.</releaseNotes>
<copyright>Copyright 2017</copyright>
<tags>Tag1 Tag2</tags>
<dependencies>
<dependency id="SampleDependency" version="1.0" />
</dependencies>
</metadata>
</package>

如果你已经看过我上面的博客,那么就知道这些东西是可以如何写,但是 UWP 有一些不同,我现在没有使用上面博客的方法可以成功上传,于是就需要做一些修改。

对空白spec进行修改

首先是版本,现在的版本和id什么都需要自己写,也就是上面的内容都需要自己全部写。如果需要在 description 使用换行,直接回车就好。如果自己的库需要依赖,那么请修改 dependencies ,依赖的版本参见

创建简单的库

上面写的叫 metadata ,写完之后可以创建一个新的 UWP 库,我在这创建一个叫 NrzlmhRzvy 的库

在里面创建一个类

批量创建不同平台 dll 可以给不同的需要

右击解决方法批处理

可以看到有很多的方法,点全选

点击重新生成

可以看到生成了很多文件

打包

接下来就是创建 Nuget ,首先需要把空白的包放到库的文件夹,这里创建的库是E:\1\NrzlmhRzvy\所以把Package.nuspec放在E:\1\NrzlmhRzvy,现在使用 SublimeText打开这个spec,对他做一些修改

<?xml version="1.0"?>
<package >
<metadata>
这里不写
</metadata>
<files>
这里写文件
</files> </package>

添加文件就是写文件的放在哪,在使用nuget会按照放在的位置,在不同的平台使用库,如果写错了,使用这个库的程序就无法使用,这里需要添加的文件有不同平台的,请看下面的代码

        <file src=".\NrzlmhRzvy\bin\ARM\Debug\NrzlmhRzvy.dll" target="runtimes\win10-arm\lib\uap10.0"/>
<file src=".\NrzlmhRzvy\bin\ARM\Debug\NrzlmhRzvy.pdb" target="runtimes\win10-arm\lib\uap10.0"/>
<file src=".\NrzlmhRzvy\bin\ARM\Debug\NrzlmhRzvy.pri" target="runtimes\win10-arm\lib\uap10.0"/> <file src=".\NrzlmhRzvy\bin\x64\Debug\NrzlmhRzvy.dll" target="runtimes\win10-x64\lib\uap10.0"/>
<file src=".\NrzlmhRzvy\bin\x64\Debug\NrzlmhRzvy.pdb" target="runtimes\win10-x64\lib\uap10.0"/>
<file src=".\NrzlmhRzvy\bin\x64\Debug\NrzlmhRzvy.pri" target="runtimes\win10-x64\lib\uap10.0"/> <file src=".\NrzlmhRzvy\bin\x86\Debug\NrzlmhRzvy.dll" target="runtimes\win10-x86\lib\uap10.0"/>
<file src=".\NrzlmhRzvy\bin\x86\Debug\NrzlmhRzvy.pdb" target="runtimes\win10-x86\lib\uap10.0"/>
<file src=".\NrzlmhRzvy\bin\x86\Debug\NrzlmhRzvy.pri" target="runtimes\win10-x86\lib\uap10.0"/>

还需要添加入口,现在的代码如果使用,就会出现 提供了编译时引用程序集,但没有与 win10-arm 兼容的运行时程序集 所以需要添加 ref 请看下面

        <file src=".\NrzlmhRzvy\bin\Debug\NrzlmhRzvy.dll" target="ref\uap10.0"/>
<file src=".\NrzlmhRzvy\bin\Debug\NrzlmhRzvy.pdb" target="ref\uap10.0"/>
<file src=".\NrzlmhRzvy\bin\Debug\NrzlmhRzvy.pri" target="ref\uap10.0"/>

于是现在的 spec 就是下面的代码

<?xml version="1.0"?>
<package >
<metadata>
<id>Package</id>
<version>1.0.0</version>
<authors>lindexi</authors>
<owners>lindexi</owners>
<licenseUrl>http://LICENSE_URL_HERE_OR_DELETE_THIS_LINE</licenseUrl>
<projectUrl>http://PROJECT_URL_HERE_OR_DELETE_THIS_LINE</projectUrl>
<iconUrl>http://ICON_URL_HERE_OR_DELETE_THIS_LINE</iconUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>Package description</description>
<releaseNotes>Summary of changes made in this release of the package.</releaseNotes>
<copyright>Copyright 2017</copyright>
<tags>Tag1 Tag2</tags>
<!-- <dependencies>
<dependency id="SampleDependency" version="1.0" />
</dependencies> -->
</metadata>
<files>
<file src=".\NrzlmhRzvy\bin\ARM\Debug\NrzlmhRzvy.dll" target="runtimes\win10-arm\lib\uap10.0"/>
<file src=".\NrzlmhRzvy\bin\ARM\Debug\NrzlmhRzvy.pdb" target="runtimes\win10-arm\lib\uap10.0"/>
<file src=".\NrzlmhRzvy\bin\ARM\Debug\NrzlmhRzvy.pri" target="runtimes\win10-arm\lib\uap10.0"/> <file src=".\NrzlmhRzvy\bin\x64\Debug\NrzlmhRzvy.dll" target="runtimes\win10-x64\lib\uap10.0"/>
<file src=".\NrzlmhRzvy\bin\x64\Debug\NrzlmhRzvy.pdb" target="runtimes\win10-x64\lib\uap10.0"/>
<file src=".\NrzlmhRzvy\bin\x64\Debug\NrzlmhRzvy.pri" target="runtimes\win10-x64\lib\uap10.0"/> <file src=".\NrzlmhRzvy\bin\x86\Debug\NrzlmhRzvy.dll" target="runtimes\win10-x86\lib\uap10.0"/>
<file src=".\NrzlmhRzvy\bin\x86\Debug\NrzlmhRzvy.pdb" target="runtimes\win10-x86\lib\uap10.0"/>
<file src=".\NrzlmhRzvy\bin\x86\Debug\NrzlmhRzvy.pri" target="runtimes\win10-x86\lib\uap10.0"/> <file src=".\NrzlmhRzvy\bin\Debug\NrzlmhRzvy.dll" target="ref\uap10.0"/>
<file src=".\NrzlmhRzvy\bin\Debug\NrzlmhRzvy.pdb" target="ref\uap10.0"/>
<file src=".\NrzlmhRzvy\bin\Debug\NrzlmhRzvy.pri" target="ref\uap10.0"/> </files>
</package>

然后尝试使用本地的库,新建另一个项目,打开Nuget命令行,输入下面的代码

install-package Package -Source E:\1\NrzlmhRzvy

或者点击选项打开 Nuget 管理,输入本地地址

这样就可以添加打包的库,安装之后需要重新编译才可以使用

如果发现安装还没发现这个程序的类,那么重新编译可能就可以使用。如果发现安装提示不兼容,找不到库,就需要升级库的版本,然后重新生成。

但是这样可以看到,虽然库可以使用,但是没有注释,因为生成没有注释,如果需要注释,那么需要在库右击属性,生成,输出 xml ,实际上输出一份就好了,自己把他复制到各个平台。

或者在生成那里点击输出 xml文档,选择所有的平台,然后修改包的内容,添加输出的xml,这样就可以使用注释

下面就是整个spec的内容

<?xml version="1.0"?>
<package >
<metadata>
<id>lindexi</id>
<version>1.0.2</version>
<authors>lindexi</authors>
<owners>lindexi</owners>
<licenseUrl>http://lindexi.oschina.io</licenseUrl>
<projectUrl>http://lindexi.oschina.io</projectUrl>
<iconUrl>http://lindexi.oschina.io</iconUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description> description</description>
<releaseNotes></releaseNotes>
<copyright>Copyright 2017</copyright>
<tags>Tag1 </tags>
</metadata>
<files>
<file src=".\NrzlmhRzvy\bin\ARM\Debug\NrzlmhRzvy.dll" target="runtimes\win10-arm\lib\uap10.0"/>
<file src=".\NrzlmhRzvy\bin\ARM\Debug\NrzlmhRzvy.pdb" target="runtimes\win10-arm\lib\uap10.0"/>
<file src=".\NrzlmhRzvy\bin\ARM\Debug\NrzlmhRzvy.XML" target="runtimes\win10-arm\lib\uap10.0"/>
<file src=".\NrzlmhRzvy\bin\ARM\Debug\NrzlmhRzvy.pri" target="runtimes\win10-arm\lib\uap10.0"/> <file src=".\NrzlmhRzvy\bin\x64\Debug\NrzlmhRzvy.dll" target="runtimes\win10-x64\lib\uap10.0"/>
<file src=".\NrzlmhRzvy\bin\x64\Debug\NrzlmhRzvy.pdb" target="runtimes\win10-x64\lib\uap10.0"/>
<file src=".\NrzlmhRzvy\bin\x64\Debug\NrzlmhRzvy.XML" target="runtimes\win10-x64\lib\uap10.0"/>
<file src=".\NrzlmhRzvy\bin\x64\Debug\NrzlmhRzvy.pri" target="runtimes\win10-x64\lib\uap10.0"/> <file src=".\NrzlmhRzvy\bin\x86\Debug\NrzlmhRzvy.dll" target="runtimes\win10-x86\lib\uap10.0"/>
<file src=".\NrzlmhRzvy\bin\x86\Debug\NrzlmhRzvy.pdb" target="runtimes\win10-x86\lib\uap10.0"/>
<file src=".\NrzlmhRzvy\bin\x86\Debug\NrzlmhRzvy.XML" target="runtimes\win10-x86\lib\uap10.0"/>
<file src=".\NrzlmhRzvy\bin\x86\Debug\NrzlmhRzvy.pri" target="runtimes\win10-x86\lib\uap10.0"/> <file src=".\NrzlmhRzvy\bin\Debug\NrzlmhRzvy.dll" target="ref\uap10.0"/>
<file src=".\NrzlmhRzvy\bin\Debug\NrzlmhRzvy.pdb" target="ref\uap10.0"/>
<file src=".\NrzlmhRzvy\bin\Debug\NrzlmhRzvy.pri" target="ref\uap10.0"/>
<file src=".\NrzlmhRzvy\bin\Debug\NrzlmhRzvy.XML" target="ref\uap10.0"/> </files>
</package>

2018-8-10-win10-uwp-如何打包Nuget给其他人的更多相关文章

  1. win10 uwp 如何打包Nuget给其他人

    原文:win10 uwp 如何打包Nuget给其他人 本文告诉大家,如果自己有做一些好用的库,如何使用 Nuget 打包之后上传,分享给大家. 首先需要知道一些 Nuget 打包需要知道的,请看 wi ...

  2. win10 uwp 上传Nuget 让别人用我们的库

    Nuget 我们的开发经常使用别人的dll,那么我们需要每次都从网上下载,然后复制到我们的项目, 而不知道我们的dll是否安全? 当我们的库更新的时候,我们又需要从网上搜索,这样不好,于是我们就用Nu ...

  3. win10 uwp 使用 Microsoft.Graph 发送邮件

    在 2018 年 10 月 13 号参加了 张队长 的 Office 365 训练营 学习如何开发 Office 365 插件和 OAuth 2.0 开发,于是我就使用 UWP 尝试使用 Micros ...

  4. win10 uwp 毛玻璃

    毛玻璃在UWP很简单,不会和WPF那样伤性能. 本文告诉大家,如何在 UWP 使用 win2d 做毛玻璃. 毛玻璃可以使用 win2D 方法,也可以使用 Compositor . 使用 win2d 得 ...

  5. win10 uwp 读取保存WriteableBitmap 、BitmapImage

    我们在UWP,经常使用的图片,数据结构就是 BitmapImage 和 WriteableBitmap.关于 BitmapImage 和 WriteableBitmap 区别,我就不在这里说.主要说的 ...

  6. win10 uwp 萤火虫效果

    原文:win10 uwp 萤火虫效果 本文在Nukepayload2指导下,使用他的思想用C#写出来. 本文告诉大家,如何使用 win2d 做出萤火虫效果. 安装 win2d 安装win2d的方法请使 ...

  7. win10 uwp 手把手教你使用 asp dotnet core 做 cs 程序

    本文是一个非常简单的博客,让大家知道如何使用 asp dot net core 做后台,使用 UWP 或 WPF 等做前台. 本文因为没有什么业务,也不想做管理系统,所以看到起来是很简单. Visua ...

  8. Win10 UWP系列:更新UWP时注意的问题——TargetDeviceFamily

    前几天把CurrencyExchanger提交到微软参加Master认证,结果没有通过,反馈了一些错误,看来微软检查还是比较仔细的. 错误主要有: Visual feedback helps user ...

  9. Win10 UWP开发实现Bing翻译

    微软在WP上的发展从原来的Win7到Win8,Win8.1,到现在的Win10 UWP,什么是UWP,UWP即Windows 10 中的Universal Windows Platform简称.即Wi ...

随机推荐

  1. spring boot自动配置之jdbc(转)

    1.DataSource配置 1.1 默认配置application.xml spring.datasource.url=jdbc:mysql://localhost/test spring.data ...

  2. 洛谷P2178 [NOI2015]品酒大会

    题目描述 一年一度的“幻影阁夏日品酒大会”隆重开幕了.大会包含品尝和趣味挑战 两个环节,分别向优胜者颁发“首席品酒家”和“首席猎手”两个奖项,吸引了众多品酒师参加. 在大会的晚餐上,调酒师 Rainb ...

  3. Leetcode15.3Sum三数之和

    给定一个包含 n 个整数的数组 nums,判断 nums 中是否存在三个元素 a,b,c ,使得 a + b + c = 0 ?找出所有满足条件且不重复的三元组. 注意:答案中不可以包含重复的三元组. ...

  4. 2019阿里云开年Hi购季域名与商标分会场全攻略!

    2019阿里云云上Hi购季活动已经于2月25日正式开启,从已开放的活动页面来看,活动分为三个阶段: 2月25日-3月04日的活动报名阶段.3月04日-3月16日的新购满返+5折抢购阶段.3月16日-3 ...

  5. Excel按照某一列的重复数据设置隔行变颜色效果

    问题:如图所示,想按照A列中的重复数据设置隔重复行变颜色的效果,能否通过条件格式命令实现. 方法1:(最佳答案) 条件格式公式:=MOD(SUMPRODUCT(--($A$1:$A1<>$ ...

  6. No.6 Verilog 其他论题

    (1)任务  **任务类似于一段程序,可以提供一种能力,使设计者可以从设计描述的不同位置执行共同的代码段.任务可以包含时序控制, 可以调用其它任务和函数.  任务的定义格式: task[automat ...

  7. Spring boot--控制器增强

    在Spring3.2中,新增了@ControllerAdvice注解.关于这个注解的官方说明https://docs.spring.io/spring-framework/docs/5.0.0.M1/ ...

  8. Duplicate a whole line in Vim

    yy or Y to copy the line or dd to delete (cutting) the line then p to paste the copied or deleted te ...

  9. PHP文件载入和载入路径

    一.文件载入 所谓的文件的载入,就是指将需要的目标文件的代码载入到当前的位置上,从某种意义上来说,文件载入也是一种流程控制! 文件载入的主要目的是体现网站的分层设计,因为不同的页面有很多相同的区域(相 ...

  10. Codeforces 439C

    题目链接 比赛时间没能通过==, 只能说明自己代码写的太不严谨咯! 解题思想就是贪心 先判断无解的情况: 1. 奇数不够,因为偶数是无法凑成奇数的 2. 偶数不够,2个奇数可以凑成一个偶数 3. 在奇 ...