[译]Nuget.Server
NuGet.Server是一个包,可用于使一个ASP.NET应用host一个package feed 。
- 使用VS创建一个新的空WEB应用,添加
Nuget.Server包。 - 配置应用的Packages文件夹,添加包。
- 部署应用到服务器上。
创建部署Nuget.Server ASP.NET应用
- 在VS中选择File > New > Project, 搜索"ASP.NET",选择ASP.NET Web Application (.NET Framework),设置Framework为".NET Framework 4.6":

- 给应用起一个合适的名字,点击OK,在下面的对话框中选择空白模板,点击OK。
- 右键项目,选择Manage NuGet Packages。
- 在包管理器界面中,选择Browse选项,搜索安装最新版本的Nuget.Server包。 (还可在包控制台使用
Install-Pacakge Nuget.Server安装Nuget.Server包。) - 安装Nuget.Server会将空白的web应用转换成了一个package source。它安装了一起其他的包,在web应用的根目录创建了
Packages文件夹,修改了web.config加上了一些配置。
安装完Nuget.Server后,我们要检查下web.config文件。Nuget.Server可能没有覆盖已经存在于web.config中的元素,而是重复的创建了一个。这可能导致服务器内部错误"Internal Server Error" 。例如如果在安装Nuget.Server之前,你的web.config已经包含了
<compilation debug="true" targetFramework="4.5.2" />,那么安装完Nuget.Server后,会多出一个<compilation debug="true" targetFramework="4.6" />。这时,你需要删除老版本的。
- 将要加入的包的 xxx.nupkg文件放到Packages文件夹下面,并将这些.nupkg文件的Build Action设为Content,将Copy to Output Directory设为Copy always:

- 按Ctrl+F5启动网站。首页上会提供package feed URL。如果出现错误,检查web.config去除重复元素。

- 点击上图中的here超级链接,可查看已安装的包。
- The first time you run the application, NuGet.Server restructures the Packages folder to contain a folder for each package. This matches the local storage layout introduced with NuGet 3.3 to improve performance. When adding more packages, continue to follow this structure.
- 一旦本地部署成功了,可以将应用发布到内部或者外部的服务器上。
- 一旦部署到了
http://<domain>,对应的package source的url为http://<domain>/nuget
配置Packages文件夹
在Nuget.Server 1.5 之后,可以在web.config中的 appSetting/packagesPath来指定package文件夹:
<appSettings>
<!-- Set the value here to specify your custom packages folder. -->
<add key="packagesPath" value="C:\MyPackages" />
</appSettings>
packagesPath可以是绝对路径也可以是相对路径。
当packagesPath没有设置或者其值为空白,那么默认的包文件夹为~/Packages。
添加package
一旦Nuget.Server应用运行起来了,可以使用nuget push添加包。
安装完Nuget.Server,web.config会有一个appSetting/apiKey:
<appSettings>
<add key="apiKey" value="" />
</appSettings>
当没有apiKey或者其值为空的时候,push package到feed是禁用的。
设置apiKey并添加appSettings/requireApiKey设置其值为true:
<appSettings>
<!-- Sets whether an API Key is required to push/delete packages -->
<add key="requireApiKey" value="true" />
<!-- Set a shared password (for all users) to push/delete packages -->
<add key="apiKey" value="" />
</appSettings>
可以设置requireApiKey为false。这样所有的人都可以push package了。
删除package
使用nuget delete命令从仓储中删除package。
可以设置web.config中的enableDelisting为true启用delist。
[译]Nuget.Server的更多相关文章
- 搭建公司内部的NuGet Server
随着公司业务慢慢的拓展,项目便会越来越来多,很多项目会依赖其他项目DLL,比如一些底层的技术框架DLL引用,还有各业务系统的也有可能会有引用的可能. 项目多,交叉引用多,如果要是有一个DLL更新,那就 ...
- 分析nuget源码,用nuget + nuget.server实现winform程序的自动更新
源起 (个人理解)包管理最开始应该是从java平台下的maven开始吧,因为java的开发大多数是基于开源组件开发的,一个开源包在使用时很可能要去依赖其他的开源包,而且必须是特定的版本才可以.以往在找 ...
- Nuget Server 搭建
每个女人都有很多包包:其实男人也有,但只有会写程序的男人才有 -- 代码世界中的大"包"小"包".这些大包小包,有花钱买的,有从开源市场淘的,也有自己或同事亲手 ...
- nuget.server搭建及实际测试
1.背景 由于所做项目越来越多,会积累一些公用组件,而每个项目中组件引用中如果组件有更新或者新增为了方便需要一个专门的工具进行管理,那么nuget就是不错的选择. 2.安装nuget.server 这 ...
- .NET持续集成与自动化部署之路第二篇——使用NuGet.Server搭建公司内部的Nuget(包)管理器
使用NuGet.Server搭建公司内部的Nuget(包)管理器 前言 Nuget是一个.NET平台下的开源的项目,它是Visual Studio的扩展.在使用Visual Studio开发基 ...
- 搭建Nuget.Server push时,"Failed to process request. 'Method Not Allowed'"
环境: windows server 2012,已经安装web dev工具. nuget.server版本2.11 输入网站地址正常访问: VS也能正常添加,nuget服务,在项目打包后上传服务器时报 ...
- 使用Docker 快速搭建nuget本地服务器,Hosting private nuget server using docker in seconds!
Server #below line automatically creates the folder, mount the volumes and maps the ports. docker ru ...
- Nuget server on IIS6 returns 404
Nuget server on IIS6 returns 404 when downloading package after upgrade 2011年9月2日 8:03:30 (GMT Dayli ...
- Nuget Server的搭建及实践之旅
一. 背景 在做的一个项目使用的是Asp.Net MVC,由于缺少规范与约束,团队成员在使用类库各自为政,时常出现路径和版本不一致的问题.在一个同事建议下,开始尝试使用Nuget 管理项目或公司使用的 ...
随机推荐
- 洛谷 P1919 【模板】A*B Problem升级版(FFT快速傅里叶)
题目来源 吐槽下P3803都是紫题... 真心好写,本想一遍过的...但是 我真是太菜了... #include<bits/stdc++.h> using namespace std; ; ...
- 第三篇-Django建立数据库各表之间的联系(下)
中篇介绍的是添加,下篇主要介绍查询 通过一个Book表的书的信息查询Publish表中出版社的信息 def addbook(request): # Book.objects.create(name=& ...
- js中同一个onclick绑定了两个js方法出现的问题
问题: js中如果同一个onclick绑定了两个js方法问题,即 <li onclick="f1(),f2()"></li> 两个方法f1,f2中都分别有一 ...
- 函数:PHP将字符串从GBK转换为UTF8字符集iconv
1. iconv()介绍 iconv函数可以将一种已知的字符集文件转换成另一种已知的字符集文件.例如:从GB2312转换为UTF-8. iconv函数在php5中内置,GB字符集默认打开. 2. ic ...
- django系列 1 :python+django环境搭建 +mac提示找不到manage.py命令
1.安装python3 2.设置python3的环境变量 3.进入命令行模式,输入 pip install django 1.10.3 4.验证是否安装完成 pip show django 5.dja ...
- c#大文件的拷贝
using System.IO; namespace 数据流 { class Demo2 { private string _strSourcePath = @"D:\httpd-2.4.3 ...
- (二叉树 BFS DFS) leetcode 111. Minimum Depth of Binary Tree
Given a binary tree, find its minimum depth. The minimum depth is the number of nodes along the shor ...
- POJ3417 LCA+树dp
http://poj.org/problem?id=3417 题意:先给出一棵无根树,然后下面再给出m条边,把这m条边连上,然后每次你能毁掉两条边,规定一条是树边,一条是新边,问有多少种方案能使树断裂 ...
- window下Nexus私服高级搭建
环境是:nexus-2.1.1.maven-3.0.4.jdk-1.6.0_32 一.用admin用户登陆nexus nexus的下载和安装都很简单 1.下载 http://www.sonatype. ...
- python 发送邮件模板
##发送普通txt文件(与发送html邮件不同的是邮件内容设置里的type设置为text,下面代码为发送普通邮件的另一种方法) import smtplibimport stringfrom emai ...