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

Project reference in new csproj format do not obey PriveAssets? (VS2017 15.4) #2909

Closed
philippe-lavoie opened this issue Oct 19, 2017 · 6 comments
Labels
Area-External Owned by another feature area and not this repo. Likely be closed in lieu of issue against it.

Comments

@philippe-lavoie
Copy link

philippe-lavoie commented Oct 19, 2017

According to issue 2313, when adding below inside BasicModel, it should stop the reference from flowing to other projects.

  <ItemGroup>
    <ProjectReference Include="..\BasicModule.Contracts\BasicModule.Contracts.csproj" PrivateAssets="All">
    </ProjectReference>
  </ItemGroup>

However, inside my unit tests, which does a project reference to BasicModel, the project.assets file contains the following

  "BasicModule/40.0.0": {
    "type": "project",
    "framework": ".NETStandard,Version=v2.0",
    "dependencies": {
      "Module": "40.0.0"
    },
    "compile": {
      "bin/placeholder/BasicModule.dll": {}
    },
    "runtime": {
      "bin/placeholder/BasicModule.dll": {}
    }
  },
  "BasicModule.Contracts/40.0.0": {
    "type": "project",
    "framework": ".NETStandard,Version=v2.0",
    "dependencies": {
      "Contracts": "40.0.0"
    },
    "compile": {
      "bin/placeholder/BasicModule.Contracts.dll": {}
    },
    "runtime": {
      "bin/placeholder/BasicModule.Contracts.dll": {}
    }
  },

So, chaining is definitely still occurring.

@philippe-lavoie philippe-lavoie changed the title How can I disable transitive project reference in new csproj format? (VS2017 15.4) Project reference in new csproj format do not obey PriveAssets? (VS2017 15.4) Oct 20, 2017
@Pilchie
Copy link
Member

Pilchie commented Oct 23, 2017

@rrelyea @emgarten - should this be on NuGet?

@emgarten
Copy link
Member

@philippe-lavoie take a look at: https://docs.microsoft.com/en-us/nuget/consume-packages/package-references-in-project-files#controlling-dependency-assets

Based on your description you might be looking for ReferenceOutputAssembly=false

Here are some examples:

// UnitTests gets BasicModule
UnitTests -(PrivateAssets=All)-> BasicModule  

// ProjectA does not see BasicModule
ProjectA -> UnitTests -(PrivateAssets=All)-> BasicModule  

// UnitTests does not see BasicModule
UnitTests -(ReferenceOutputAssembly=false)-> BasicModule

@philippe-lavoie
Copy link
Author

I have the second situation you mention and ProjectA does see the nuget reference to BasicModule. You are implying it does not see it, but it does.

To be clear, the configuration is

Unit Test -> BasicModule -> (PrivateAssets=All) BasicModuleContract

i.e. the BasicModuleContract is linked by BasicModule as a private assets

This is bad when content files are also promoted by this bug. I have a nuget that has content files and even with PrivateAssets=All, those files still get promoted and included in a project that has a PackageReference to it or any project referencing it afterwards.

ProjectA / contentFiles / Bob.txt

ProjectB -> Project A (PrivateAssets=All)
ProjectC -> Project B (PrivateAssets = All)

when you look inside visual Studio, Bob.txt is still showing up inside ProjectC.

@emgarten
Copy link
Member

This issue was moved to NuGet/Home#6098

@emgarten
Copy link
Member

@philippe-lavoie let's continue debugging this at NuGet/Home#6098

@Pilchie this can be closed, I don't think this is related to the project system.

@Pilchie
Copy link
Member

Pilchie commented Oct 25, 2017

Thanks @emgarten closing as external.

@Pilchie Pilchie closed this as completed Oct 25, 2017
@Pilchie Pilchie added the Area-External Owned by another feature area and not this repo. Likely be closed in lieu of issue against it. label Oct 25, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-External Owned by another feature area and not this repo. Likely be closed in lieu of issue against it.
Projects
None yet
Development

No branches or pull requests

3 participants