3

I'm trying to setup a project in mvc6, but i'm encountring with this error and even reading for a few days through related topics i'm not finding where the conflict comes from. Surely a miss configurated dependecy?

project.json

{ 
  "webroot": "wwwroot",
  "version": "1.0.0-*",

  "dependencies": {
    "Microsoft.AspNet.Mvc": "6.0.0-rc1-final",
    "Microsoft.AspNet.Server.IIS": "1.0.0-beta7",
    "Microsoft.AspNet.Server.WebListener": "1.0.0-rc1-final",
    "Microsoft.AspNet.StaticFiles": "1.0.0-rc1-final",
    "Swashbuckle.SwaggerGen": "6.0.0-rc1-final",
    "Swashbuckle.SwaggerUi": "6.0.0-rc1-final",
    "System.Reflection": "4.1.0-beta-23516",
    "System.Xml.XPath.XmlDocument": "4.0.1-beta-23516",
    "System.Reflection.TypeExtensions": "4.1.0-beta-23516",
    "System.Reflection.Extensions": "4.0.1-beta-23516",
    "Newtonsoft.Json": "8.0.1-beta3"
  },

  "commands": {
    "web": "Microsoft.AspNet.Hosting --config hosting.ini",
  },

  "frameworks": {
    "dnx451": {
      "dependencies": {
        "Microsoft.AspNet.Hosting.Abstractions": "1.0.0-rc1-final",
        "Microsoft.AspNet.Mvc.Core": "6.0.0-rc1-final",
        "Microsoft.Extensions.DependencyInjection.Abstractions": "1.0.0-rc1-final",
        "Microsoft.AspNet.Http.Abstractions": "1.0.0-rc1-final"
      }
    }
  },

  "exclude": [
    "wwwroot",
    "node_modules",
    "bower_components"
  ],
  "publishExclude": [
    "node_modules",
    "bower_components",
    "**.xproj",
    "**.user",
    "**.vspscc"
  ]
}

Also i'm reading on the internet about global.json which i don't have in the newly created project. if this is required and possibly generating the issue? should i just place it in my root? and what should it contain?

Finally my dnvm list output:

Active Version           Runtime Architecture OperatingSystem Alias
------ -------           ------- ------------ --------------- -----
       1.0.0-beta5       clr     x64          win
       1.0.0-beta5       clr     x86          win
       1.0.0-beta5       coreclr x64          win
       1.0.0-beta5       coreclr x86          win
  *    1.0.0-rc1-update1 clr     x86          win             default
       1.0.0-rc2-16319   clr     x86          win

And i have about 40 of this errors:

CS0433  The type 'List<T>' exists in both 'System.Collections, Version=4.0.11.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' and 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'

CS0433  The type 'Random' exists in both 'System.Runtime.Extensions, Version=4.0.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' and 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'

CS0433  The type 'Dictionary<TKey, TValue>' exists in both 'System.Collections, Version=4.0.11.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' and 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'

UPDATE 1:

Thanks to the comments of oleq i fixed a lot of depencecies. My new project.json is:

{
  "webroot": "wwwroot",
  "version": "1.0.0-*",

  "dependencies": {
    "Microsoft.AspNet.Mvc": "6.0.0-rc1-final",
    "Microsoft.AspNet.Server.Kestrel": "1.0.0-rc1-final",
    "Microsoft.AspNet.StaticFiles": "1.0.0-rc1-final",
    "Swashbuckle.SwaggerGen": "6.0.0-rc1-final",
    "Swashbuckle.SwaggerUi": "6.0.0-rc1-final"
  },

  "commands": {
    "web": "Microsoft.AspNet.Server.Kestrel"
  },


  "frameworks": {
    "dnx451": {
      "dependencies": {
        "Microsoft.AspNet.Mvc.ViewFeatures": "6.0.0-rc1-final",
        "Microsoft.Extensions.DependencyInjection.Abstractions": "1.0.0-rc1-final"
      }
    },
    "dnxcore50": { }
  },

  "exclude": [
    "wwwroot",
    "node_modules",
    "bower_components"
  ],
  "publishExclude": [
    "node_modules",
    "bower_components",
    "**.xproj",
    "**.user",
    "**.vspscc"
  ]
}

Also see my last comment for problems caused by the option "Produce outputs on build", no fix for this yet.. But in general it seems that my issue was caused by a combination of this option and wrong dependecies.

Spons
  • 1,593
  • 1
  • 17
  • 46
  • There are a few questions in SO that might help, for example http://stackoverflow.com/questions/31907796/cs0433-the-type-listt-exists-in-both – Daniel J.G. Dec 21 '15 at 10:39
  • Thanks for the comment daniel but This one didn't help. Already tríed it out. – Spons Dec 21 '15 at 11:39
  • I tried, but I can't reproduce the problem. You should replace `"Microsoft.AspNet.Server.IIS": "1.0.0-beta7"` to `"Microsoft.AspNet.IISPlatformHandler": "1.0.0-rc1-final"` and probably add `"Microsoft.AspNet.Server.Kestrel": "1.0.0-rc1-final"`. You can move all dependencies from `"frameworks"."dnx451"` (to use `"frameworks": { "dnx451": { }, "dnxcore50": { } }`). I would recommend you to delete content of `%USERPROFILE%\.dnx\packages` and run `dnvm uninstall 1.0.0-rc2-16319 -r clr` and then run `dnvm upgrade`. It if will not help, please include content of `%APPDAT%\NuGet\NuGet.Config`. – Oleg Dec 25 '15 at 23:13
  • *It could be that you can unclean environment after some previous experiments.* As I wrote before, I would recommend you to uninstall unneeded frameworks (1.0.0-beta5, 1.0.0-rc2-16319), then delete the content of `%USERPROFILE%\.dnx\packages` and verify that you get NuGet packages only from `https://api.nuget.org/v3/index.json`. After that `dnu restore` (or saving `project.json` in Visual Studio) will reload all used packages. You can read [my old answer](http://stackoverflow.com/a/34421286/315935), where I described how to make clean experiment with unstable night build and then remove it. – Oleg Dec 25 '15 at 23:34
  • Thanks for your response Oleg.. I had a minute so played a bit around. emptied the .dxnx\packages folder. As well i cleaned out my dnvm which is now after the upgrade with only 1.0.0-rc1-update1. I replaced the dependicies that you said.. (Though did not moved the dependecies, as i did not understand you .. ), and none of it helped.. As well i checked my Nuget.config and cleaned it out to what you said. I was wondering.. do i need to upgrade my dependecies now to: "1.0.0-rc1-update1" ? – Spons Dec 26 '15 at 15:44
  • The `global.json` should have `"sdk": {"version": "1.0.0-rc1-update1"}`. Do you removed `"Microsoft.AspNet.Server.IIS": "1.0.0-beta7"`? Could you append your question with **UPDATED** part where you post the current `project.json`? I tried to reproduce your problem, but I don't get any errors. I just created an empty MVC6 WebApi application and added all the dependencies which you have. I have no errors. You can try to compile [the demo](http://www.ok-soft-gmbh.com/ForStackOverflow/WebApplication5.zip) on your computer or to provide some simple demo which could I use to reproduce your problem. – Oleg Dec 26 '15 at 17:10
  • Yes i did remove, i'll try to make a project from scratch and provide it if the issue persists! – Spons Dec 26 '15 at 17:12
  • @spons: Please use `@Oleg` for comments addressed to me. I don't get any notifications currently because I'm not the only person, who wrote comments to you above (see the comment from `DanielJ.G.`). – Oleg Dec 26 '15 at 18:44
  • @Oleg, setting up the project from scratch made me find a possible cause of a part of the problem! I used swagger (see: http://damienbod.com/2015/12/13/asp-net-5-mvc-6-api-documentation-using-swagger/) And step 2 of the tutorial shows to enable produce outputs on build.. This setting is causing at least the not finding of Microsoft.DNX.PackageManager. Which caused the troubles it seems. To be continued.. – Spons Jan 07 '16 at 16:08
  • @Oleg, see updated question, with new project.json and a shot on what caused the issue. I'll keep the question open for if you want post your comments as anwser and if you have any ideas on my above comment. – Spons Jan 07 '16 at 16:13

0 Answers0