NuGet.Core with _bin_DeployableAssemblies

Jun 28, 2011 at 2:55 PM

Hi,

I have some code that references a recent NuGet.Core (1.3.20419.9005) and uses some of its API's. I use this code in an MVC 3 web application.

When I deploy the web application, I used the "Add Deployable Dependencies" option to include the MVC 3 assemblies. That includes version 1.0.11220.104 of NuGet.Core.dll.

Since the assembly is older, my own code fails because some types/methods don't exist.

If I use the new version, I get:

Could not load file or assembly 'NuGet.Core, Version=1.0.11220.104

Now that's an easy problem to solve - binding redirects! Only that makes it worse:

Method 'AddFrameworkReference' in type 'System.Web.WebPages.Administration.PackageManager.WebProjectSystem' from assembly 'System.Web.WebPages.Administration, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' does not have an implementation

I use Razor, so I can't remove the reference to System.Web.WebPages.dll as this answer suggests. 

My workaround at the moment is to download the NuGet.Core source code, rename everything to FooGet, and deploy NuGet.Core and FooGet.Core side by side, changing my own code to use FooGet.

Is there a better solution? 

Paul

Coordinator
Jun 28, 2011 at 4:52 PM

Why do you have System.Web.WebPages.Administration referenced? My guess is you checked “ASP.NET Web Pages with Razor Syntax” when deploying assemblies. Don’t check that option. You only need ASP.NET MVC if you’re building an MVC site. Read my blog post for more details. http://haacked.com/archive/2011/05/25/bin-deploying-asp-net-mvc-3.aspx

Phil

Mar 20, 2013 at 10:25 PM
Edited Mar 21, 2013 at 2:38 PM
nuget update adds nuget.core dependency in mvc
Every time I do a nuget update it breaks my build/deploy.
Somewhere in my solution or project some sort of dependency is added that I cannot find or understand.
Today I updated to jQuery 1.8.20. Everything seemed fine running locally.
When I deploy to DEV I get an error in the app start up.
Event code: 3005 
Event message: An unhandled exception has occurred. 

Application information: 
Application domain: /LM/W3SVC/1448020018/Root/PositionManagement-7-130082865703384198 
Trust level: Full 
Application Virtual Path: /PositionManagement 
Application Path: D:\Inetpub\RJApps\MutualFundsDev.rjf.com\PositionManagement\ 
Machine name: ORANGEXA 

Process information: 
Process name: w3wp.exe 

Exception information: 
Exception type: InvalidOperationException 
Exception message: The pre-application start initialization method Start on type System.Web.WebPages.Administration.PreApplicationStartCode threw an exception with the following error message: Could not load file or assembly 'NuGet.Core, Version=1.0.11220.104, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified..
at System.Web.Compilation.BuildManager.InvokePreStartInitMethods(ICollection`1 methods)
at System.Web.Compilation.BuildManager.CallPreStartInitMethods()
at System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException)

Could not load file or assembly 'NuGet.Core, Version=1.0.11220.104, Culture=neutral,     PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
at System.Reflection.RuntimeAssembly.GetExportedTypes(RuntimeAssembly assembly, ObjectHandleOnStack retTypes)
at System.Reflection.RuntimeAssembly.GetExportedTypes()
at System.Web.WebPages.ApplicationParts.ResourceAssembly.GetTypes()
at System.Web.WebPages.ApplicationParts.ApplicationPartRegistry.Register(ApplicationPart applicationPart, Func`1 registerPageAction)
at System.Web.WebPages.ApplicationPart.Register(ApplicationPart applicationPart)
at System.Web.WebPages.Administration.SiteAdmin.RegisterAdminModule()
at System.Web.WebPages.Administration.PreApplicationStartCode.Start()
Why does NuGet do this to me?
I find it very stressful.
The last time this happened I spent most of my day removing every single solitary NuGet package, and adding them all back again.
What a stressfull total pain.

Any suggestions will be appreciated.

Sincerely, Joe
Mar 21, 2013 at 6:45 AM
Please remove system.web.webpages.administration.dll from your reference list. This assembly should never be used as an reference.

http://msdn.microsoft.com/en-us/library/system.web.webpages.administration(v=vs.111).aspx

It should be a VS issue if VS adds this reference automatically to your project.
Mar 21, 2013 at 2:33 PM
Thank you for your suggestion.
My project does not include a reference to system.web.webpages.administration.

Here is the references section of the project file:
<ItemGroup>
<Reference Include="AutoMapper">
  <HintPath>..\..\packages\AutoMapper.2.2.0\lib\net40\AutoMapper.dll</HintPath>
</Reference>
<Reference Include="EntityFramework, Version=4.3.1.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
  <SpecificVersion>False</SpecificVersion>
  <HintPath>..\..\packages\EntityFramework.4.3.1\lib\net40\EntityFramework.dll</HintPath>
</Reference>
<Reference Include="EPPlus, Version=3.1.2.0, Culture=neutral, PublicKeyToken=ea159fdaa78159a1, processorArchitecture=MSIL">
  <SpecificVersion>False</SpecificVersion>
  <HintPath>..\..\packages\EPPlus.3.1.2\lib\net35\EPPlus.dll</HintPath>
</Reference>
<Reference Include="Microsoft.ApplicationServer.Caching.Client, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
  <SpecificVersion>False</SpecificVersion>
  <HintPath>..\..\packages\ServerAppFabric.Client.1.1.2106\lib\Microsoft.ApplicationServer.Caching.Client.dll</HintPath>
</Reference>
<Reference Include="Microsoft.ApplicationServer.Caching.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
  <SpecificVersion>False</SpecificVersion>
  <HintPath>..\..\packages\ServerAppFabric.Client.1.1.2106\lib\Microsoft.ApplicationServer.Caching.Core.dll</HintPath>
</Reference>
<Reference Include="Microsoft.CSharp" />
<Reference Include="Microsoft.Practices.ServiceLocation">
  <HintPath>..\..\packages\CommonServiceLocator.1.0\lib\NET35\Microsoft.Practices.ServiceLocation.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Practices.Unity, Version=2.1.505.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
  <HintPath>..\..\packages\Unity.2.1.505.2\lib\NET35\Microsoft.Practices.Unity.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Web.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
  <Private>True</Private>
</Reference>
<Reference Include="Newtonsoft.Json">
  <HintPath>..\..\packages\Newtonsoft.Json.4.5.10\lib\net40\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="RaymondJames.Security">
  <HintPath>..\..\Lib\RaymondJames.Security.dll</HintPath>
</Reference>
<Reference Include="RJDF.Infrastructure.Caching">
  <HintPath>..\..\packages\RJDF.Infrastructure.1.5.1\lib\net40\RJDF.Infrastructure.Caching.dll</HintPath>
</Reference>
<Reference Include="RJDF.Infrastructure.Crosscutting">
  <HintPath>..\..\packages\RJDF.Infrastructure.1.5.1\lib\net40\RJDF.Infrastructure.Crosscutting.dll</HintPath>
</Reference>
<Reference Include="RJDF.Infrastructure.Crosscutting.WorkingModule">
  <HintPath>..\..\packages\RJDF.Infrastructure.1.5.1\lib\net40\RJDF.Infrastructure.Crosscutting.WorkingModule.dll</HintPath>
</Reference>
<Reference Include="RJDF.Infrastructure.Logging, Version=1.5.1.0, Culture=neutral, PublicKeyToken=1d110d056ee8718d, processorArchitecture=MSIL">
  <SpecificVersion>False</SpecificVersion>
  <HintPath>..\..\packages\RJDF.Infrastructure.1.5.1\lib\net40\RJDF.Infrastructure.Logging.dll</HintPath>
</Reference>
<Reference Include="RJDF.Infrastructure.Performance">
  <HintPath>..\..\packages\RJDF.Infrastructure.1.5.1\lib\net40\RJDF.Infrastructure.Performance.dll</HintPath>
</Reference>
<Reference Include="SignalR">
  <HintPath>..\..\packages\SignalR.Server.0.5.3\lib\net40\SignalR.dll</HintPath>
</Reference>
<Reference Include="SignalR.Hosting.AspNet">
  <HintPath>..\..\packages\SignalR.Hosting.AspNet.0.5.3\lib\net40\SignalR.Hosting.AspNet.dll</HintPath>
</Reference>
<Reference Include="SignalR.Hosting.Common">
  <HintPath>..\..\packages\SignalR.Hosting.Common.0.5.3\lib\net40\SignalR.Hosting.Common.dll</HintPath>
</Reference>
<Reference Include="System.Data.Entity" />
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.DirectoryServices.AccountManagement" />
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System.Core" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Drawing" />
<Reference Include="System.Web.Extensions" />
<Reference Include="System.Web" />
<Reference Include="System.Web.Abstractions" />
<Reference Include="System.Web.Helpers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
  <SpecificVersion>False</SpecificVersion>
  <HintPath>_bin_deployableAssemblies\System.Web.Helpers.dll</HintPath>
</Reference>
<Reference Include="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
  <SpecificVersion>False</SpecificVersion>
  <HintPath>..\..\..\..\..\..\Program Files (x86)\Microsoft ASP.NET\ASP.NET MVC 3\Assemblies\System.Web.Mvc.dll</HintPath>
</Reference>
<Reference Include="System.Web.Routing" />
<Reference Include="System.Web.WebPages, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
  <SpecificVersion>False</SpecificVersion>
  <HintPath>_bin_deployableAssemblies\System.Web.WebPages.dll</HintPath>
</Reference>
<Reference Include="System.Xml" />
<Reference Include="System.Configuration" />
<Reference Include="Telerik.Web.Mvc">
  <HintPath>Lib\Telerik.Web.Mvc.dll</HintPath>
</Reference>
<Reference Include="Unity.Mvc3, Version=1.2.0.0, Culture=neutral, processorArchitecture=MSIL">
  <SpecificVersion>False</SpecificVersion>
  <HintPath>..\..\packages\Unity.Mvc3.1.2\lib\net40\Unity.Mvc3.dll</HintPath>
</Reference>
<Reference Include="WindowsBase" />
</ItemGroup>
Could the problem be the physical path of my packages folder.
We have mandatory source code organization rules.
We have to keep solution files two directories above the projects.
/Source/product.sln
/Source/Product/Projects/project.csproj
This causes NuGet to create the packages folder in a weird location.
/Source/packages
Could this get NuGet confused?

Joe
Mar 21, 2013 at 7:19 PM
Seriously. I removed every single NuGet reference from my entire solution, added them back again, ran my build/deploy and got the same error.
The web server is starting up the web app and throwing an unhandled error because it cannot find NuGet.Core./
Has anyone else ever had this problem?
I am ready to uninstall NuGet from Visual Studio and add the references manually.
If I cannot get this to work I can never update any references in my app.
Any help?
Joe
Mar 21, 2013 at 7:49 PM
lextm - you are correct.
I found that the System.Web.WebPages.Administration.dll was in my _bin_deployables directory.
Not sure how it got there. This app has been to production seven times now.
This problem has happenned before. Usually weeks go by and I forget how I resolved it.
If I determine a scenario where NuGet / Visual Studio bring the file back again I will post it.
Joe