Merge pull request #2721 from dotnet/pakry/no-deps-yes-deps

Fix --no-dependencies incremental check regression
This commit is contained in:
Pavel Krymets 2016-04-28 08:43:59 -07:00
commit f8300f8747
5 changed files with 50 additions and 8 deletions

View file

@ -74,6 +74,14 @@ namespace Microsoft.DotNet.Tools.Build
allOutputPath.Add(path);
}
}
foreach (var dependency in graphNode.Dependencies)
{
var outputFiles = dependency.ProjectContext
.GetOutputPaths(_configuration, _buildBasePath, _outputPath)
.CompilationFiles;
inputs.Add(outputFiles.Assembly);
}
// output: compiler outputs
foreach (var path in allOutputPath)

View file

@ -23,7 +23,7 @@ namespace Microsoft.DotNet.Tools.Build
private readonly DotNetCommandFactory _commandFactory;
private readonly IncrementalManager _incrementalManager;
public DotNetProjectBuilder(BuildCommandApp args)
public DotNetProjectBuilder(BuildCommandApp args): base(args.ShouldSkipDependencies)
{
_args = args;

View file

@ -12,6 +12,13 @@ namespace Microsoft.DotNet.Tools.Build
{
internal abstract class ProjectBuilder
{
private readonly bool _skipDependencies;
public ProjectBuilder(bool skipDependencies)
{
_skipDependencies = skipDependencies;
}
private Dictionary<ProjectContextIdentity, CompilationResult> _compilationResults = new Dictionary<ProjectContextIdentity, CompilationResult>();
public IEnumerable<CompilationResult> Build(IEnumerable<ProjectGraphNode> roots)
@ -40,6 +47,7 @@ namespace Microsoft.DotNet.Tools.Build
protected virtual void ProjectSkiped(ProjectGraphNode projectNode)
{
}
protected abstract CompilationResult RunCompile(ProjectGraphNode projectNode);
private CompilationResult Build(ProjectGraphNode projectNode)
@ -57,6 +65,8 @@ namespace Microsoft.DotNet.Tools.Build
}
private CompilationResult CompileWithDependencies(ProjectGraphNode projectNode)
{
if (!_skipDependencies)
{
foreach (var dependency in projectNode.Dependencies)
{
@ -66,6 +76,7 @@ namespace Microsoft.DotNet.Tools.Build
return CompilationResult.Failure;
}
}
}
var context = projectNode.ProjectContext;
if (!HasSourceFiles(context))

View file

@ -36,8 +36,9 @@ namespace Microsoft.DotNet.Tools.Build
private ProjectGraphNode TraverseProject(ProjectDescription project, IDictionary<string, LibraryDescription> lookup, ProjectContext context = null)
{
var isRoot = context != null;
var deps = new List<ProjectGraphNode>();
if (_collectDependencies)
if (isRoot || _collectDependencies)
{
foreach (var dependency in project.Dependencies)
{
@ -55,8 +56,9 @@ namespace Microsoft.DotNet.Tools.Build
}
}
}
var task = context != null ? Task.FromResult(context) : Task.Run(() => _projectContextFactory(project.Path, project.Framework));
return new ProjectGraphNode(task, deps, context != null);
return new ProjectGraphNode(task, deps, isRoot);
}
private IEnumerable<ProjectGraphNode> TraverseNonProject(LibraryDescription root, IDictionary<string, LibraryDescription> lookup)

View file

@ -86,6 +86,27 @@ namespace Microsoft.DotNet.Tools.Builder.Tests
AssertResultDoesNotContainStrings(result3, dependencies);
}
[Fact]
public void TestNoDependenciesDependencyRebuild()
{
var testInstance = TestAssetsManager.CreateTestInstance("TestProjectToProjectDependencies")
.WithLockFiles()
.WithBuildArtifacts();
TestProjectRoot = testInstance.TestRoot;
// modify the source code of a leaf dependency
TouchSourcesOfProject("L11");
// second build with no dependencies, rebuilding leaf
var result2 = new BuildCommand(GetProjectDirectory("L11"), noDependencies: true, framework: DefaultLibraryFramework).ExecuteWithCapturedOutput();
result2.Should().HaveStdOutMatching("Compiling.*L11.*");
// third build with no dependencies but incremental; root project should rebuild
var result3 = BuildProject(noDependencies: true);
result3.Should().HaveCompiledProject("L0", _appFrameworkFullName);
}
private static void AssertResultDoesNotContainStrings(CommandResult commandResult, string[] strings)
{
foreach (var s in strings)