sdk icon indicating copy to clipboard operation
sdk copied to clipboard

Dependency conflict when project.json references csproj

Open Eilon opened this issue 10 years ago • 47 comments

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

Eilon avatar May 23 '16 19:05 Eilon

/cc @emgarten @yishaigalatzer

This is the problem that happens when we don't read the packages.config as part of the dependency walk.

davidfowl avatar May 24 '16 03:05 davidfowl

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.

pantonis avatar May 24 '16 06:05 pantonis

Yes, please, fix this asap. This bug is blocking us all

nemenos avatar May 24 '16 14:05 nemenos

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

yishaigalatzer avatar May 24 '16 14:05 yishaigalatzer

You can also define the dependencies just like you would do in any asp.net 4 web application you would build

yishaigalatzer avatar May 24 '16 14:05 yishaigalatzer

+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.

dmikov avatar May 25 '16 10:05 dmikov

+1 Blocker for me

amcdnl avatar May 25 '16 11:05 amcdnl

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.

ghost avatar May 25 '16 20:05 ghost

+1 Would like fix. The work-around is working for me, except I don't get any intellisense for my project references. o.O

guardiannite avatar May 26 '16 21:05 guardiannite

+1 Blocker

kt215 avatar May 30 '16 21:05 kt215

Tracking as NuGet issue.

rrelyea avatar May 31 '16 16:05 rrelyea

@rrelyea what's the NuGet issue?

sayedihashimi avatar Jun 03 '16 17:06 sayedihashimi

@sayedihashimi, https://github.com/NuGet/Home/issues/2865.

joelverhagen avatar Jun 03 '16 18:06 joelverhagen

@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 avatar Jun 07 '16 00:06 yishaigalatzer

@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.

ghost avatar Jun 07 '16 06:06 ghost

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.

tomten avatar Jul 06 '16 08:07 tomten

Any solution for this problem? I'm using the latest and still cannot do a dotnet restore with csproj based projects.

tessierp avatar Aug 29 '16 14:08 tessierp

Hitting this too. Any news?

gmartinezsan avatar Aug 30 '16 22:08 gmartinezsan

I wouldn't expect progress on this until we make the move to msbuild

yishaigalatzer avatar Aug 31 '16 16:08 yishaigalatzer

+1

Seems like a pretty fundamental requirement!

bandito22 avatar Oct 04 '16 11:10 bandito22