2018-8-10-win10-uwp-如何打包Nuget给其他人
| 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给其他人的更多相关文章
- win10 uwp 如何打包Nuget给其他人
原文:win10 uwp 如何打包Nuget给其他人 本文告诉大家,如果自己有做一些好用的库,如何使用 Nuget 打包之后上传,分享给大家. 首先需要知道一些 Nuget 打包需要知道的,请看 wi ...
- win10 uwp 上传Nuget 让别人用我们的库
Nuget 我们的开发经常使用别人的dll,那么我们需要每次都从网上下载,然后复制到我们的项目, 而不知道我们的dll是否安全? 当我们的库更新的时候,我们又需要从网上搜索,这样不好,于是我们就用Nu ...
- win10 uwp 使用 Microsoft.Graph 发送邮件
在 2018 年 10 月 13 号参加了 张队长 的 Office 365 训练营 学习如何开发 Office 365 插件和 OAuth 2.0 开发,于是我就使用 UWP 尝试使用 Micros ...
- win10 uwp 毛玻璃
毛玻璃在UWP很简单,不会和WPF那样伤性能. 本文告诉大家,如何在 UWP 使用 win2d 做毛玻璃. 毛玻璃可以使用 win2D 方法,也可以使用 Compositor . 使用 win2d 得 ...
- win10 uwp 读取保存WriteableBitmap 、BitmapImage
我们在UWP,经常使用的图片,数据结构就是 BitmapImage 和 WriteableBitmap.关于 BitmapImage 和 WriteableBitmap 区别,我就不在这里说.主要说的 ...
- win10 uwp 萤火虫效果
原文:win10 uwp 萤火虫效果 本文在Nukepayload2指导下,使用他的思想用C#写出来. 本文告诉大家,如何使用 win2d 做出萤火虫效果. 安装 win2d 安装win2d的方法请使 ...
- win10 uwp 手把手教你使用 asp dotnet core 做 cs 程序
本文是一个非常简单的博客,让大家知道如何使用 asp dot net core 做后台,使用 UWP 或 WPF 等做前台. 本文因为没有什么业务,也不想做管理系统,所以看到起来是很简单. Visua ...
- Win10 UWP系列:更新UWP时注意的问题——TargetDeviceFamily
前几天把CurrencyExchanger提交到微软参加Master认证,结果没有通过,反馈了一些错误,看来微软检查还是比较仔细的. 错误主要有: Visual feedback helps user ...
- Win10 UWP开发实现Bing翻译
微软在WP上的发展从原来的Win7到Win8,Win8.1,到现在的Win10 UWP,什么是UWP,UWP即Windows 10 中的Universal Windows Platform简称.即Wi ...
随机推荐
- 独立版的 Asio安装与使用
Asio分为独立版和Boost版.两者使用方法基本一致,只是头文件不同.Boost版是作为Boost的子库提供的. 因为Asio的组织形式为hpp文件(不同一般的C++项目区分头文件.h和源文件.cp ...
- 使用Docker 安装Elasticsearch、Elasticsearch-head、IK分词器 和使用
原文:使用Docker 安装Elasticsearch.Elasticsearch-head.IK分词器 和使用 Elasticsearch的安装 一.elasticsearch的安装 1.镜像拉取 ...
- Python实例 包机制
每一个.py文件称为一个module,module之间可以互相导入.请参看以下例子: # a.py def add_func(a,b): return a+b # b.py from a im ...
- web前端学习(四)JavaScript学习笔记部分(1)-- JavaScript基础教程
1.JavaScript基础教程 1.1.Javascript基础-介绍.实现.输出 1.1.1.JavaScript是互联网上最流行的脚本语言,这门语言可用于web和HTML,更可广泛用于服务端.p ...
- arcgis显示经纬度
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> ...
- Android——系统权限
Android是一个特权分隔的操作系统,每一个应用程序运行在不同的系统身份中(Linux的user ID和group ID).系统部分和不同的身份被隔离开来.因此,Linux隔离了应用程序(与其它程序 ...
- 学习JDK1.8集合源码之--LinkedList
1. LinkedList简介 LinkedList是一种可以在任何位置进行高效地插入和移除操作的有序序列,它是基于双向链表实现的.因为它实现了Deque接口,所以也是双端队列的一种实现. 2.Lin ...
- Vue.之. 动态设置按钮Disabled
Vue.之. 动态设置按钮Disabled 按钮代码如下: 添加了一个 属性 :disabled="isAble" ,控制:更新按钮.重置按钮 <el-form- ...
- jQuery中的工具和插件
jQuery的工具属性 jQuery类数组操作 length属性 表示获取类数组中元素的个数 get()方法 表示获取类数组中单个元素"括号中填写该元素的索引值" index()方 ...
- python 常规字符匹配