diff --git a/TestAssets/TestProjects/TestApp/project.json b/TestAssets/TestProjects/TestApp/project.json
index 5fd2a8c4f..325f56373 100644
--- a/TestAssets/TestProjects/TestApp/project.json
+++ b/TestAssets/TestProjects/TestApp/project.json
@@ -1,11 +1,12 @@
{
"version": "1.0.0-*",
"compilationOptions": {
- "emitEntryPoint": true
+ "emitEntryPoint": true,
+ "preserveCompilationContext": true
},
"dependencies": {
- "TestLibrary": { "target":"project"},
+ "TestLibrary": { "target":"project", "version":"1.0.0-*" },
"NETStandard.Library": "1.0.0-rc2-23810"
},
diff --git a/TestAssets/TestProjects/TestAppWithTransitiveAppDependency/Program.cs b/TestAssets/TestProjects/TestAppWithTransitiveAppDependency/Program.cs
new file mode 100644
index 000000000..b1520563c
--- /dev/null
+++ b/TestAssets/TestProjects/TestAppWithTransitiveAppDependency/Program.cs
@@ -0,0 +1,17 @@
+// Copyright (c) .NET Foundation and contributors. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+
+using System;
+using System.Diagnostics;
+
+namespace TestApp
+{
+ public class Program
+ {
+ public static int Main(string[] args)
+ {
+ Console.WriteLine(TestLibrary.Helper.GetMessage());
+ return 0;
+ }
+ }
+}
diff --git a/TestAssets/TestProjects/TestAppWithTransitiveAppDependency/project.json b/TestAssets/TestProjects/TestAppWithTransitiveAppDependency/project.json
new file mode 100644
index 000000000..645f29a2c
--- /dev/null
+++ b/TestAssets/TestProjects/TestAppWithTransitiveAppDependency/project.json
@@ -0,0 +1,16 @@
+{
+ "version": "1.0.0-*",
+ "compilationOptions": {
+ "emitEntryPoint": true
+ },
+
+ "dependencies": {
+ "TestLibraryWithAppDependency": { "target":"project", "version":"1.0.0-*" },
+
+ "NETStandard.Library": "1.0.0-rc2-23808"
+ },
+
+ "frameworks": {
+ "dnxcore50": { }
+ },
+}
diff --git a/TestAssets/TestProjects/TestLibraryWithAppDependency/Helper.cs b/TestAssets/TestProjects/TestLibraryWithAppDependency/Helper.cs
new file mode 100644
index 000000000..b24d91ae4
--- /dev/null
+++ b/TestAssets/TestProjects/TestLibraryWithAppDependency/Helper.cs
@@ -0,0 +1,24 @@
+// Copyright (c) .NET Foundation and contributors. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+
+using System;
+
+namespace TestLibrary2
+{
+ public static class Helper
+ {
+ ///
+ /// Gets the message from the helper. This comment is here to help test XML documentation file generation, please do not remove it.
+ ///
+ /// A message
+ public static string GetMessage()
+ {
+ return "This string came from the test library!";
+ }
+
+ public static void SayHi()
+ {
+ Console.WriteLine("Hello there!");
+ }
+ }
+}
diff --git a/TestAssets/TestProjects/TestLibraryWithAppDependency/project.json b/TestAssets/TestProjects/TestLibraryWithAppDependency/project.json
new file mode 100644
index 000000000..b63bfedad
--- /dev/null
+++ b/TestAssets/TestProjects/TestLibraryWithAppDependency/project.json
@@ -0,0 +1,12 @@
+{
+ "version": "1.0.0-*",
+ "dependencies": {
+ "TestApp": { "target":"project", "version":"1.0.0-*" },
+
+ "NETStandard.Library": "1.0.0-rc2-23808",
+ },
+
+ "frameworks": {
+ "dnxcore50": { }
+ }
+}
diff --git a/src/dotnet/commands/dotnet-build/CompileContext.cs b/src/dotnet/commands/dotnet-build/CompileContext.cs
index 21fa11e06..0cae3a45b 100644
--- a/src/dotnet/commands/dotnet-build/CompileContext.cs
+++ b/src/dotnet/commands/dotnet-build/CompileContext.cs
@@ -91,7 +91,7 @@ namespace Microsoft.DotNet.Tools.Build
private bool NeedsRebuilding(ProjectContext project, ProjectDependenciesFacade dependencies, string baseBuildPath)
{
- var compilerIO = GetCompileIO(project, _args.ConfigValue, baseBuildPath, _args.OutputValue, dependencies);
+ var compilerIO = GetCompileIO(project, _args.ConfigValue, baseBuildPath, _args.OutputValue, dependencies, project == _rootProject);
// rebuild if empty inputs / outputs
if (!(compilerIO.Outputs.Any() && compilerIO.Inputs.Any()))
@@ -437,12 +437,7 @@ namespace Microsoft.DotNet.Tools.Build
// computes all the inputs and outputs that would be used in the compilation of a project
// ensures that all paths are files
// ensures no missing inputs
- public static CompilerIO GetCompileIO(
- ProjectContext project,
- string buildConfiguration,
- string buildBasePath,
- string outputPath,
- ProjectDependenciesFacade dependencies)
+ public static CompilerIO GetCompileIO(ProjectContext project, string buildConfiguration, string buildBasePath, string outputPath, ProjectDependenciesFacade dependencies, bool isRootProject)
{
var compilerIO = new CompilerIO(new List(), new List());
var calculator = project.GetOutputPaths(buildConfiguration, buildBasePath, outputPath);
@@ -462,7 +457,7 @@ namespace Microsoft.DotNet.Tools.Build
AddDependencies(dependencies, compilerIO);
var allOutputPath = new List(calculator.CompilationFiles.All());
- if (project.ProjectFile.HasRuntimeOutput(buildConfiguration))
+ if (isRootProject && project.ProjectFile.HasRuntimeOutput(buildConfiguration))
{
allOutputPath.AddRange(calculator.RuntimeFiles.All());
}
diff --git a/test/dotnet-build.Tests/IncrementalTestBase.cs b/test/dotnet-build.Tests/IncrementalTestBase.cs
index e3450ad3f..0b5c3f72a 100644
--- a/test/dotnet-build.Tests/IncrementalTestBase.cs
+++ b/test/dotnet-build.Tests/IncrementalTestBase.cs
@@ -16,15 +16,16 @@ namespace Microsoft.DotNet.Tools.Builder.Tests
protected readonly string MainProject;
protected readonly string ExpectedOutput;
+ protected readonly TempDirectory Root;
public IncrementalTestBase(string testProjectsRoot, string mainProject, string expectedOutput)
{
MainProject = mainProject;
ExpectedOutput = expectedOutput;
- var root = Temp.CreateDirectory();
+ Root = Temp.CreateDirectory();
- TempProjectRoot = root.CopyDirectory(testProjectsRoot);
+ TempProjectRoot = Root.CopyDirectory(testProjectsRoot);
}
protected void TouchSourcesOfProject()
diff --git a/test/dotnet-build.Tests/IncrementalTestsTransitiveRuntime.cs b/test/dotnet-build.Tests/IncrementalTestsTransitiveRuntime.cs
new file mode 100644
index 000000000..fed114ca5
--- /dev/null
+++ b/test/dotnet-build.Tests/IncrementalTestsTransitiveRuntime.cs
@@ -0,0 +1,44 @@
+// Copyright (c) .NET Foundation and contributors. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+
+using System;
+using System.IO;
+using Microsoft.DotNet.Tools.Test.Utilities;
+using Xunit;
+
+namespace Microsoft.DotNet.Tools.Builder.Tests
+{
+ public class IncrementalTestsTransitiveRuntime : IncrementalTestBase
+ {
+ private const string TestLibraryWithAppDependency = "TestLibraryWithAppDependency";
+ private const string LibraryProject = "TestLibrary";
+ private const string AppProject = "TestApp";
+
+ public IncrementalTestsTransitiveRuntime() : base(
+ Path.Combine(AppContext.BaseDirectory, "TestAssets", "TestProjects", "TestAppWithTransitiveAppDependency"),
+ "TestAppWithTransitiveAppDependency",
+ "This string came from the test library!" + Environment.NewLine)
+ {
+ Root.CopyDirectory(Path.Combine(AppContext.BaseDirectory, "TestAssets", "TestProjects", LibraryProject));
+ Root.CopyDirectory(Path.Combine(AppContext.BaseDirectory, "TestAssets", "TestProjects", AppProject));
+ Root.CopyDirectory(Path.Combine(AppContext.BaseDirectory, "TestAssets", "TestProjects", TestLibraryWithAppDependency));
+ }
+
+ [Fact]
+ public void TestSkipsRebuildWithTransitiveExeDependency()
+ {
+ var buildResult = BuildProject();
+ buildResult.Should().HaveCompiledProject(MainProject);
+ buildResult.Should().HaveCompiledProject(TestLibraryWithAppDependency);
+ buildResult.Should().HaveCompiledProject(AppProject);
+ buildResult.Should().HaveCompiledProject(LibraryProject);
+
+ buildResult = BuildProject();
+
+ buildResult.Should().HaveSkippedProjectCompilation(MainProject);
+ buildResult.Should().HaveSkippedProjectCompilation(TestLibraryWithAppDependency);
+ buildResult.Should().HaveSkippedProjectCompilation(AppProject);
+ buildResult.Should().HaveSkippedProjectCompilation(LibraryProject);
+ }
+ }
+}
\ No newline at end of file
diff --git a/test/dotnet-build.Tests/project.json b/test/dotnet-build.Tests/project.json
index 4c4a6f085..dfa6696dc 100644
--- a/test/dotnet-build.Tests/project.json
+++ b/test/dotnet-build.Tests/project.json
@@ -27,6 +27,8 @@
"../../TestAssets/TestProjects/TestProjectToProjectDependencies/**/*",
"../../TestAssets/TestProjects/TestProjectWithCultureSpecificResource/**/*",
"../../TestAssets/TestProjects/TestProjectWithResource/**/*",
+ "../../TestAssets/TestProjects/TestLibraryWithAppDependency/**/*",
+ "../../TestAssets/TestProjects/TestAppWithTransitiveAppDependency/**/*",
"../../TestAssets/TestProjects/global.json"
],