Nuget 使用笔记 纯dll发布

Nuget 使用笔记 纯dll发布

建nuget server


直接创建一个framework版本的空webapi项目,然后nuget管理里安装nuget.server。
web.config里有个apikey的appsetting,填上新建的guid值就好了,可以发布部署到对应的服务器上去。
这里需要把nuget.exe放到项目根文件里去。下载地址

设置VS程序包源


新增一个程序包源,路径为IP或者域名后加上nuget。:http://xxx.nuget.com/nuget

发布dll


由于我是内外网隔离,所以要搬运dll到内网机器里去。前期项目有很多第三方dll。这里要针对dll生成。

下载nuget.exe


这里要借助官方的nuget管理工具nuget.exe。上面有写下载地址。

脚本创建nuget文件


首先将下载好的nuget.exe放入对应文件夹,我这里是D盘Nuget文件夹,打开cmd定位到对应文件夹下
cd D:\Nuget
然后使用nuget.exe,生成 nuspec文件
.\nuget.exe spec testdll
这时,文件夹下会有个testdll.nuspec文件夹。

需要打开,编辑:

<?xml version="1.0" encoding="utf-8"?>
<package >
  <metadata>
    <id>test</id>
    <version>1.0.0</version>
    <authors>wuzy</authors>
    <requireLicenseAcceptance>false</requireLicenseAcceptance>
    <license type="expression">MIT</license>
    <projectUrl>http://project_url_here_or_delete_this_line/</projectUrl>
    <iconUrl>http://icon_url_here_or_delete_this_line/</iconUrl>
    <description>Package description</description>
    <releaseNotes>Summary of changes made in this release of the package.</releaseNotes>
    <copyright>$copyright$</copyright>
    <tags>Tag1 Tag2</tags>
    <dependencies>
      <group targetFramework=".NETStandard2.1">
        <dependency id="SampleDependency" version="1.0.0" />
      </group>
    </dependencies>
  </metadata>
</package>

这里需要把对应的文件内容填好,dll的version,可以右键dll文件查看属性里有对应版本。
producturl,iconurl没有的话,就删除掉这两行。
targetFramework是目标框架版本,可以换成.NetFramework4.5啥的,看需求。

拷贝dll文件


nuspec文件创建好了后,在此文件夹下创建lib文件夹,然后在根据targetFramework创建对应文件夹:如Net40,Net45,Net46等等。
把dll拷贝到对应target目录下。

生成nupkg


在上面运行生成nuspec文件的cmd窗口里,直接运行:

.\nuget.exe pack testdll.nuspec

就会生成了nupkg。

发布


直接执行下面脚本,apikey和source设置为自己的。

.\nuget.exe push testdll.1.0.0.nupkg -apikey xxxxxxx -Source http://xxx.nuget.com/nuget

Nuget.Server Push操作提示404


部署环境IIS7+Net4.6
如果你也遇到这个问题 建议检查下 进程池是不是设置为了经典模式, 如果是需要切换成 集成模式

删除nuget


删除Nuget,在nuget.exe 文件所在的位置,执行

.\nuget.exe delete ConsoleApp1 1.0.0 -Source http://xxx.nuget.com/nuget  -Apikey xxxxxxx
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值