Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PackageReference/ProjectReference transitive behavior #3241

Closed
meziantou opened this issue Apr 26, 2018 · 2 comments
Closed

PackageReference/ProjectReference transitive behavior #3241

meziantou opened this issue Apr 26, 2018 · 2 comments
Labels

Comments

@meziantou
Copy link

Steps to reproduce

  1. Create a new solution
  2. Add 2 C# Class Library (.NET Framework) projects named ClassLibrary1 and ClassLibrary2
  3. Add a project reference: ClassLibrary2 references ClassLibrary1
  4. Add a NuGet reference in ClassLibrary1 to Newtonsoft.Json (<PackageReference>)
  5. In ClassLibrary2 add the following code
public class Class1
{
    public void A() => Newtonsoft.Json.JsonConvert.SerializeObject(null); // Use Newtonsoft.Json
}

Execute the following command line

msbuild /bl

=> Build failed

In ClassLibrary2 add a NuGet reference to a NuGet package that doesn't depend on Newtonsoft.Json, such as NUnit (<PackageReference>)

Execute the following command line

msbuild /bl

=> Build succeed

Expected behavior

I think the first build should succeed, or the second one should fail.

Actual behavior

It fails.

Environment data

msbuild /version output:
15.6.85.37198

OS info:
Windows 10 1607

If applicable, version of the tool that invokes MSBuild (Visual Studio, dotnet CLI, etc):
Visual Studio 15.6.7 and command line (msbuild)

@rainersigwald
Copy link
Member

This is a NuGet behavior. Older versions of NuGet didn't treat dependencies as transitive in this way, so NuGet (currently) requires you to explicitly opt into the new behavior from your ClassLibrary2 with

<RestoreProjectStyle>PackageReference</RestoreProjectStyle>

NuGet/Home#4581 would also help for this case.

@rainersigwald
Copy link
Member

Duplicate of NuGet/Home#4488

@rainersigwald rainersigwald marked this as a duplicate of NuGet/Home#4488 Apr 26, 2018
@AR-May AR-May added the triaged label Feb 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants