Moving nuget package folder to a different location (1 level higher)

Hi,

Note: thanks to this post by sebastian belczyk for some help:
http://belczyk.com/2013/02/moving-nuget-packages-directory-outside-solutionss-directory/

This morning I need to relocate my nuget packages folder 1 level higher to allow an offshore team to work parallel with us. Basically, the original solution was cloaked and branched. In the original solution we realised we had 2 places for nuget packages so hence we had to merge them into 1 solution. This mean’t that the branched solution need to match the original other wise we would have lots of reintegration issues.

Firstly, I needed to update my nuget.config file. We had our package located here:
../packages/
But we really needed them here:
../../packages/ – up another level.

Then I needed to close the solution and reopen it for this change to take affect. I found this out as changing the file without restarting meant that nothing changed and my packages were still restoring to the old ../packages/ directory.

Then right click to Manage nuget Packages for Solution …

Then Visual Studio will detect that there is no nuget packages folder on the file system at the location specified:

It will load them when you click restore:

So in summary, I had this file structure:
Soln
— Project
—- packages Folder

And now I have this structure:
Soln
— packages Folder
— Project

thanks
Russ

Advertisements

Fix already installed nuget packages

Hello,

Sometimes I create a branch and for some reason 1 or 2 projects packages and hence Dlls are wrong. I even try using “Restore Nuget Packages” at solution level from the context menu but this doesn’t always fix it.

The best fix I have found is this:
Update-Package PackageName -ProjectName MyProject -reinstall

So if you have Entity Framework 6.1.2 installed and it got broken in a branch then you could run:


Update-Package EntityFramework -ProjectName MyProject -reinstall

And it will reinstall EF 6.1.2

That is all,

thanks
Russ

A small update

Morning all,
Well it’s been a while since I posted in my blog that i’m sure no one reads! I have finally got used to living in Melbourne and have started enjoying it more now that the weather is getting better.
I will hopefully be posting some interesting stuff on MVC up here is the next few weeks.
Here is a list of things I have looked at in the last few weeks.
  • MVC(3) – I have been trying to get around to getting up to date on MVC for years. Ever since I tried and failed to read Martin fowler’s book on design patterns (http://martinfowler.com/eaaDev/uiArchs.html).
    Well finally I have got around to it and I love it. Combined with the Entity Framework edmx or code first it is such a great way to work. This is the way, for most sites, the web should be built. No hidden viewstate, no nightmare page load order and code that you have total granular control over. Awesome!!
  • Razor view engine – initially it looks dodgy but after a little playing around it’s cleaner and easier to read than traditional asp.net forms. One thing I have learned about Razor is, if it looks messy and hard to read, then you probably have started putting business logic where it should not go.
  • Unit testing and TDD with MVC – Combined with Ninject and Moq this is easy. You can directly test your controllers. Compare this to ASP.NET web forms where your controller was, sort of, your code behind. You needed httpContext etc. Now you can test just your controller logic without other webby things clouding the test.
  • JQuery – ok so this is not new but im loving it so far.
  • NuGet – the NuGet package manager is quite cool. NuGet is a Visual Studio extension that makes it easy to add, remove, and update libraries and tools in Visual Studio projects that use the .NET Framework. When you add a library or tool, NuGet copies files to your solution and automatically makes whatever changes are needed in your project, such as adding references and changing your app.config or web.config file. When you remove a library, NuGet removes files and reverses whatever changes it made in your project so that no clutter is left.
    For example if you need to get the latest JQuery libraries into you solution you open Tools > library package manager > package manager console and type:

    PM> Update-Package jquery

    PM with auto update your JQuery to the correct version. Note that your references inside Views > Shared > _Layout.cshtml (for example) will not be auto updated.

Well, I know this is a bit of a lame post but it was more to get me back into the habit of writing on my blog. I hope to come up with some more interesting stuff soon.

RuSs