diff --git a/TestAssets/TestProjects/AppWithAppDependency/TestApp1/Program.cs b/TestAssets/TestProjects/AppWithAppDependency/TestApp1/Program.cs new file mode 100644 index 000000000..51233cffa --- /dev/null +++ b/TestAssets/TestProjects/AppWithAppDependency/TestApp1/Program.cs @@ -0,0 +1,12 @@ +using System; + +namespace ConsoleApplication +{ + public class Program + { + public static void Main(string[] args) + { + Console.WriteLine("Hello World!"); + } + } +} diff --git a/TestAssets/TestProjects/AppWithAppDependency/TestApp1/project.json b/TestAssets/TestProjects/AppWithAppDependency/TestApp1/project.json new file mode 100644 index 000000000..3f0ab3af7 --- /dev/null +++ b/TestAssets/TestProjects/AppWithAppDependency/TestApp1/project.json @@ -0,0 +1,18 @@ +{ + "buildOptions": { + "emitEntryPoint": true + }, + "dependencies": { + "TestApp2": { "target": "project" } + }, + "frameworks": { + "netcoreapp1.0": { + "dependencies": { + "Microsoft.NETCore.App": { + "type": "platform", + "version": "1.0.0-rc3-*" + } + } + } + } +} diff --git a/TestAssets/TestProjects/AppWithAppDependency/TestApp2/Program.cs b/TestAssets/TestProjects/AppWithAppDependency/TestApp2/Program.cs new file mode 100644 index 000000000..51233cffa --- /dev/null +++ b/TestAssets/TestProjects/AppWithAppDependency/TestApp2/Program.cs @@ -0,0 +1,12 @@ +using System; + +namespace ConsoleApplication +{ + public class Program + { + public static void Main(string[] args) + { + Console.WriteLine("Hello World!"); + } + } +} diff --git a/TestAssets/TestProjects/AppWithAppDependency/TestApp2/project.json b/TestAssets/TestProjects/AppWithAppDependency/TestApp2/project.json new file mode 100644 index 000000000..0e34cfa33 --- /dev/null +++ b/TestAssets/TestProjects/AppWithAppDependency/TestApp2/project.json @@ -0,0 +1,16 @@ +{ + "buildOptions": { + "emitEntryPoint": true + }, + "dependencies": {}, + "frameworks": { + "netcoreapp1.0": { + "dependencies": { + "Microsoft.NETCore.App": { + "type": "platform", + "version": "1.0.0-rc3-*" + } + } + } + } +} diff --git a/TestAssets/TestProjects/AppWithAppDependency/global.json b/TestAssets/TestProjects/AppWithAppDependency/global.json new file mode 100644 index 000000000..9e26dfeeb --- /dev/null +++ b/TestAssets/TestProjects/AppWithAppDependency/global.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-build/DotnetProjectBuilder.cs b/src/dotnet/commands/dotnet-build/DotnetProjectBuilder.cs index 9333c15a6..91cc77f05 100644 --- a/src/dotnet/commands/dotnet-build/DotnetProjectBuilder.cs +++ b/src/dotnet/commands/dotnet-build/DotnetProjectBuilder.cs @@ -133,6 +133,26 @@ namespace Microsoft.DotNet.Tools.Build } } + protected override CompilationResult Build(ProjectGraphNode projectNode) + { + var result = base.Build(projectNode); + AfterRootBuild(projectNode, result); + return result; + } + + protected void AfterRootBuild(ProjectGraphNode projectNode, CompilationResult result) + { + if (result != CompilationResult.IncrementalSkip && projectNode.IsRoot) + { + var success = result == CompilationResult.Success; + if (success) + { + MakeRunnable(projectNode); + } + PrintSummary(projectNode, success); + } + } + protected override CompilationResult RunCompile(ProjectGraphNode projectNode) { try @@ -140,15 +160,6 @@ namespace Microsoft.DotNet.Tools.Build var managedCompiler = new ManagedCompiler(_scriptRunner, _commandFactory); var success = managedCompiler.Compile(projectNode.ProjectContext, _args); - if (projectNode.IsRoot) - { - if (success) - { - MakeRunnable(projectNode); - } - PrintSummary(projectNode, success); - } - return success ? CompilationResult.Success : CompilationResult.Failure; } finally diff --git a/src/dotnet/commands/dotnet-build/ProjectBuilder.cs b/src/dotnet/commands/dotnet-build/ProjectBuilder.cs index 4118fb0f7..fe9d20864 100644 --- a/src/dotnet/commands/dotnet-build/ProjectBuilder.cs +++ b/src/dotnet/commands/dotnet-build/ProjectBuilder.cs @@ -55,7 +55,7 @@ namespace Microsoft.DotNet.Tools.Build protected abstract CompilationResult RunCompile(ProjectGraphNode projectNode); - private CompilationResult Build(ProjectGraphNode projectNode) + protected virtual CompilationResult Build(ProjectGraphNode projectNode) { CompilationResult result; if (_compilationResults.TryGetValue(projectNode.ProjectContext.Identity, out result)) diff --git a/test/dotnet-build.Tests/BuildOutputTests.cs b/test/dotnet-build.Tests/BuildOutputTests.cs index bfdddd4de..d426a6173 100644 --- a/test/dotnet-build.Tests/BuildOutputTests.cs +++ b/test/dotnet-build.Tests/BuildOutputTests.cs @@ -176,6 +176,25 @@ namespace Microsoft.DotNet.Tools.Builder.Tests informationalVersion.Should().BeEquivalentTo("1.0.0-85"); } + [Fact] + public void BuildGlobbingMakesAllRunnable() + { + var testInstance = TestAssetsManager.CreateTestInstance("AppWithAppDependency") + .WithLockFiles(); + + var cmd = new BuildCommand(string.Format("*{0}project.json", Path.DirectorySeparatorChar), skipLoadProject: true) + .WithWorkingDirectory(testInstance.TestRoot) + .Execute() + .Should() + .Pass(); + + foreach (var project in new [] { "TestApp1", "TestApp2" }) + { + new DirectoryInfo(Path.Combine(testInstance.TestRoot, project, "bin", "Debug", DefaultFramework)) + .Should().HaveFile($"{project}.deps.json"); + } + } + [Theory] // [InlineData("net20", false, true)] // [InlineData("net40", true, true)]