开发者

Can I avoid checking in the bin folder of MVC3 project with NuGet?

I created an MVC3 project and pulled in a few libraries using NuGet (NHibernate, AutoFac, etc.) It seems that these libraries are set up to install binaries into the bin folder rather than to reference the root packages folder. When I pulled in the sources on another machine (bin folder not yet in source control), I had a bunch of broken references.

Question: am I doing something wr开发者_开发技巧ong? Is there a way to set this up so that I don't have to check in the binaries folder w/o having to resort to GAC or to manually managing the reference back to the packages folder?

I am using VS2010 sp1 and NuGet 1.4.

UPDATE

I found my problem! I had moved the project after it was created and libraries were pulled in via NuGet. This worked fine on my first dev machine because I already had the dll's in my bin folder, but did not work on my second dev machine because the <HintPath> in the .csproj file was no longer pointing correctly to the packages folder.

To fix this, unload your project in VS, edit it and fix the references. It would be nice if NuGet checked the <HintPath> setting in the .csproj file and auto-corrected it.

NuGet work item: http://nuget.codeplex.com/workitem/1230


My solution to this is to put the nuget.exe in a solution folder, which I put in the source control, and use a pre-build event for each project:

"$(SolutionDir)NuGetCLI\nuget" install "$(ProjectDir)packages.config" -o "$(SolutionDir)Packages"

This pulls out and configures the packages used in the project. The benefit is that I do not have to store the binaries at all in the source control.


am I doing something wrong?

Actually when you install a NuGet package containing assemblies there's a packages folder created under the root of the project. This folder contains all the files for all installed packages. References are then made from this folder. So make sure to check this folder and its contents in version control as well. This folder is not automatically added to the Visual Studio project, so I don't know what VCS you use but seems that it doesn't version this folder.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜