10

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": { }
  },
  ...
}
dav_i
  • 27,509
  • 17
  • 104
  • 136

2 Answers2

3

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"
janpieter_z
  • 1,722
  • 13
  • 28
  • Thanks for your answer. Where are you putting this in your *project.json*? If I put it in `"dependencies"` then I just get resolve errors for both frameworks. – dav_i Feb 15 '16 at 14:55
  • In my dependencies indeed. Are all of your nuget feeds available? Your output should log if there is one that isn't available. – janpieter_z Feb 15 '16 at 19:29
  • Strangely it doesn't give that error, just complains they it is "Unable to resolve". However, I tried running the commmand `dotnet restore -s https://api.nuget.org/v3/index.json` and the referenced packages are installed. Running `dotnet build` then works as expected! – dav_i Feb 16 '16 at 09:05
  • Interesting. You're not running v2 by accident in your package sources? – janpieter_z Feb 16 '16 at 09:07
  • Nope! It's v3 in my roaming nuget.config. – dav_i Feb 16 '16 at 10:11
  • Im getting this error trying to dotnet restore with RC2 and this solution doesnt seem to fix that - now I get `Microsoft.CodeAnalysis.Common 1.1.1 is not compatible with DNXCore,Version=v5.0` – Greg Ennis Mar 17 '16 at 01:52
2

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

user7518s
  • 452
  • 1
  • 7
  • 16