From 5e74847c50be30d89d299f7a49be83c6955e20a6 Mon Sep 17 00:00:00 2001 From: Jared Parsons Date: Thu, 16 Nov 2017 15:20:14 -0800 Subject: [PATCH 1/2] Add DisableImplicitTransitiveReferences This implements the feature described in #1750. It provides projects with a way to explicitly opt-out of implicit transitive refernces by setting the DisableImplicitTransitiveReferences property to `'true'`. closes #1750 --- ...rosoft.PackageDependencyResolution.targets | 4 +++- ...ntToBuildAnAppWithTransitiveProjectRefs.cs | 23 +++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/Tasks/Microsoft.NET.Build.Tasks/build/Microsoft.PackageDependencyResolution.targets b/src/Tasks/Microsoft.NET.Build.Tasks/build/Microsoft.PackageDependencyResolution.targets index c85e09ec507e..3491eebe105e 100644 --- a/src/Tasks/Microsoft.NET.Build.Tasks/build/Microsoft.PackageDependencyResolution.targets +++ b/src/Tasks/Microsoft.NET.Build.Tasks/build/Microsoft.PackageDependencyResolution.targets @@ -462,6 +462,7 @@ Copyright (c) .NET Foundation. All rights reserved. --> @@ -479,6 +480,7 @@ Copyright (c) .NET Foundation. All rights reserved. @@ -593,4 +595,4 @@ Copyright (c) .NET Foundation. All rights reserved. - \ No newline at end of file + diff --git a/test/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildAnAppWithTransitiveProjectRefs.cs b/test/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildAnAppWithTransitiveProjectRefs.cs index 80e458e8232d..8d08dc68e6fa 100644 --- a/test/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildAnAppWithTransitiveProjectRefs.cs +++ b/test/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildAnAppWithTransitiveProjectRefs.cs @@ -122,5 +122,28 @@ public void The_clean_target_removes_all_files_from_the_output_folder() outputDirectory.Should().OnlyHaveFiles(Array.Empty()); } + + [Fact] + public void It_does_not_build_the_project_successfully() + { + // NOTE the project dependencies in AppWithTransitiveProjectRefs: + // TestApp --depends on--> MainLibrary --depends on--> AuxLibrary + // (TestApp transitively depends on AuxLibrary) + + var testAsset = _testAssetsManager + .CopyTestAsset("AppWithTransitiveProjectRefs", "BuildAppWithTransitiveProjectRefDisabled") + .WithSource(); + + testAsset.Restore(Log, "TestApp"); + testAsset.Restore(Log, "MainLibrary"); + testAsset.Restore(Log, "AuxLibrary"); + + var appProjectDirectory = Path.Combine(testAsset.TestRoot, "TestApp"); + var buildCommand = new BuildCommand(Log, appProjectDirectory); + buildCommand + .Execute("/p:DisableImplicitTransitiveReferences=true") + .Should() + .Fail(); + } } } From 7069f82d46e803d73d3d3b5e17da1442fb8182f2 Mon Sep 17 00:00:00 2001 From: Jared Parsons Date: Thu, 16 Nov 2017 16:59:25 -0800 Subject: [PATCH 2/2] Change prop name to DisableTransitiveProjectReferences --- .../build/Microsoft.PackageDependencyResolution.targets | 4 ++-- .../GivenThatWeWantToBuildAnAppWithTransitiveProjectRefs.cs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Tasks/Microsoft.NET.Build.Tasks/build/Microsoft.PackageDependencyResolution.targets b/src/Tasks/Microsoft.NET.Build.Tasks/build/Microsoft.PackageDependencyResolution.targets index 3491eebe105e..d0f4d4fac516 100644 --- a/src/Tasks/Microsoft.NET.Build.Tasks/build/Microsoft.PackageDependencyResolution.targets +++ b/src/Tasks/Microsoft.NET.Build.Tasks/build/Microsoft.PackageDependencyResolution.targets @@ -462,7 +462,7 @@ Copyright (c) .NET Foundation. All rights reserved. --> @@ -480,7 +480,7 @@ Copyright (c) .NET Foundation. All rights reserved. diff --git a/test/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildAnAppWithTransitiveProjectRefs.cs b/test/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildAnAppWithTransitiveProjectRefs.cs index 8d08dc68e6fa..f82554006e80 100644 --- a/test/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildAnAppWithTransitiveProjectRefs.cs +++ b/test/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildAnAppWithTransitiveProjectRefs.cs @@ -141,7 +141,7 @@ public void It_does_not_build_the_project_successfully() var appProjectDirectory = Path.Combine(testAsset.TestRoot, "TestApp"); var buildCommand = new BuildCommand(Log, appProjectDirectory); buildCommand - .Execute("/p:DisableImplicitTransitiveReferences=true") + .Execute("/p:DisableTransitiveProjectReferences=true") .Should() .Fail(); }