10
votes

I'm having an error restoring dependencies for an ASP.NET 5/ASP.NET Core 1.0.

It appears that a couple of the dependencies (namely Microsoft.CodeAnalysis.CSharp / .Common) of Microsoft.AspNet.Mvc are fixed to seemingly out of date packages.

A requirement for this is to use the dotnet cli tool and target both .NET Vanilla and .NET Core.

Is there any way to get Mvc to reference Core-compatible version of CodeAnalysis?


Steps to reproduce in Visual Studio 2015 (v14.0.24729.00 Update 1):

  1. File > New > Project > Web > ASP.NET Web Application
  2. API.NET 5 Templates > Web API
  3. Open PM, run command dotnet restore

Output:

info : Restoring packages for C:\PATH_TO_SOLUTION\WebApplication2\src\WebApplication2\project.json...
error: Microsoft.CodeAnalysis.CSharp 1.1.0-rc1-20151109-01 is not compatible with DNXCore,Version=v5.0.
error: Microsoft.CodeAnalysis.Common 1.1.0-rc1-20151109-01 is not compatible with DNXCore,Version=v5.0.
error: Some packages are not compatible with DNXCore,Version=v5.0.
error: Microsoft.CodeAnalysis.CSharp 1.1.0-rc1-20151109-01 is not compatible with DNXCore,Version=v5.0 (win7-x64).
error: Microsoft.CodeAnalysis.Common 1.1.0-rc1-20151109-01 is not compatible with DNXCore,Version=v5.0 (win7-x64).
... (loads more errors) ...

project.json file contains:

{
  ...
  "dependencies": {
    ...
    "Microsoft.AspNet.Mvc": "6.0.0-rc1-final",
    ...
  }
  ...
  "frameworks": {
    "dnx451": { },
    "dnxcore50": { }
  },
  ...
}
2

2 Answers

3
votes

Using the (currently) latest stable version works with as target framework only dnxcore50. In my project.json:

"Microsoft.CodeAnalysis.Common": "1.1.1",
"Microsoft.CodeAnalysis.CSharp": "1.1.1"
2
votes

Just installing the latest version of Microsoft.CodeAnalysis.Common from NuGet Package Manager worked fine for me.