abort build when an unresolved dependency is found (#2696)
This commit is contained in:
parent
f8300f8747
commit
b98bc1289d
13 changed files with 122 additions and 8 deletions
|
@ -0,0 +1,12 @@
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace ConsoleApplication
|
||||||
|
{
|
||||||
|
public class Program
|
||||||
|
{
|
||||||
|
public static void Main(string[] args)
|
||||||
|
{
|
||||||
|
Console.WriteLine("Hello World!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,18 @@
|
||||||
|
{
|
||||||
|
"version": "1.0.0-*",
|
||||||
|
"compilationOptions": {
|
||||||
|
"emitEntryPoint": true
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"Microsoft.NETCore.App": {
|
||||||
|
"type": "platform",
|
||||||
|
"version": "1.0.0-rc2-*"
|
||||||
|
},
|
||||||
|
"ThisIsNotARealDependencyAndIfSomeoneGoesAndAddsAProjectWithThisNameIWillFindThemAndPunishThem": { "target": "project" }
|
||||||
|
},
|
||||||
|
"frameworks": {
|
||||||
|
"netcoreapp1.0": {
|
||||||
|
"imports": "dnxcore50"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,12 @@
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace ConsoleApplication
|
||||||
|
{
|
||||||
|
public class Program
|
||||||
|
{
|
||||||
|
public static void Main(string[] args)
|
||||||
|
{
|
||||||
|
Console.WriteLine("Hello World!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,18 @@
|
||||||
|
{
|
||||||
|
"version": "1.0.0-*",
|
||||||
|
"compilationOptions": {
|
||||||
|
"emitEntryPoint": true
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"Microsoft.NETCore.App": {
|
||||||
|
"type": "platform",
|
||||||
|
"version": "1.0.0-rc2-3002498"
|
||||||
|
},
|
||||||
|
"LibraryWithBuildDependency": { "target": "project" }
|
||||||
|
},
|
||||||
|
"frameworks": {
|
||||||
|
"netcoreapp1.0": {
|
||||||
|
"imports": "dnxcore50"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,12 @@
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace ConsoleApplication
|
||||||
|
{
|
||||||
|
public class Program
|
||||||
|
{
|
||||||
|
public static void Main(string[] args)
|
||||||
|
{
|
||||||
|
Console.WriteLine("Hello World!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,18 @@
|
||||||
|
{
|
||||||
|
"version": "1.0.0-*",
|
||||||
|
"dependencies": {
|
||||||
|
"Microsoft.NETCore.App": {
|
||||||
|
"type": "platform",
|
||||||
|
"version": "1.0.0-rc2-3002498"
|
||||||
|
},
|
||||||
|
"Microsoft.Net.Compilers": {
|
||||||
|
"type": "build",
|
||||||
|
"version": "1.1.1"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"frameworks": {
|
||||||
|
"netcoreapp1.0": {
|
||||||
|
"imports": "dnxcore50"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -19,6 +19,7 @@ namespace Microsoft.DotNet.TestFramework
|
||||||
|
|
||||||
internal TestInstance(string testAssetRoot, string testDestination)
|
internal TestInstance(string testAssetRoot, string testDestination)
|
||||||
{
|
{
|
||||||
|
Console.WriteLine($"Copying {testAssetRoot} to {testDestination}");
|
||||||
if (string.IsNullOrEmpty(testAssetRoot))
|
if (string.IsNullOrEmpty(testAssetRoot))
|
||||||
{
|
{
|
||||||
throw new ArgumentException("testScenario");
|
throw new ArgumentException("testScenario");
|
||||||
|
|
|
@ -137,8 +137,11 @@ namespace Microsoft.DotNet.Tools.Build
|
||||||
|
|
||||||
var success = managedCompiler.Compile(projectNode.ProjectContext, _args);
|
var success = managedCompiler.Compile(projectNode.ProjectContext, _args);
|
||||||
if (projectNode.IsRoot)
|
if (projectNode.IsRoot)
|
||||||
|
{
|
||||||
|
if (success)
|
||||||
{
|
{
|
||||||
MakeRunnable(projectNode);
|
MakeRunnable(projectNode);
|
||||||
|
}
|
||||||
PrintSummary(projectNode, success);
|
PrintSummary(projectNode, success);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,7 @@ namespace Microsoft.DotNet.Tools.Build
|
||||||
LibraryDescription libraryDescription;
|
LibraryDescription libraryDescription;
|
||||||
if (lookup.TryGetValue(dependency.Name, out libraryDescription))
|
if (lookup.TryGetValue(dependency.Name, out libraryDescription))
|
||||||
{
|
{
|
||||||
if (libraryDescription.Identity.Type.Equals(LibraryType.Project))
|
if (libraryDescription.Resolved && libraryDescription.Identity.Type.Equals(LibraryType.Project))
|
||||||
{
|
{
|
||||||
deps.Add(TraverseProject((ProjectDescription)libraryDescription, lookup));
|
deps.Add(TraverseProject((ProjectDescription)libraryDescription, lookup));
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,11 +63,10 @@ namespace Microsoft.DotNet.Tools.Compiler
|
||||||
diagnostics.Add(diag);
|
diagnostics.Add(diag);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (missingFrameworkDiagnostics.Count > 0)
|
if(diagnostics.Any(d => d.Severity == DiagnosticMessageSeverity.Error))
|
||||||
{
|
{
|
||||||
// The framework isn't installed so we should short circuit the rest of the compilation
|
// We got an unresolved dependency or missing framework. Don't continue the compilation.
|
||||||
// so we don't get flooded with errors
|
PrintSummary(diagnostics, sw);
|
||||||
PrintSummary(missingFrameworkDiagnostics, sw);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -214,6 +214,27 @@ namespace Microsoft.DotNet.Tools.Builder.Tests
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void UnresolvedReferenceCausesBuildToFailAndNotProduceOutput()
|
||||||
|
{
|
||||||
|
var testAssetsManager = GetTestGroupTestAssetsManager("NonRestoredTestProjects");
|
||||||
|
var testInstance = testAssetsManager.CreateTestInstance("TestProjectWithUnresolvedDependency")
|
||||||
|
.WithLockFiles();
|
||||||
|
|
||||||
|
var restoreResult = new RestoreCommand() { WorkingDirectory = testInstance.TestRoot }.Execute();
|
||||||
|
restoreResult.Should().Fail();
|
||||||
|
new DirectoryInfo(testInstance.TestRoot).Should().HaveFile("project.lock.json");
|
||||||
|
|
||||||
|
var buildCmd = new BuildCommand(testInstance.TestRoot);
|
||||||
|
var buildResult = buildCmd.ExecuteWithCapturedOutput();
|
||||||
|
buildResult.Should().Fail();
|
||||||
|
|
||||||
|
buildResult.StdErr.Should().Contain("The dependency ThisIsNotARealDependencyAndIfSomeoneGoesAndAddsAProjectWithThisNameIWillFindThemAndPunishThem could not be resolved.");
|
||||||
|
|
||||||
|
var outputDir = new DirectoryInfo(Path.Combine(testInstance.TestRoot, "bin", "Debug", "netcoreapp1.0"));
|
||||||
|
outputDir.GetFiles().Length.Should().Be(0);
|
||||||
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void PackageReferenceWithResourcesTest()
|
public void PackageReferenceWithResourcesTest()
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue