From 15742b6387f5c7f5369fad755150772d8a453e00 Mon Sep 17 00:00:00 2001 From: Daniel Plaisted Date: Mon, 11 May 2020 17:25:59 -0700 Subject: [PATCH] Add logging for assets file contents if assertion fails --- .../GivenThatIWantToRestoreApp.cs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/Tests/dotnet-restore.Tests/GivenThatIWantToRestoreApp.cs b/src/Tests/dotnet-restore.Tests/GivenThatIWantToRestoreApp.cs index 56c922ee6df3..57b6b41473db 100644 --- a/src/Tests/dotnet-restore.Tests/GivenThatIWantToRestoreApp.cs +++ b/src/Tests/dotnet-restore.Tests/GivenThatIWantToRestoreApp.cs @@ -77,8 +77,21 @@ public void ItRestoresLibToSpecificDirectory(bool useStaticGraphEvaluation) .Pass() .And.NotHaveStdErr(); + var dllCount = 0; + + if (Directory.Exists(fullPath)) + { + dllCount = Directory.EnumerateFiles(fullPath, "*.dll", SearchOption.AllDirectories).Count(); + } + + if (dllCount == 0) + { + Log.WriteLine("Assets file contents:"); + Log.WriteLine(File.ReadAllText(Path.Combine(rootPath, "obj", "project.assets.json"))); + } + Directory.Exists(fullPath).Should().BeTrue(); - Directory.EnumerateFiles(fullPath, "*.dll", SearchOption.AllDirectories).Count().Should().BeGreaterThan(0); + dllCount.Should().BeGreaterThan(0); } [Theory]