Dependency conflict when project.json references csproj
Moved from https://github.com/aspnet/Mvc/issues/4680 By @pantonis
Steps to reproduce
Use the app from https://github.com/pantonis/AspNetRC2EFCore
It is a simple web app (project.json) that references a class library (csproj + packages.config) using this syntax:
"frameworks": {
"net46": {
"dependencies": {
"ClassLibrary1": {
"target": "project"
}
}
}
},
Expected behavior
Everything should compile and run.
Actual behavior
An exception of type 'System.IO.FileLoadException' occurred in Microsoft.Extensions.Configuration.FileExtensions.dll but was not handled in user code
Additional information: Could not load file or assembly 'Newtonsoft.Json, Version=8.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
Environment data
dotnet --info output:
N/A
/cc @emgarten @yishaigalatzer
This is the problem that happens when we don't read the packages.config as part of the dependency walk.
Please fix this asap. I think it is a very important bug and the workaround as described by @Eilon in https://github.com/aspnet/Mvc/issues/4680#issuecomment-221171047 is a little bit messy especially when it involves large projects.
I think 99% of the existing projects out there use .csproj class libraries. So there should be a way of smooth transition to asp.net core. I already saw a lot of people complaining about incompatibilities between .csproj and .xproj.
Thanks.
Yes, please, fix this asap. This bug is blocking us all
You should be able to move your class library to use project.json to define dependencies while still maintaining the csproj file, this should unblock you (and give you other goodness).
See: https://oren.codes/2016/02/08/project-json-all-the-things/
Get Outlook for Androidhttps://aka.ms/ghei36
On Tue, May 24, 2016 at 7:33 AM -0700, "nemenos" <[email protected]mailto:[email protected]> wrote:
Yes, please, fix this asap. This bug is blocking us all
You are receiving this because you were mentioned. Reply to this email directly or view it on GitHubhttps://github.com/dotnet/cli/issues/3205#issuecomment-221290318
You can also define the dependencies just like you would do in any asp.net 4 web application you would build
+1 it is blocking issue for us as well (I can do it in VS, but build server crashes) and no - the wrapper kinda work (didn't for dll, does for project /shrug). Going to try @yishaigalatzer suggestion now. Well that didn't work, because it automatically switched the project to use xproj, which unfortunately (always catch 22) doesn't support custom tools on grammar files and t4 templates, so no code generated as a result.
+1 Blocker for me
This is blocking us as well. New application xproj wants to consume three csproj-based libraries which are not maintained by us as they live in our code-base as git submodules. So where changing the dependency lib projects is not an option, the new project system is off the table?
First:
dotnet restore fails Unable to resolve 'csproj-based-project-name' for .NETFramework, Version=v4.5`` see dotnet/sdk#6224: same for 4.5.1, 4.5.2, 4.6, 4.6.1.
Then:
dotnet run/build fails fails error NU1001: The dependency csproj-based-project-name could not be resolved.
All this is happening in CLI.
From VS, the whole solution compiles and project runs.
+1 Would like fix. The work-around is working for me, except I don't get any intellisense for my project references. o.O
+1 Blocker
Tracking as NuGet issue.
@rrelyea what's the NuGet issue?
@sayedihashimi, https://github.com/NuGet/Home/issues/2865.
@dmikov moving to project.json next to the csproj doesn't move you to xproj. It is only used to define the nuget package dependencies.
If you can share your project here (or [email protected]), and we can try converting it for you.
@yishaigalatzer, we are using libraries as submodule which we don't own. So getting every upstream repo owner to agree on having project.json for our use-case with all of their csprojs is not a viable option and expensive thing to achieve, especially when everything is building with VS just fine.
This seems very much like a dotnet cli bug or one of its constituents.
Are there any non-project.json workarounds for this?
We have a simple ASP.NET Core RC1 web application (with csproj dependencies) that builds and publishes fine using msbuildand dnu, but that we cannot upgrade to ASP.NET Core RTM if there is no way to do command-line builds.
I'm on Windows, so any workaround requiring nugetand msbuildis fine.
Any solution for this problem? I'm using the latest and still cannot do a dotnet restore with csproj based projects.
Hitting this too. Any news?
I wouldn't expect progress on this until we make the move to msbuild
+1
Seems like a pretty fundamental requirement!