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)
|
||||
{
|
||||
Console.WriteLine($"Copying {testAssetRoot} to {testDestination}");
|
||||
if (string.IsNullOrEmpty(testAssetRoot))
|
||||
{
|
||||
throw new ArgumentException("testScenario");
|
||||
|
|
|
@ -138,7 +138,10 @@ namespace Microsoft.DotNet.Tools.Build
|
|||
var success = managedCompiler.Compile(projectNode.ProjectContext, _args);
|
||||
if (projectNode.IsRoot)
|
||||
{
|
||||
MakeRunnable(projectNode);
|
||||
if (success)
|
||||
{
|
||||
MakeRunnable(projectNode);
|
||||
}
|
||||
PrintSummary(projectNode, success);
|
||||
}
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ namespace Microsoft.DotNet.Tools.Build
|
|||
LibraryDescription 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));
|
||||
}
|
||||
|
|
|
@ -63,11 +63,10 @@ namespace Microsoft.DotNet.Tools.Compiler
|
|||
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
|
||||
// so we don't get flooded with errors
|
||||
PrintSummary(missingFrameworkDiagnostics, sw);
|
||||
// We got an unresolved dependency or missing framework. Don't continue the compilation.
|
||||
PrintSummary(diagnostics, sw);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -66,12 +66,12 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
|
|||
return s_testsAssetsMgr;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected static TestAssetsManager GetTestGroupTestAssetsManager(string testGroup)
|
||||
{
|
||||
string assetsRoot = Path.Combine(RepoRoot, "TestAssets", testGroup);
|
||||
var testAssetsMgr = new TestAssetsManager(assetsRoot);
|
||||
|
||||
|
||||
return testAssetsMgr;
|
||||
}
|
||||
|
||||
|
|
|
@ -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]
|
||||
public void PackageReferenceWithResourcesTest()
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue