Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Trouble restoring Mvc CodeAnalysis dependencies using dotnet cli

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": { }
  },
  ...
}
like image 615
dav_i Avatar asked Feb 12 '16 13:02

dav_i


2 Answers

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"
like image 111
janpieter_z Avatar answered Nov 17 '22 23:11

janpieter_z


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

like image 36
user7518s Avatar answered Nov 17 '22 23:11

user7518s