Merge pull request #3413 from sokket/cycle
Adding check for self-referencing projects
This commit is contained in:
commit
30ba1a1a61
6 changed files with 47 additions and 1 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,16 @@
|
||||||
|
{
|
||||||
|
"version": "1.0.0-*",
|
||||||
|
"buildOptions": {
|
||||||
|
"emitEntryPoint": true
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"TestProjectWithSelfReferencingDependency": {
|
||||||
|
"target": "project"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"frameworks": {
|
||||||
|
"netcoreapp1.0": {
|
||||||
|
"imports": "dnxcore50"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -43,7 +43,7 @@ namespace Microsoft.DotNet.Tools.Build
|
||||||
foreach (var dependency in project.Dependencies)
|
foreach (var dependency in project.Dependencies)
|
||||||
{
|
{
|
||||||
LibraryDescription libraryDescription;
|
LibraryDescription libraryDescription;
|
||||||
if (lookup.TryGetValue(dependency.Name, out libraryDescription))
|
if ((lookup.TryGetValue(dependency.Name, out libraryDescription)) && (!libraryDescription.Identity.Name.Equals(project.Identity.Name)))
|
||||||
{
|
{
|
||||||
if (libraryDescription.Resolved && libraryDescription.Identity.Type.Equals(LibraryType.Project))
|
if (libraryDescription.Resolved && libraryDescription.Identity.Type.Equals(LibraryType.Project))
|
||||||
{
|
{
|
||||||
|
|
|
@ -19,5 +19,11 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
|
||||||
|
|
||||||
return base.Execute(args);
|
return base.Execute(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override CommandResult ExecuteWithCapturedOutput(string args = "")
|
||||||
|
{
|
||||||
|
args = $"restore {args}";
|
||||||
|
return base.ExecuteWithCapturedOutput(args);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -351,6 +351,18 @@ namespace Microsoft.DotNet.Tools.Builder.Tests
|
||||||
buildResult.StdErr.Should().Contain("The project has not been restored or restore failed - run `dotnet restore`");
|
buildResult.StdErr.Should().Contain("The project has not been restored or restore failed - run `dotnet restore`");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
private void App_WithSelfReferencingDependency_FailsBuild()
|
||||||
|
{
|
||||||
|
var testAssetsManager = GetTestGroupTestAssetsManager("NonRestoredTestProjects");
|
||||||
|
var testInstance = testAssetsManager.CreateTestInstance("TestProjectWithSelfReferencingDependency")
|
||||||
|
.WithLockFiles();
|
||||||
|
|
||||||
|
var restoreResult = new RestoreCommand() { WorkingDirectory = testInstance.TestRoot }.ExecuteWithCapturedOutput();
|
||||||
|
restoreResult.Should().Fail();
|
||||||
|
restoreResult.StdOut.Should().Contain("error: Cycle detected");
|
||||||
|
}
|
||||||
|
|
||||||
private void CopyProjectToTempDir(string projectDir, TempDirectory tempDir)
|
private void CopyProjectToTempDir(string projectDir, TempDirectory tempDir)
|
||||||
{
|
{
|
||||||
// copy all the files to temp dir
|
// copy all the files to temp dir
|
||||||
|
|
Loading…
Reference in a new issue