xforfun
xforfun

Reputation: 592

Cannot add Microsoft.AspNet.Mvc.Core to classic library

I'm having a classic library that is based on .Net4.6 and I would like to add the nuget-package of the new mvc6. I try doing this using the Package Manager Console. The error is the follwing:

Install-Package : Failed to add reference to 'System.Runtime'. Please make sure that it is in the Global Assembly Cache.
At line:1 char:1
+ Install-Package Microsoft.AspNet.Mvc.Core -Pre
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Install-Package], Exception
    + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand

Installing the requested System.Runtime is no problem - it works fine:

Install-Package System.Runtime -Pre

And this is the total result:

PM> Install-Package Microsoft.AspNet.Mvc.Core -Pre
Attempting to gather dependencies information for package 'Microsoft.AspNet.Mvc.Core.6.0.0-rc1-final' with respect to project 'LibTest', targeting '.NETFramework,Version=v4.6'
Attempting to resolve dependencies for package 'Microsoft.AspNet.Mvc.Core.6.0.0-rc1-final' with DependencyBehavior 'Lowest'
Resolving actions to install package 'Microsoft.AspNet.Mvc.Core.6.0.0-rc1-final'
Resolved actions to install package 'Microsoft.AspNet.Mvc.Core.6.0.0-rc1-final'
Adding package 'System.Diagnostics.DiagnosticSource.4.0.0-beta-23516' to folder 'C:\Data\MyProject\SourceCode\packages'
Added package 'System.Diagnostics.DiagnosticSource.4.0.0-beta-23516' to folder 'C:\Data\MyProject\SourceCode\packages'
Added package 'System.Diagnostics.DiagnosticSource.4.0.0-beta-23516' to 'packages.config'
Successfully installed 'System.Diagnostics.DiagnosticSource 4.0.0-beta-23516' to LibTest
Adding package 'Microsoft.AspNet.Mvc.Core.6.0.0-rc1-final' to folder 'C:\Data\MyProject\SourceCode\packages'
Added package 'Microsoft.AspNet.Mvc.Core.6.0.0-rc1-final' to folder 'C:\Data\MyProject\SourceCode\packages'
Install failed. Rolling back...
Package 'Microsoft.AspNet.Mvc.Core.6.0.0-rc1-final : Microsoft.AspNet.Authorization [1.0.0-rc1-final, ), Microsoft.AspNet.FileProviders.Abstractions [1.0.0-rc1-final, ), Microsoft.AspNet.Hosting.Abstractions [1.0.0-rc1-final, ), Microsoft.AspNet.Mvc.Abstractions [6.0.0-rc1-final, ), Microsoft.Extensions.Logging.Abstractions [1.0.0-rc1-final, ), Microsoft.Extensions.MemoryPool [1.0.0-rc1-final, ), Microsoft.Extensions.PlatformAbstractions [1.0.0-rc1-final, ), System.Diagnostics.DiagnosticSource [4.0.0-beta-23516, )' does not exist in project 'LibTest'
Removed package 'System.Diagnostics.DiagnosticSource.4.0.0-beta-23516 : System.Diagnostics.Tracing [4.0.0, ), System.Runtime [4.0.0, ), System.Threading [4.0.0, )' from 'packages.config'
Removing package 'Microsoft.AspNet.Mvc.Core.6.0.0-rc1-final : Microsoft.AspNet.Authorization [1.0.0-rc1-final, ), Microsoft.AspNet.FileProviders.Abstractions [1.0.0-rc1-final, ), Microsoft.AspNet.Hosting.Abstractions [1.0.0-rc1-final, ), Microsoft.AspNet.Mvc.Abstractions [6.0.0-rc1-final, ), Microsoft.Extensions.Logging.Abstractions [1.0.0-rc1-final, ), Microsoft.Extensions.MemoryPool [1.0.0-rc1-final, ), Microsoft.Extensions.PlatformAbstractions [1.0.0-rc1-final, ), System.Diagnostics.DiagnosticSource [4.0.0-beta-23516, )' from folder 'C:\Data\MyProject\SourceCode\packages'
Removed package 'Microsoft.AspNet.Mvc.Core.6.0.0-rc1-final : Microsoft.AspNet.Authorization [1.0.0-rc1-final, ), Microsoft.AspNet.FileProviders.Abstractions [1.0.0-rc1-final, ), Microsoft.AspNet.Hosting.Abstractions [1.0.0-rc1-final, ), Microsoft.AspNet.Mvc.Abstractions [6.0.0-rc1-final, ), Microsoft.Extensions.Logging.Abstractions [1.0.0-rc1-final, ), Microsoft.Extensions.MemoryPool [1.0.0-rc1-final, ), Microsoft.Extensions.PlatformAbstractions [1.0.0-rc1-final, ), System.Diagnostics.DiagnosticSource [4.0.0-beta-23516, )' from folder 'C:\Data\MyProject\SourceCode\packages'
Removing package 'System.Diagnostics.DiagnosticSource.4.0.0-beta-23516 : System.Diagnostics.Tracing [4.0.0, ), System.Runtime [4.0.0, ), System.Threading [4.0.0, )' from folder 'C:\Data\MyProject\SourceCode\packages'
Removed package 'System.Diagnostics.DiagnosticSource.4.0.0-beta-23516 : System.Diagnostics.Tracing [4.0.0, ), System.Runtime [4.0.0, ), System.Threading [4.0.0, )' from folder 'C:\Data\MyProject\SourceCode\packages'
Install-Package : Failed to add reference to 'System.Runtime'. Please make sure that it is in the Global Assembly Cache.
At line:1 char:1
+ Install-Package Microsoft.AspNet.Mvc.Core -Pre
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Install-Package], Exception
    + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand

PM> 

Any idea what could be the problem here?

Upvotes: 3

Views: 1055

Answers (1)

xforfun
xforfun

Reputation: 592

I'm not sure what it really was... but I changed some points:

  • I had my projects on net461. I changed them back to net451. This removed some warnings in the dependency-graph of the references in the aspnet5-application.
  • After I tried to add Microsoft.AspNet.Mvc.Core and it failed I changed the packages.config manually: I added this line:

<package id="Microsoft.AspNet.Mvc.Core" version="6.0.0-rc1-final" targetFramework="net451" />

And after recompiling it seems to work.

Upvotes: 1

Related Questions