1

I've got a multi-project ASP.NET Web Forms Application solution. I need to share a master page (3 files), some user controls and some images, scripts and CSS files out to the other projects in the solution.

I have already created a package using the NuGet Package Explorer per the documentation:

http://docs.nuget.org/docs/creating-packages/using-a-gui-to-build-packages

My current problem is this: I have updated the shared files in the root project and now I want to update the package before pulling it into the other projects (package currently in a local folder on my dev machine). How do I do this?

If anyone has some getting-started-quickly NuGet links, please share as the official docs just aren't doing it for me.

IrishChieftain
  • 15,108
  • 7
  • 50
  • 91

4 Answers4

3

create the package again with a new version aka if the orginal is 1.0 make this 1.1 and NuGet will pick up the update.

Matthew M. Osborn
  • 4,673
  • 4
  • 25
  • 26
  • Will give this a shot... but is it necessary to actually "create" it again as opposed to "upgrading" it? – IrishChieftain Jun 10 '11 at 14:54
  • 1
    There is no concept of "Upgrading" a package... You can just open the package in package explorer and edit the package and save it :) – Matthew M. Osborn Jun 10 '11 at 16:25
  • Okay, have updated and saved it. But when I try to add Library Package Ref to sub-project, the update is not appearing in the GUI; I can see "MyPackage" in list of installed packages but no package update being shown... – IrishChieftain Jun 10 '11 at 16:40
  • Thought I got it working... had to click top "Installed packages" link in main project to get it working there. GUI is really flaky. 1.1 shows as installed in sub-project in PM console... but .nuspec still showing 1.0?? – IrishChieftain Jun 10 '11 at 16:43
  • Marking this as answer... still not satisfied with NuGet docs :-/ – IrishChieftain Jun 13 '11 at 15:20
  • I'm sorry! Can you post a repro somewhere of the issue you are seeing so I can get a better Idea? Also If there is something you think is missing please file a bug for the NuGet Docs (http://nugetdocs.codeplex.com/workitem/list/basic) And perhaps you can also fix the issue and submit a pull request ;) – Matthew M. Osborn Jun 14 '11 at 15:44
  • IrishChieftain, a fundamental predicate of package management is that packages are immutable - they are designed not to be changed once created. – Matthew Skelton Feb 07 '14 at 11:19
1

The NuGet file is ultimately just a zip file. You can update entries using anything that can update a zip file. Such as something like

using System.IO.Compression;
using System.IO.Compression.FileSystem;

// EG: AddOrUpdateZipEntry("mypackage.nupkg", "my.dll", "bin/my.dll")
void AddOrUpdateZipEntry(string zipFilePath, string contentsFilePath, string entryPathInZip)
{
    using (var zip = ZipFile.Open(zipFilePath, ZipArchiveMode.Update))
    {
        zip.GetEntry(entryPathInZip)?.Delete(); // Remove any existing entry first.
        zip.CreateEntryFromFile(contentsFilePath, entryPathInZip);
    }
}
Sean Kearon
  • 10,987
  • 13
  • 77
  • 93
0

I've already done it before. You just have to increment the version of your package, inside metadata of .nuspec file.

In my case, my packages names are '[name].[version].nupkg' so I save my new package as '[name].[version +1].nupkg' as well.

The update apears in 'Manage nuget packages' updates section.

DeBorges
  • 712
  • 1
  • 7
  • 9
0

Are you asking what you need to do to update projects that are already using the package?

The key thing in this kind of scenario is simply versioning. The new version of the file will be sub'd out. Bundle up the package again with a new version number and then run Update-Package from the package manager console in VS.

You may also want to consider a couple of discreet packages, rather than one straight one. If you want to update a couple images or a CSS file, but not the MasterPage, it might work best to have a couple smaller ones.

Use the PM Explorer (from the post you mentioned) to open a couple packages from the NuGet main repository, in particular, jQuery 1.5.1 and 1.6.x and have a look, as these will be doing very similar things. No real magic needed!

Cheers.

MisterJames
  • 3,306
  • 1
  • 30
  • 48
  • Just tried this from PM command line: Update-Package MyPackage -Version 1.1 -Source C:\VS2010 and got this: No updates available for 'MyPackage'. – IrishChieftain Jun 09 '11 at 21:28
  • So, let's verify a couple of things: is your compiled package in c:\vs2010? What is the version you currently have installed (type Get-Package to confirm)? Is your new package a different version than the one you've got? Also, are you meaning the package manager console, or the nuget command line? – MisterJames Jun 10 '11 at 13:40
  • Not a compiled package, all in content folder incl. master and supporting files - compiles successfully in dest. project. 1.0 to 1.1 upgrade did not work - still showing 1.0. Using PM console - when would I use the Nuget.exe over the PM console? – IrishChieftain Jun 10 '11 at 14:46