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. go语言:类型转换

    类型转换用于将一种类型的变量转换为另一种类型的变量. 有以下场景: package main import "fmt" func main() { var sum int = 17 ...

  2. java.lang.ClassCastException: java.io.ByteArrayInputStream cannot be cast to java.io.FileInputStream

    今天在做文件上传的时候遇到一个这样的问题 java.lang.ClassCastException: java.io.ByteArrayInputStream cannot be cast to ja ...

  3. SPOJ GSS5

    GSS5 - Can you answer these queries V #tree You are given a sequence A[1], A[2], ..., A[N] . ( |A[i] ...

  4. http响应头信息

    HTTP 响应头信息 HTTP请求头提供了关于请求,响应或者其他的发送实体的信息. 在本章节中我们将具体来介绍HTTP响应头信息. 应答头 说明 Allow 服务器支持哪些请求方法(如GET.POST ...

  5. 那些年,我们见过的Java服务端乱象

    导读 查尔斯·狄更斯在<双城记>中写道:“这是一个最好的时代,也是一个最坏的时代.”移动互联网的快速发展,出现了许多新机遇,很多创业者伺机而动:随着行业竞争加剧,互联网红利逐渐消失,很多创 ...

  6. 字符串的trim()用法

      trim() 方法会从一个字符串的两端删除空白字符.在这个上下文中的空白字符是所有的空白字符 (space, tab, no-break space 等) 以及所有行终止符字符(如 LF,CR). ...

  7. Direct2D 第3篇 绘制文字

    原文:Direct2D 第3篇 绘制文字 #include <windows.h> #include <d2d1.h> #include <d2d1helper.h> ...

  8. 大数据技术之HBase

    第1章 HBase简介 1.1 什么是HBase HBase的原型是Google的BigTable论文,受到了该论文思想的启发,目前作为Hadoop的子项目来开发维护,用于支持结构化的数据存储. 官方 ...

  9. SiteMesh:一个优于Apache Tiles的Web页面布局、装饰框架

    一.SiteMesh项目简介 OS(OpenSymphony)的SiteMesh是一个用来在JSP中实现页面布局和装饰(layout and decoration)的框架组件,能够帮助网站开发人员较容 ...

  10. 【itsdangerous】的加密解密原理(易懂版)

    from itsdangerous import TimedJSONWebSignatureSerializer import time from itsdangerous import Signat ...