There are many infrastructure or infrastructure components within the company, and even for companies that use SOA architectures, there will be a large number of contractual assemblies for business components, and the use of source control tools for reference management of those frameworks or components, but NuGet is more convenient than source control tools:
1) Install and uninstall: You do not need to manually add and remove references, you do not need to manually overwrite the configuration file or even some code that initializes the service. The version upgrade also requires only one command to execute.
2) Packaging: Multi-file packaging, support dependency management, etc., the use of people without cumbersome configuration.
For the official package, can be found in http://www.nuget.org/, you can also submit the package up. But if you don't want to expose the package, you can set up a nuget server inside.
Here are the basic steps and how to package them.
1) Download Nugetserver.rar (contains source code, adapted from Mceranski-nugetserver, cannot find the original) compiled, published to the intranet server. This MVC3 website has several features:
One is to provide nuget services that provide information for all packages for use by the NuGet Package Manager in VS2010
The second is to provide a few pages, you can upload the package can also browse all the packages
The third is to provide a Web service for the program to automatically upload the package after compiling
2) Download the Lib.rar (executable file only) and unzip it to the Lib directory in the solution directory. Two programs are available in this compact package:
One is the official website provides the NuGet.exe small tool, may package the file to call Nupkg
The second is to write your own one upload package to the NuGet Server Web service gadget, here is the source code, it will upload the latest compilation of the package
3) Configure the properties of the items that need to be packaged:
IF not "$ (configurationname)" = = "Release" Exit/b 0
IF not EXIST $ (solutiondir) releasepackages MD $ (solutiondir) releasepackages
$ (SolutionDir) Libs\nuget.exe Pack $ (ProjectDir) $ (ProjectName). Nuspec-o $ (SolutionDir) releasepackages\
$ (SolutionDir) Libs\nugetpackageuploader.exe $ (solutiondir) releasepackages\
The function that this script completes is:
If the release method is compiled, first create the Releasepackages folder, then call NuGet.exe package, and finally call NuGetPackageUploader.exe upload Package
4) Create the [project name].nuspec, package description file in the project:
<?xml version= "1.0" encoding= "Utf-8"?>
<package>
<metadata>
<id>WcfExtension</id>
<version>1.0.0.0</version>
<title>WcfExtension</title>
<authors> author </authors>
<projectUrl> Project Address </projectUrl>
<DESCRIPTION>A communication framework based on wcf</description>
</metadata>
<files>
<file src= "Bin\release\*.dll" target= "Lib"/>
<file src= "Bin\release\*.transform" target= "content"/>
</files>
</package>
Here, we put all the DLLs into the package, and also the transform file used to convert the configuration file into the package.
In order to automatically add nodes to the configuration file, we create App.config.transform and Web.config.transform under the project file, set to:
The file content is the same as the normal configuration file:
<?xml version= "1.0" encoding= "Utf-8"?>
<configuration>
<configSections>
<section name= "Unity" type= "Microsoft.Practices.Unity.Configuration.UnityConfigurationSection, Microsoft.Practices.Unity.Configuration "/>
</configSections>
<appSettings>
<add key= "configservice_address" value= "192.168.129.11:1888/wcfconfigservice.svc"/>
<add key= "logservice_address" value= "192.168.129.12:1889/wcflogservice.svc"/>
<add key= "redis_address" value= "192.168.129.175"/>
<add key= "Redis_message_client_channel" value= "Wcfconfigclientchange"/>
<add key= "Redis_message_service_channel" value= "Wcfconfigservicechange"/>
</appSettings>
<unity configsource= "Unity.config"/>
</configuration>
5) After compiling the project with release, you can discover that there is one more package in the releasepackages, and that the package will be uploaded to the remote NuGet server.
If the upload is not successful, check to see if the address in NuGetPackageUploader.exe.config is modified to the address of the server you are deploying.
6) After installing the VS2010 NuGet Package Manager plugin on the website:
Configuring the NuGet server address should allow you to see all the packages you have uploaded:
If your site is deployed to nuget.xxx.com, then the address here is filled with nuget.xxx.com/nuget.
Find the package Click the Install button to install the component.
Open the Package Manager console and enter Get-help NuGet to see some other commands:
------------------ ----------------------------------------------
Get-package Gets The set of packages available from the package source.
Install-package installs a package and its dependencies into the project.
Uninstall-package uninstalls a package. If and packages depend on the This package,
The command would fail unless the–force option is specified.
Update-package Updates A package and its dependencies to a newer version.
new-package Creates a new package is supplied with a NUSPEC package specification file.
Add-bindingredirect examines all assemblies within the output path for a project and adds binding
Redirects to the application (or Web) configuration file where necessary.
Get-project Returns A reference to the DTE (development Tools Environment) for the active
or specified project.
Transferred from: http://www.cnblogs.com/lovecindywang/archive/2011/05/12/2044301.html
Build the NuGet server internally