4

I notice there is a circular problem with warnings issued by Visual Studio 2015, for a project with asp.net 5 beta8 specified (1.0.0-beta8 DNX framework), and also that CS1703 errors are now a problem for me, starting in beta7, and continuing in beta8, and no such problem occurred in beta6.

I have solution containing a main project, and some sub-assemblies, in one of those sub assemblies there is a project.json which is part of a Class Library project (.xproj) that defines an abstract set of interfaces, and it contains some list of dependencies like this and each of these dependencies exists mostly so I can use types defined in these assemblies in my interface definitions.

The entire project.json for the plugin-contract assembly is:

{
  "version": "1.0.0-*",
  "description": "ITConsolePluginContract Class Library",
  "authors": [ "wpostma" ],
  "tags": [ "" ],
  "projectUrl": "",
  "licenseUrl": "",

  "dependencies": {
    "Microsoft.CSharp": "????",
    "System.Collections": "4.0.0-*",
    "System.Threading": "4.0.0-*",
    "System.Linq": "4.0.1-*",
    "System.Runtime": "4.0.21-*",
    "Newtonsoft.Json": "7.0.1"
  },

  "frameworks": {
    "dotnet": { }
  }
}

However in my main app which consumes this assembly, I have:

  "frameworks": {
    "dnx451": { }

  },

In this situation, the problem I see is that I keep getting "Dependency specified was Microsoft.CSharp >= X but ended up with Microsoft.CSharp Y. No matter whether I put 4.0.0-* or 4.0.1-* in the above project.json, I get the warning that it resolved the other way, I can get around that by removing the Microsoft.CSharp item, but that leaves behind one or more CS1703 errors, and if I can get rid of the CS1703 errors, then I get back to the state where the compilation fails because of a missing Microsoft.CSharp dependency. This is a circle of failures, I'm trying to figure out how to get out of the maze.

enter image description here

I'm trying to understand and repair these two kinds of problems and I have figured out so far:

  • It matters that this is one project within a solution which has dependencies on other projects in the same solution, plus upon public internet fetched nuget packages.

  • I believe I need to make sure I remove any explicit references to packages that are for dnx 1.0 beta 7 or earlier, however doing this is non-trivial since the package versions are not all numbered identically. For example, System.Collections 4.0.10 and 4.0.11-beta versions are available and it's not clear from just the version numbering itself which is for beta 7 or 6 or 8 or 4 or whatever.

So given that, how do you clean up a package and its references? I realize that this problem is exacerbated by the frequent breaking changes in the ASP.NET beta cycle, but I think this is a microcosm, a time-compressed view, into the future of maintaining a Asp.Net application over time.

What in particular causes the circular behavior I observe above, and how do you fix this? What practice can be used to avoid falling into this pit of failure?

Secondly, is this behaviour linked in any way to the two build errors I also have right now:

CS1703  Multiple assemblies with equivalent identity have been imported: 'C:\Users\LOCALUSERNAME\.dnx\packages\System.Collections\4.0.10\ref\dotnet\System.Collections.dll' and 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.1\Facades\System.Collections.dll'. Remove one of the duplicate references.      

CS1703  Multiple assemblies with equivalent identity have been imported: 'C:\Users\LOCALUSERNAME\.dnx\packages\System.Threading\4.0.10\ref\dotnet\System.Threading.dll' and 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.1\Facades\System.Threading.dll'. Remove one of the duplicate references.    

Update: I suspect that my projects may be falling into a pit of over-specifying dependencies. If I need dynamic things to work, I need to add Microsoft.CSharp, and if I don't absolutely need it, I shouldn't have that in my project.json. That is, that I should seek a minimal set of required dependencies, and add them back one at a time, when I'm in a bad state, starting with the assemblies with few or no dependencies on other items in the same solution. So in this exact I am asking about, the answer is "remove the unnecessary item(s) from project.json, in this case, remove the Microsoft.CSharp line from the dependencies". I am not just asking "how do I fix one particular manifest", but I hope rather, I can make this question a useful general resource on these rather odd warnings and prompts that Visual Studio gives you that I don't feel are helping me to understand and repair the underlying problem. For that to happen, one has to understand what's happening at build time in the DNX/DNU level and at the visual studio tooling level, and then also, at the .Net class loader level (at runtime).

Update2: I have a solution, which contains several ASP.NET 5 .xproj elements, each of which depends on what I thought was the right framework for that project element. The main asp.net web application depends currently on framework dnx451, but my plugin-contract (defines interfaces and no implementations for plugins) depends on framework dotnet which I think is perhaps the right thing for such an "abstract" assembly, whose purpose is to define types (interfaces) and it defines no actual implementation (no classes).

update3: The best I have achieved now is to reduce the error to 1 remaining CS1703, and it appears that perhaps mixing framework monikers might be the cause, and I wonder if the mixup is actually between my project.json and the auto-generated project.lock.json, that is to say, I'm hitting a bug in ASP.NET 5 tooling that is new in beta8.

 Build  The design time host build failed with the following error:   
 error CS1703: Multiple assemblies with equivalent identity have been  
 imported:
 'C:\Users\USERNAME\.dnx\packages\System.Runtime\4.0.21-beta-23409\ref\dotnetSystem.Runtime.dll'
 and 'C:\Program Files (x86)\Reference
 Assemblies\Microsoft\Framework\.NETFramework\v4.5.1\FacadesSystem.Runtime.dll'.
 Remove one of the duplicate references.

This error changes to another cryptic error if I drop everything back to beta7 to see if this is a beta8 bug:

CS1703  Build   Multiple assemblies with equivalent identity have been imported: '<in-memory assembly>' and '<in-memory assembly>'. Remove one of the duplicate references. 

Example project on bitbucket, in mercurial: https://bitbucket.org/wpostma/itconsole-demo

Warren P
  • 65,725
  • 40
  • 181
  • 316
  • why do you use `dotnet` framework instead of `dnxXXX` or `dnxcore50`? – pg0xC Oct 16 '15 at 16:02
  • 1
    That may stem from my own confusion. What changes if I change it to dnxXXX? (`dnx451`) . related: http://stackoverflow.com/questions/31539341/project-json-definition-dnx451-vs-dotnet-4-51 – Warren P Oct 16 '15 at 16:23
  • I have found that when crazy things like this need to be debugged or troubleshooted, it helps to go clean up my `C:\Users\USERNAME\.dnx\packages` and `C:\Users\USERNAME\.dnx\runtime` folders, and delete the `project.lock.json` files, and experiment with what framework is required, `dotnet`, or `dnx451` or `dnxcore50`, but in my particular case I face a series of catch-22s. – Warren P Oct 16 '15 at 17:37
  • I am almost sure that System.Runtime 4.0.21 should not be loaded in dnx451 - maybe you build against it and trying to load both mscorelib and System.Runtime 4.0.21? Try building against coreclr only. – pg0xC Oct 16 '15 at 18:29
  • How do I do that? Specify Framework=dotnet in the main ASP.NET app as well as in all relevant sub-assemblies? – Warren P Oct 16 '15 at 18:53
  • (EDITED farmework name) Specify Framework `dnxcore50` I think this is the only way – pg0xC Oct 16 '15 at 19:05
  • That appears to be a key element of the solution. After doing that, I get different errors, which are probably due to other breaking API changes between beta6 and beta8. – Warren P Oct 16 '15 at 19:08
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/92536/discussion-between-pg0xc-and-warren-p). – pg0xC Oct 16 '15 at 19:12
  • Are you sure you need to specify `Microsoft.CSharp` at all? I think you receive the warning because a newer version of this package was pulled in by a dependency. You can use `dnu list` to see what gets pulled by what. – Pawel Oct 19 '15 at 21:15
  • Cool. `dnu list` is a good thing to know about. – Warren P Oct 21 '15 at 14:55

1 Answers1

1

Microsoft.CSharp should only be imported for dnxcore50.

See example here:

https://github.com/aspnet/dnx/blob/2acce95b3f2ad4e924bc36471ed8f08ee1fccd2b/misc/BootstrapperSolution/src/TesterProgram/project.json

You are actually trying to re-import something that already exist as part of the dnx451 moniker.

NOTE:

Monikers have changed with RC1. I'm using the monikers for beta7/8 here.

Community
  • 1
  • 1
Maxime Rouiller
  • 13,614
  • 9
  • 57
  • 107