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

PrivateAssets = All does not prevent the dependency from flowing to another project #3996

Open
MarkKharitonov opened this issue Dec 8, 2018 · 2 comments
Labels

Comments

@MarkKharitonov
Copy link

Steps to reproduce

I have two projects:

Project UITests:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>net472</TargetFramework>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="NUnit3TestAdapter" Version="3.11.2">
      <PrivateAssets>All</PrivateAssets>
    </PackageReference>
  </ItemGroup>
</Project>

Project Rollup:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>net472</TargetFramework>
  </PropertyGroup>
  <ItemGroup>
    <ProjectReference Include="..\UITests\UITests.csproj"/>
  </ItemGroup>
</Project>

The only code file is Class1.cs in UITests:

namespace UITests
{
    class Class1
    {
    }
}

The solution file is:

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.28307.136
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UITests", "UITests\UITests.csproj", "{47EF8446-D7D9-4B15-A170-BABBB5E5A30F}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Rollup", "Rollup\Rollup.csproj", "{9758E8DF-CB3E-46CE-B4E2-98B1D51651D6}"
EndProject
Global
	GlobalSection(SolutionConfigurationPlatforms) = preSolution
		Debug|Any CPU = Debug|Any CPU
		Release|Any CPU = Release|Any CPU
	EndGlobalSection
	GlobalSection(ProjectConfigurationPlatforms) = postSolution
		{47EF8446-D7D9-4B15-A170-BABBB5E5A30F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
		{47EF8446-D7D9-4B15-A170-BABBB5E5A30F}.Debug|Any CPU.Build.0 = Debug|Any CPU
		{47EF8446-D7D9-4B15-A170-BABBB5E5A30F}.Release|Any CPU.ActiveCfg = Release|Any CPU
		{47EF8446-D7D9-4B15-A170-BABBB5E5A30F}.Release|Any CPU.Build.0 = Release|Any CPU
		{9758E8DF-CB3E-46CE-B4E2-98B1D51651D6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
		{9758E8DF-CB3E-46CE-B4E2-98B1D51651D6}.Debug|Any CPU.Build.0 = Debug|Any CPU
		{9758E8DF-CB3E-46CE-B4E2-98B1D51651D6}.Release|Any CPU.ActiveCfg = Release|Any CPU
		{9758E8DF-CB3E-46CE-B4E2-98B1D51651D6}.Release|Any CPU.Build.0 = Release|Any CPU
	EndGlobalSection
	GlobalSection(SolutionProperties) = preSolution
		HideSolutionNode = FALSE
	EndGlobalSection
	GlobalSection(ExtensibilityGlobals) = postSolution
		SolutionGuid = {D10BCC6A-C354-4291-9DBF-C9863F7C62C0}
	EndGlobalSection
EndGlobal

Command line

C:\work\test [master ↑1 +3 ~1 -16 ~]> git clean -qdfx
C:\work\test [master ↑1 +3 ~1 -16 ~]> Test-Path .\Rollup\bin
False
C:\work\test [master ↑1 +3 ~1 -16 ~]> msbuild /t:Restore
Microsoft (R) Build Engine version 15.9.20+g88f5fadfbe for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.

Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
Build started 12/7/2018 9:38:21 PM.
Project "C:\work\test\Rollup.sln" on node 1 (Restore target(s)).
ValidateSolutionConfiguration:
  Building solution configuration "Debug|Any CPU".
Restore:
  Restoring packages for C:\work\test\Rollup\Rollup.csproj...
  Restoring packages for C:\work\test\UITests\UITests.csproj...
  Committing restore...
  Committing restore...
  Generating MSBuild file C:\work\test\Rollup\obj\Rollup.csproj.nuget.g.props.
  Generating MSBuild file C:\work\test\UITests\obj\UITests.csproj.nuget.g.props.
  Generating MSBuild file C:\work\test\UITests\obj\UITests.csproj.nuget.g.targets.
  Generating MSBuild file C:\work\test\Rollup\obj\Rollup.csproj.nuget.g.targets.
  Writing lock file to disk. Path: C:\work\test\UITests\obj\project.assets.json
  Writing lock file to disk. Path: C:\work\test\Rollup\obj\project.assets.json
  Restore completed in 214.98 ms for C:\work\test\UITests\UITests.csproj.
  Restore completed in 212.7 ms for C:\work\test\Rollup\Rollup.csproj.

  NuGet Config files used:
      C:\Users\mkharitonov\AppData\Roaming\NuGet\NuGet.Config
      C:\Program Files (x86)\NuGet\Config\Microsoft.VisualStudio.Offline.config

  Feeds used:
      https://api.nuget.org/v3/index.json
      C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\
Done Building Project "C:\work\test\Rollup.sln" (Restore target(s)).


Build succeeded.
    0 Warning(s)
    0 Error(s)

Time Elapsed 00:00:00.79
C:\work\test [master ↑1 +3 ~1 -16 ~]> msbuild /bl
Microsoft (R) Build Engine version 15.9.20+g88f5fadfbe for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.

C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\\MSBuild\15.0\bin\MSBuild.exe /bl .\Rollup.sln
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
Build started 12/7/2018 9:38:29 PM.
Project "C:\work\test\Rollup.sln" on node 1 (default targets).
ValidateSolutionConfiguration:
  Building solution configuration "Debug|Any CPU".
Project "C:\work\test\Rollup.sln" (1) is building "C:\work\test\UITests\UITests.csproj" (2) on node 1 (default targets).
PrepareForBuild:
  Creating directory "bin\Debug\net472\".
  Creating directory "obj\Debug\net472\".
GenerateTargetFrameworkMonikerAttribute:
Skipping target "GenerateTargetFrameworkMonikerAttribute" because all output files are up-to-date with respect to the input files.
CoreCompile:
  C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\bin\Roslyn\csc.exe /noconfig /unsafe- /checked- /nowarn:1701,1702,1701,1702 /nostdl
  ib+ /errorreport:prompt /warn:4 /define:TRACE;DEBUG;NETFRAMEWORK;NET472 /highentropyva+ /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Frame
  work\.NETFramework\v4.7.2\mscorlib.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\System.Core.dll" /refe
  rence:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\System.Data.dll" /reference:"C:\Program Files (x86)\Reference Assem
  blies\Microsoft\Framework\.NETFramework\v4.7.2\System.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\Sys
  tem.Drawing.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\System.IO.Compression.FileSystem.dll" /refere
  nce:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\System.Numerics.dll" /reference:"C:\Program Files (x86)\Reference Ass
  emblies\Microsoft\Framework\.NETFramework\v4.7.2\System.Runtime.Serialization.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\
  .NETFramework\v4.7.2\System.Xml.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\System.Xml.Linq.dll" /deb
  ug+ /debug:portable /filealign:512 /optimize- /out:obj\Debug\net472\UITests.dll /ruleset:"C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Team T
  ools\Static Analysis Tools\\Rule Sets\MinimumRecommendedRules.ruleset" /subsystemversion:6.00 /target:library /warnaserror+ /utf8output /deterministic+ Class1.
  cs "C:\Users\mkharitonov\AppData\Local\Temp\.NETFramework,Version=v4.7.2.AssemblyAttributes.cs" obj\Debug\net472\UITests.AssemblyInfo.cs /warnaserror+:NU1605
  Using shared compilation with compiler from directory: C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\bin\Roslyn
_CopyOutOfDateSourceItemsToOutputDirectory:
  Copying file from "C:\Users\mkharitonov\.nuget\packages\nunit3testadapter\3.11.2\build\net35\nunit.engine.dll" to "bin\Debug\net472\nunit.engine.dll".
  Copying file from "C:\Users\mkharitonov\.nuget\packages\nunit3testadapter\3.11.2\build\net35\nunit.engine.api.dll" to "bin\Debug\net472\nunit.engine.api.dll".
  Copying file from "C:\Users\mkharitonov\.nuget\packages\nunit3testadapter\3.11.2\build\net35\NUnit3.TestAdapter.dll" to "bin\Debug\net472\NUnit3.TestAdapter.dl
  l".
  Copying file from "C:\Users\mkharitonov\.nuget\packages\nunit3testadapter\3.11.2\build\net35\NUnit3.TestAdapter.pdb" to "bin\Debug\net472\NUnit3.TestAdapter.pd
  b".
CopyFilesToOutputDirectory:
  Copying file from "obj\Debug\net472\UITests.dll" to "bin\Debug\net472\UITests.dll".
  UITests -> C:\work\test\UITests\bin\Debug\net472\UITests.dll
  Copying file from "obj\Debug\net472\UITests.pdb" to "bin\Debug\net472\UITests.pdb".
Done Building Project "C:\work\test\UITests\UITests.csproj" (default targets).

Project "C:\work\test\Rollup.sln" (1) is building "C:\work\test\Rollup\Rollup.csproj" (3) on node 1 (default targets).
PrepareForBuild:
  Creating directory "bin\Debug\net472\".
  Creating directory "obj\Debug\net472\".
GenerateTargetFrameworkMonikerAttribute:
Skipping target "GenerateTargetFrameworkMonikerAttribute" because all output files are up-to-date with respect to the input files.
CoreCompile:
  C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\bin\Roslyn\csc.exe /noconfig /unsafe- /checked- /nowarn:1701,1702,1701,1702 /nostdl
  ib+ /errorreport:prompt /warn:4 /define:TRACE;DEBUG;NETFRAMEWORK;NET472 /highentropyva+ /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Frame
  work\.NETFramework\v4.7.2\mscorlib.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\System.Core.dll" /refe
  rence:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\System.Data.dll" /reference:"C:\Program Files (x86)\Reference Assem
  blies\Microsoft\Framework\.NETFramework\v4.7.2\System.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\Sys
  tem.Drawing.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\System.IO.Compression.FileSystem.dll" /refere
  nce:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\System.Numerics.dll" /reference:"C:\Program Files (x86)\Reference Ass
  emblies\Microsoft\Framework\.NETFramework\v4.7.2\System.Runtime.Serialization.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\
  .NETFramework\v4.7.2\System.Xml.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\System.Xml.Linq.dll" /ref
  erence:C:\work\test\UITests\bin\Debug\net472\UITests.dll /debug+ /debug:portable /filealign:512 /optimize- /out:obj\Debug\net472\Rollup.dll /ruleset:"C:\Progra
  m Files (x86)\Microsoft Visual Studio\2017\Enterprise\Team Tools\Static Analysis Tools\\Rule Sets\MinimumRecommendedRules.ruleset" /subsystemversion:6.00 /targ
  et:library /warnaserror+ /utf8output /deterministic+ obj\Debug\net472\Rollup.AssemblyInfo.cs /warnaserror+:NU1605
  Using shared compilation with compiler from directory: C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\bin\Roslyn
_CopyFilesMarkedCopyLocal:
  Copying file from "C:\work\test\UITests\bin\Debug\net472\UITests.dll" to "bin\Debug\net472\UITests.dll".
  Copying file from "C:\work\test\UITests\bin\Debug\net472\UITests.pdb" to "bin\Debug\net472\UITests.pdb".
  Creating "C:\work\test\Rollup\obj\Debug\net472\Rollup.csproj.CopyComplete" because "AlwaysCreate" was specified.
_CopyOutOfDateSourceItemsToOutputDirectory:
  Copying file from "C:\Users\mkharitonov\.nuget\packages\nunit3testadapter\3.11.2\build\net35\nunit.engine.dll" to "bin\Debug\net472\nunit.engine.dll".
  Copying file from "C:\Users\mkharitonov\.nuget\packages\nunit3testadapter\3.11.2\build\net35\NUnit3.TestAdapter.pdb" to "bin\Debug\net472\NUnit3.TestAdapter.pd
  b".
  Copying file from "C:\Users\mkharitonov\.nuget\packages\nunit3testadapter\3.11.2\build\net35\nunit.engine.api.dll" to "bin\Debug\net472\nunit.engine.api.dll".
  Copying file from "C:\Users\mkharitonov\.nuget\packages\nunit3testadapter\3.11.2\build\net35\NUnit3.TestAdapter.dll" to "bin\Debug\net472\NUnit3.TestAdapter.dl
  l".
CopyFilesToOutputDirectory:
  Copying file from "obj\Debug\net472\Rollup.dll" to "bin\Debug\net472\Rollup.dll".
  Rollup -> C:\work\test\Rollup\bin\Debug\net472\Rollup.dll
  Copying file from "obj\Debug\net472\Rollup.pdb" to "bin\Debug\net472\Rollup.pdb".
Done Building Project "C:\work\test\Rollup\Rollup.csproj" (default targets).

Done Building Project "C:\work\test\Rollup.sln" (default targets).

Deferred Messages

  Detailed Build Summary
  ======================


  ============================== Build Hierarchy (IDs represent configurations) =====================================================
  Id                  : Exclusive Time   Total Time   Path (Targets)
  -----------------------------------------------------------------------------------------------------------------------------------
  0                   : 0.046s           0.851s       C:\work\test\Rollup.sln ()
  | 1                 : 0.580s           0.580s       C:\work\test\UITests\UITests.csproj ()
  . 2                 : 0.209s           0.226s       C:\work\test\Rollup\Rollup.csproj ()
  | | 3               : 0.009s           0.009s       C:\work\test\UITests\UITests.csproj (GetTargetFrameworks)
  | . 4               : 0.008s           0.008s       C:\work\test\UITests\UITests.csproj (GetNativeManifest)

  ============================== Node Utilization (IDs represent configurations) ====================================================
  Timestamp:            1        Duration   Cumulative
  -----------------------------------------------------------------------------------------------------------------------------------
  636798335100192873:   0        0.034s     0.034s
  636798335100533786:   1        0.580s     0.614s ###########
  636798335106329212:   2        0.063s     0.677s #
  636798335106961300:   3        0.008s     0.685s
  636798335107041507:   2        0.040s     0.725s
  636798335107442188:   4        0.008s     0.733s
  636798335107522409:   2        0.106s     0.839s ##
  636798335108585229:   0        0.012s     0.851s
  -----------------------------------------------------------------------------------------------------------------------------------
  Utilization:          100.0    Average Utilization: 100.0

Build succeeded.
    0 Warning(s)
    0 Error(s)

Time Elapsed 00:00:00.94
C:\work\test [master ↑1 +3 ~1 -16 | +1 ~0 -0 !]> dir .\Rollup\bin\Debug\net472\NUnit3.TestAdapter.dll


    Directory: C:\work\test\Rollup\bin\Debug\net472


Mode                LastWriteTime         Length Name
----                -------------         ------ ----
-a----       11/22/2018   7:56 AM         352768 NUnit3.TestAdapter.dll


C:\work\test [master ↑1 +3 ~1 -16 | +1 ~0 -0 !]>

Expected behavior

The dependency NUnit3TestAdapter of UITests does not end up in the bin folder of Rollup, because it has PrivateAssets = All

Actual behavior

It ends up there as if PrivateAssets does not matter.

Environment data

C:\work\test [master ↑1 +3 ~1 -16 | +1 ~0 -0 !]> msbuild /version
Microsoft (R) Build Engine version 15.9.20+g88f5fadfbe for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.

15.9.20.62856

I can attach the binlog, if needed.

@rowland-banks-abide
Copy link

This Stack Overflow answer appears to be related. It describes how NUnit3TestAdapter has a .props file which causes dlls to be added as Content files of the original project.

@MarkKharitonov
Copy link
Author

Yes it does. (That is my SO question, btw)

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