NuGet是一个开放性的组件发布、更新平台。它允许第三方自定义Package source,对于不同开发团队之间的组件版本获取将变的更为轻松。新建一个ASP.NET Empty Web Application,选中项目右键 -> Manage NuGet Packages,在Online -> NuGet official package source中搜索NuGet.Server:
安装完成后,在IIS中默认浏览,站点会返回一个Package source的地址,比如:http://localhost:7004/nuget。打开Visual Studio -> 顶部菜单 -> Tools -> Options -> Package Manager -> Package Sources 添加该地址:
再次打开Manage NuGet Packages -> Online 可以看到新添加的Package source,下载NuGet Package Explorer可以制作自定义package。NuGet允许Package source来自于一个本地或者网络目录。自定义的NuGet Server默认使用当前站点下~/Packages目录,通过修改Web.config -> appSettings的packagesPath修改来源。
<appSettings> <!-- Determines if an Api Key is required to push\delete packages from the server. --> <add key="requireApiKey" value="true" /> <!-- Set the value here to allow people to push/delete packages from the server. NOTE: This is a shared key (password) for all users. --> <add key="apiKey" value="" /> <!-- Change the path to the packages folder. Default is ~/Packages. This can be a virtual or physical path. --> <add key="packagesPath" value="" /> </appSettings>