Efficiently Integrate Patch of NuGet Package - visual-studio-2012

Our small, distributed team uses a NuGet package in a project. That package has a bug in the current release. Unfortunately the package does not publish debug symbols and source, so I grabbed & built the latest source, removed the project via NuGet and added a (temporary) reference to the project I just built locally.
Turns out, the issue is fixed in the latest code base.
This particular project only seems to release updates on NuGet every 6 months or so.
Until that next release, our team needs to use the code version where the bug is fixed.
One option certainly is to check the source code into our source code repository and keep the project reference (rather than a NuGet reference), essentially treating it as an internal utility project.
That feels "old school" though.
Is there a better way to manage this situation, using the NuGet infrastructure?

One option is to create your own NuGet package with the updated code. Then add a new Local Package source (just create a file share and place the .nupkg file there). Move the local package source up higher in priority than the official one so NuGet will use your package before looking online.
In fact I recommend copying all NuGet packages to a local repository, especially if you use package restore. This way you are not dependent on nuget.org to be up all the time (there have been several instances of downtime).
The one drawback is that when an updated package is finally published to nuget.org, Update-Package will not pick up the new one unless you specify the package source.
Anyway this will allow you to continue to use NuGet while waiting for your updated package.

Related

Is it possible to use the CSPROJ version when creating NuGet packages via gulp?

I'm currently using a gulp file to create a NuGet package automatically whenever the project is built. One trouble I'm currently having is the versioning - ideally I'd like the NuGet package version to reflect the version of the project.
I've checked through various tools for gulp and node, but have so far been unable to find anything that might help. Has anyone come across a solution to this issue?
As far as I know, csproj file doesn’t have its own version. This file have information about the files included in that project, assemblies used in that project, project GUID and project version and so on.
So I assume you want to get the product/assembly version and then using this version as the NuGet package version. You could use gulp to read the file and then use regular expression to match the file version information.

Catel 4.0.0 and Dependency on Microsoft.Bcl.Build

When updating a project to use current Catel version (4.0) I am getting this warning:
All projects referencing MyInfrastructureProject.csproj must install nuget package Microsoft.Bcl.Build. For more information, see http://go.microsoft.com/fwlink/?LinkID=317569.
The error is reported for projects that references MyInfrastructureProject.csproj.
I find it odd that I need to add additional libraries to other project especially when it is concerned with nuget (if I am getting the picture correctly) and not with actual functionality of my code (or maybe even Catel). But in any case, I don't really understand the issue.
I searched a little for this issue but didn't find relevant details or explanations.
Should I go ahead and add the Microsoft.Bcl.Build reference everywhere in my project?
Thanks,
Tomer
If you don't know what is Microsoft.Bcl.Async you should study it.
Catel uses this feature pack so as to use async/await on .NET 4 and Silverlight 5. So if you use Catel in a .NET 4 project, you inherit the same dependencies, which is what the warning says.
Thus, yes, please go ahead and add the NuGet package to the necessary projects, or simply upgrade your projects to .NET 4.5 and reapply the NuGet packages.

Using specific version of packages in MonoDevelop

What is the best way to handle specific version of libraries while using MonoDevelop (precisely - use ServiceStack v3 instead of ServiceStack v4)?
Unfortunately, MonoDevelop's addin NuGet does not allow specifying package version (no Package management console support). I've tried hacking it in .csproj and package.config file but it does not work entirely well and it seems to be smelly solution.
One obvious solution is to get rid of NuGet and reference libraries locally after manually downloading them.
How would you solve this problem?
Thanks for all responses :)
Being able to add a specific version of a NuGet package with the MonoDevelop addin is on the todo list.
If you have access to Windows you could use SharpDevelop to add a specific version using its Package Management console.
Or as you have suggested, edit the packages.config file, then restore the packages. However you will need to add the required assembly references by hand. This option is not that bad if there are not that many assembly references and you are not going to be updating the NuGet package very often. Although the benefit of this approach over downloading the NuGet package, extracting it, and directly referencing the assemblies is equivalent and the same amount of work. Also doing it this way you can more easily update the references by simply dropping the new binaries into your lib folder.
Or you could change the source code of the addin. I thought about adding a simple text box where you could specify a particular version. Ideally the dialog would give you a list of available versions.
I would probably just download the ServiceStack assemblies you need and directly reference them.

Why isn't ServiceStack.Text being copied to Bin?

I have added ServiceStack.Redis via Nuget to an assembly that I have. That package has a dependency on ServiceStack.Common which has a dependency on ServiceStack.Text
this project is referenced from my web project, but when I build the Website and load it in a browser I get the error
Could not load file or assembly 'ServiceStack.Text, Version=3.9.24.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
Sure enough, when I go to the Bin directory of my website it isn't there. Oddly enough, if I go to the Bin directory of the class library I am referencing (the one I pulled the Nuget package into) it IS there.
To recap
ClassLibrary
ServiceStack.Redis via Nuget (includes ServiceStack.Common and ServiceStack.Text)
All of these make it in the Bin dir upon build
Web Proj
Refs ClassLibrary
all dependencies are moved to Bin except ServiceStack.Text
I'm stumped. Does anyone know why?
Note: The error appears to be looking for version 3.9.24, but the version Nuget pulled is 3.9.26. If I move it to the Web/Bin manually it works though
Check the assembly reference properties in your .csproj files, perhaps they are still referencing the older version of ServiceStack.Text. Sometimes I find that NuGet will fail at some point during a package update and leave your assembly references in a bad state. For example, your packages.config file may correctly show that all ServiceStack references are at the same version number, but your .csproj file may be referencing 3.9.24 for ServiceStack.Common and 3.9.26 for ServiceStack.Text. Thus, it will copy different versions of these assemblies to your bin directory. It likely can still build successfully because you have the older copy of ServiceStack.Common cached in your NuGet packages directories.
I fix this by either manually editing the .csproj file to have the correct assembly path and version number, or by uninstalling and reinstalling the affected packages via NuGet (this would likely require reinstalling most/all of the ServiceStack packages since ServiceStack.Text is such a low level dependency.
I had this somewhat bizarre problem in several versions of Visual Studio, atm 2013. It has occurred at random.
I too have dependencies on ServiceStack.Common, which implicitly depends on ServiceStack.Text. However, I am not directly at any place referencing any class, struct or the like inside ServiceStack.Text binary.
Even having set
Copy Local = true
ServiceStack.Text.dll is not being copied to the output folder.
I have experienced this with numerous versions of ServiceStack dll's, currently v4.0.15. This could be a more general Visual Studio bug concerning dependency-chains with dead ends in not directly used libraries? Probably ServiceStack.Text is marked as a dependency in other ServiceStack dll's, but Visual Studio tries to outsmart this by seeing, the library can be excluded (I'm just speculating).
Anyway, I solved it by simply using ServiceStack.Text directly in a private method put in a random used file in my own library:
/// <summary>
/// Needed because of Visual Studio bug? Don't use this method.
/// </summary>
private JsonValue DontDoIt()
{
return new ServiceStack.Text.JsonValue();
}
I would expect the compiler to exlude an unused private method - indeed maybe it does in the IL code, but none the less this makes VS copy the dll to the output directory.
As esker says there may be some problems with Nuget when updating but there are also some problems with ServiceStack Nuget packages.
The latest package working as of today is 3.9.60. ServiceStack.Text.dll is really 3.9.60.
ServiceStack 3.9.61 and above has ServiceStack.Text.dll version 3.9.59.
The copy problem is appearing again.

NuGet : How to keep package versions consistent across several solutions?

We're building a set of several services, each service has it's own solution with associated projects. Many of these services rely on the same NuGet packages.
All the solutions have "Package Restore" enabled.
Some of the solutions refer to assemblies owned by other solutions, this is one obvious reason why we need all the solutions to refer to exactly the same versions of different NuGet Packages.
All of the services need to work together to achieve an end result. They're packaged and installed as part of a single product, which is another reason we'd like everything to be running off the same versions of the NuGet Packages
We're having trouble keeping package versions consistent between Solutions.
Currently we're manually checking and updating package versions, we're also getting occasional compilation errors because projects in one solution end up referring to different versions of the same package.
Is there a recommended way of doing this (hopefully an automatic process)?
Would we be better off without Package Restore?
Anyone have any general advice on the subject?
Thanks
Update: I created an issue for this on the NugGet project http://nuget.codeplex.com/workitem/2623
To solve this:
Create your own private NuGet server (see 1 and 2) that hosts the correct versions of the packages you use.
Configure each build system to use that server and auto update to the latest version.
Although this requires a server, it not only ensures everyone has the correct version but speeds up the downloads for build servers as well.
You could configure your TFS builds to update all NuGet packages in the solution to their latest versions using the nuget update command.
The latest versions could be from nuget.org, a local NuGet server or even a network share. Use the source parameter to define the sources you want to update from.
You can perform the build configuration via MsBuild proj files or via a TFS template.

Resources