1. Origin
In our project. The components that need to be referenced are uniformly placed under a Libs folder. Regardless of the common components on the platform. or the application module, all the same.
Suppose an application module, such as energy Management (EM). To refer to common components provided by the platform, such as database access (platform.pl). So not only to copy the platform.pl assembly into the Libs folder of EM, but also to put the platform.pl referenced by the assembly. This is the file under the Libs folder of platform.pl. Copy the Libs folder to the EM.
With the increase of the application module on the platform, Platform.pl is quoted more and more. How do we give the platform.pl itself and its libs to these application modules? is by hand copying the way.
So what's the problem?--platform.pl upgrade? The answer is that they can only be copied by hand.
This is very corny, and because of manual copying, easy error. It is best to place the shared components on the server, and to download or update the server when the application module is referenced or upgraded. In fact, the industry has been doing this for quite a long time. is to get the assembly with NuGet.
Only these assemblies are generally public, such as NHibernate, Spring.net, and so on. We were able to use the NuGet mechanism and put the pooled assembly on the internal server.
So, instead of using NuGet to manage the assemblies used in a solution, how do we put our own common components on the internal server and let the other modules download and update them?
Incidentally, the development environment, of course, is. NET, and the version number of Visual Studio is 2012. This version number has the NuGet Package Manager installed by default.
2. Prepare the Assembly for publication
After developing the common components. To advertise it on the NuGet server, you need to do some preparatory work.
0. Download NuGet.exe. here's the address. This is a console program that will be executed later on the command line. After download. Place it in a suitable location and point to the location using path. Of course, this file only needs to be downloaded once.
1. Create the manifest file.
Open a command-line program. Enter the directory of the project where the public component is located and execute NuGet spec.
Just like this:
Watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqvahh0yw4=/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/dissolve/70 /gravity/southeast ">
This creates a file: Platform.PL.nuspec. Open this file and you'll see what it looks like:
<?
XML version= "1.0"? ><package > <metadata> <id> $id $</id> <version> $version $</version> <title> $title $</title> <authors> $author $</authors> <owners> $autho R$</owners> <licenseUrl>http://LICENSE_URL_HERE_OR_DELETE_THIS_LINE</licenseUrl> < Projecturl>http://project_url_here_or_delete_this_line</projecturl> <iconUrl>http://ICON_URL_ Here_or_delete_this_line</iconurl> <requireLicenseAcceptance>false</requireLicenseAcceptance> <description> $description $</description> <releasenotes>summary of changes made in this release of the package.</releasenotes> <copyright>copyright 2014</copyright> <tags>Tag1 Tag2</tags> </metadata></package>
Some of the content is not required and can be deleted. Licenseurl. Projecturl,iconurl, can be deleted, anyway it prompts us to delete.
Releasenotes and tags must be changed. Otherwise, a warning will appear next.
For example, I changed this file to this:
<?XML version= "1.0"? ><package > <metadata> <id> $id $</id> <version>$ version$</version> <title> $title $</title> <authors> $author $</authors> <owners> $author $</owners> <requirelicenseacceptance>false</ requirelicenseacceptance> <description> $description $</description> <releaseNotes> The MES platform database access component was first published on Nugetserver </releaseNotes> <copyright>copyright 2014</copyright> <tags>mes Platform Database interview </tags> </metadata></package>
2. Packaging. under the command line interface above, execute the NuGet pack, like this:
Watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqvahh0yw4=/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/dissolve/70 /gravity/southeast ">
This creates a file Platform.PL.xyz.nupkg. This is the package we are going to publish to Nugetserver.
One case is worth mentioning: for some reason, we have to use the pre-release version of Spring.net (pre-release). Are you curious? The reason for this is that Spring.net uses dictionary in the concurrency, and this class is not thread-safe and causes failures at execution time. Spring.net in the pre-release version 2.0.0-rc1 this problem, but there is no stable (Stable) version. So we're going to use this pre-release version.
NuGet has one rule: if you use an assembly that is not stable, the advertised assembly cannot be a stable version number. Otherwise, the package will cause this error:
For this We need to set the package we want to publish as a test or pre-release version. The practice is to manually edit the Properties/assemblyinfo.cs file for your project:
Watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqvahh0yw4=/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/dissolve/70 /gravity/southeast ">
36 of the rows we put in.
3. Advertise the assembly to the internal server
Go through the previous step. We have generated the package to be advertised: platform.pl.3.1.0-alpha.nupkg.
This package can be published on public nugetserver for all people to download. But now we don't want to do this. We are only posting to internal servers for use within the project team.
To do this, we will first create a site. Create the IIS site in a regular way and be able to name the site Nugetserver.
Second, we're going to create a web app.
Use VS to create an ASP. NET empty Web application.
Be able to name this project Nugetserver.
Again, in this application, add the Nuget.server package reference with NuGet:
Watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqvahh0yw4=/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/dissolve/70 /gravity/southeast ">
After referencing the Nuget.server package. Will voluntarily increase the number of packages it references.
Again, add the Platform.pl.3.1.0-alpha.nupck file that we just created to the packages directory of this Web project:
Watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqvahh0yw4=/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/dissolve/70 /gravity/southeast ">
Finally, the application is published to the site Nugetserver to be able to.
After the success of the announcement, open this site, you can see similar content:
4. Referencing assemblies
Once the assembly has been advertised successfully on the internal nugetserver, it is able to reference it to the application module.
Before you apply a module reference, you need to do a piece of work: Join the server to the NuGet configuration.
In VS 2012, click Menu Tools--NuGet Package Manager--Manage NuGet packages for resolution, and in the Pop-up dialog box, click on the "Settings" button in the lower-left corner to bring up the "Options" dialog box. Click on the big plus sign in the upper right corner to add the "available package source" to the address above IE prompt. such as Http://localhost:8010/nuget. Join up and you'll be able to. Capable of naming mes:
Watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqvahh0yw4=/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/dissolve/70 /gravity/southeast ">
At this point, you can download the assembly like a public nugetserver. Download our own assembly from the internal nugetserver.
Watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqvahh0yw4=/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/dissolve/70 /gravity/southeast ">
5. Other
The title of this post comes with a "pre-release version". The expression of this procedure has just been experimentally passed. Really use it up. There are many unexpected problems that should be faced. Even so, it is recommended.
Our project team is recommended:
1. Discard the assemblies referenced with Libs management. How to switch to NuGet to download assemblies;
2, the MES platform to build a unified NuGet server;
3. Common components are published on the NuGet server and set the version number in the way of the semantic version number.
Manage our assemblies with NuGet-pre-release version