ylbtech-NuGet-Doc: NuGet.Server |
1. Back to top |
NuGet.Server
NuGet.Server is provided by the .NET Foundation package, ASP.NET application that created the source packages can be hosted on any server running IIS. In short, NuGet.Server provide a folder on the server via HTTP (especially OData). Set method is very simple, ideal for simple solutions.
- Create an empty in Visual Studio ASP.NET Web application and add NuGet.Server package.
- Configuring the application
Packages
folder and add the package. - The application is deployed to the appropriate client.
The following sections detail the use of C # walkthrough process.
If you have further questions about NuGet.Server, please https://github.com/nuget/NuGetGallery/issues create problems.
NuGet.Server use to create and deploy an ASP.NET Web application
-
In Visual Studio, select "File"> "New"> "project" Search "ASP.NET", choose to apply to the C # "ASP.NET Web Application (.NET Framework)" template, then the "Framework" is set to ".NET Framework 4.6":
-
In addition to providing a suitable name NuGet.Server, and select "OK", select "Empty" template in the next dialog box that appears, then select "OK" for the application.
-
Right-click the project, select "Manage NuGet package."
-
If for .NET Framework 4.6, in the "Package Manager UI", select the "Browser" tab, then search for and install the latest version NuGet.Server package. (You can also use
Install-Package NuGet.Server
the console installed from the package manager.) If prompted, accept the license terms. -
Installation NuGet.Server empty Web application will be converted into a source packet. This will install a variety of other packages, created in the application
Packages
folder, and modifyweb.config
to include other settings (see the comment section of this document for details).important
After NuGet.Server complete package of modifications to the file, double-check
web.config
. NuGet.Server may not overwrite existing elements, and create duplicate elements. When you try to run the project later, these duplicates will lead to "Internal Server Error." For example, ifweb.config
contained before installing NuGet.Server<compilation debug="true" targetFramework="4.5.2" />
, the package will not cover it, but will insert another<compilation debug="true" targetFramework="4.6" />
. In this case, remove the frame has an older version of the element. -
To provide a package in the source when publishing the application to the server, add each
.nupkg
file to the Visual StudioPackages
folder, and then the "Build Action" each file is set to "content", the "Copy to Output Directory "is set to" copy always ": -
In Visual Studio website run locally (using the "Debug"> "started (not debug)" or Ctrl + F5). Home provide package source URL, as shown below. If you find an error, please refer to the previous step 5 double-check
web.config
whether there are duplicate elements. -
单击上述框选区域中的“此处”可查看 OData 包源 。
-
首次运行应用程序时,NuGet.Server 会重新构建
Packages
文件夹,以包含每个包的文件夹。这符合 NuGet 3.3 中引入的用于提高性能的本地存储布局。 添加更多包时,请继续遵照此结构。 -
测试本地部署后,请根据需要将应用程序部署到任何其他内部或外部网站。
-
部署到
http://<domain>
后,用于包源的 URL 将为http://<domain>/nuget
。
配置包文件夹
对于 NuGet.Server
1.5 和更高版本,可使用 web.config
中的 appSetting/packagesPath
值更具体地配置包文件夹:
<appSettings>
<!-- Set the value here to specify your custom packages folder. -->
<add key="packagesPath" value="C:\MyPackages" /> </appSettings>
packagesPath
可以是绝对或虚拟路径。
省略 packagesPath
或将其留空时,包文件夹是默认的 ~/Packages
。
以外部方式向源添加包
NuGet.Server 站点运行后,就可以使用 nuget push 添加包,前提是在 web.config
中设置了 API 密钥值。
安装 NuGet.Server 包后,web.config
包含一个空 appSetting/apiKey
值:
<appSettings>
<add key="apiKey" value="" /> </appSettings>
省略 apiKey
或将其留空时,会禁用向源推送包的功能。
要启用此功能,请设置 apiKey
的值(理想情况下为强密码),并添加值为 true
名为 appSettings/requireApiKey
的密钥:
<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>
如果服务器已受保护或不需要其他 API 密钥(例如,在本地团队网络上使用专用服务器时),可将 requireApiKey
设置为 false
。 然后,有权访问服务器的所有用户均可推送包。
Delete package from the source
When using NuGet.Server, NuGet the Delete command removes a package from the repository, but only contains the API key and notes.
If you want to change behavior to remove the package from the list (leave it package can be used to restore), set web.config
the enableDelisting
Change key to true.
NuGet.Server support
Additional help on using NuGet.Server, please https://github.com/nuget/NuGetGallery/issues create problems.
2. Return to top |
3. Back to top |
4. Top |
5. Top |
6. Back to top |
Author: ylbtech Source: http://ylbtech.cnblogs.com/ This article belongs to the author and blog Park total, welcome to reprint, but without the author's consent declared by this section must be retained, and given the original connection in the apparent position of the article page, otherwise We reserve the right to pursue legal responsibilities. |