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 PrivateAssets? (VS2017 15.4) #6098

Open
emgarten opened this issue Oct 25, 2017 · 7 comments
Labels
Category:Quality Week Issues that should be considered for quality week Functionality:Restore Priority:2 Issues for the current backlog. Triage:Investigate Type:Bug
Milestone

Comments

@emgarten
Copy link
Member

From @philippe-lavoie on October 19, 2017 13:46

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.

Copied from original issue: dotnet/project-system#2909

@emgarten
Copy link
Member Author

From @Pilchie on October 23, 2017 23:3

@rrelyea @emgarten - should this be on NuGet?

@emgarten
Copy link
Member Author

@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

@emgarten
Copy link
Member Author

From @philippe-lavoie on October 25, 2017 13:42

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 Author

@philippe-lavoie would you share the obj/project.assets.json file for ProjectC (the root project)?

@rrelyea rrelyea changed the title Project reference in new csproj format do not obey PriveAssets? (VS2017 15.4) Project reference in new csproj format do not obey PrivateAssets? (VS2017 15.4) Oct 30, 2017
@rrelyea rrelyea added the Priority:2 Issues for the current backlog. label Oct 30, 2017
@rrelyea rrelyea added this to the Backlog milestone Oct 30, 2017
@mungojam
Copy link

I've seen similar behaviour where I think I had to delete .vs folder or obj and maybe restart VS for things to catch up

@mwpowellhtx
Copy link

Not PackageReference but rather ProjectReference. I think we're talking about internally distributed assets here, do not necessarily require a full on NuGet package for internal delivery. Is this still a thing? Is this a NuGet issue or an MSBuild issue? We are doing something similar, we are looking for an analog, if not the same, as the PackageReference/PrivateAssets path for ProjectReference, if possible.

@aortiz-msft aortiz-msft added the Category:Quality Week Issues that should be considered for quality week label Mar 30, 2020
@valadas
Copy link

valadas commented May 15, 2020

I am experiencing this issue too in Visual Studio 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Category:Quality Week Issues that should be considered for quality week Functionality:Restore Priority:2 Issues for the current backlog. Triage:Investigate Type:Bug
Projects
None yet
Development

No branches or pull requests

9 participants