From 098c83c05e95758b0bb5f27db9c3205772f02302 Mon Sep 17 00:00:00 2001 From: Matthieu MEZIL Date: Mon, 10 Oct 2022 14:20:59 -0700 Subject: [PATCH 1/5] There was a bad copy/paste using ItemSpec instead of destination when destination folder was invalid. --- src/Artifacts.UnitTests/ArtifactsTests.cs | 34 +++++++++++++++++++++++ src/Artifacts/Tasks/RobocopyMetadata.cs | 2 +- 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/src/Artifacts.UnitTests/ArtifactsTests.cs b/src/Artifacts.UnitTests/ArtifactsTests.cs index 727b43c7..fb6f5d6f 100644 --- a/src/Artifacts.UnitTests/ArtifactsTests.cs +++ b/src/Artifacts.UnitTests/ArtifactsTests.cs @@ -224,5 +224,39 @@ public void UsingSdkLogic(bool appendTargetFrameworkToOutputPath) }.Select(i => Path.Combine(artifactsPath.FullName, i)), ignoreOrder: true); } + + + [Fact] + public void InvalidDestinationFolderShouldLogAnErrorRegardingDestinationFolder() + { + DirectoryInfo baseOutputPath = CreateFiles( + Path.Combine("bin", "Debug"), + "foo.exe", + "foo.pdb", + "foo.exe.config", + "bar.dll", + "bar.pdb", + "bar.cs"); + + CreateFiles( + Path.Combine(baseOutputPath.FullName, "ref"), + "bar.dll"); + + string artifactPathes = "Foo\"Bar"; + + string outputPath = $"{Path.Combine("bin", "Debug")}{Path.DirectorySeparatorChar}"; + + ProjectCreator.Templates.ProjectWithArtifacts( + outputPath: outputPath, + appendTargetFrameworkToOutputPath: false, + artifactsPath: artifactPathes) + .TryGetItems("Artifact", out IReadOnlyCollection _) + .TryGetPropertyValue("DefaultArtifactsSource", out string _) + .TryBuild(out bool result, out BuildOutput buildOutput); + + string consoleLog = buildOutput.GetConsoleLog(); + result.ShouldBeFalse(consoleLog); + Assert.Contains("Failed to expand the path \"Foo\"Bar\"", consoleLog); + } } } \ No newline at end of file diff --git a/src/Artifacts/Tasks/RobocopyMetadata.cs b/src/Artifacts/Tasks/RobocopyMetadata.cs index 4449f6b7..704e3dfb 100644 --- a/src/Artifacts/Tasks/RobocopyMetadata.cs +++ b/src/Artifacts/Tasks/RobocopyMetadata.cs @@ -112,7 +112,7 @@ public static bool TryParse(ITaskItem item, TaskLoggingHelper log, Func Date: Mon, 10 Oct 2022 15:37:08 -0700 Subject: [PATCH 2/5] Remove extraline. --- src/Artifacts.UnitTests/ArtifactsTests.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Artifacts.UnitTests/ArtifactsTests.cs b/src/Artifacts.UnitTests/ArtifactsTests.cs index fb6f5d6f..2c4253c1 100644 --- a/src/Artifacts.UnitTests/ArtifactsTests.cs +++ b/src/Artifacts.UnitTests/ArtifactsTests.cs @@ -225,7 +225,6 @@ public void UsingSdkLogic(bool appendTargetFrameworkToOutputPath) ignoreOrder: true); } - [Fact] public void InvalidDestinationFolderShouldLogAnErrorRegardingDestinationFolder() { From e75f16d0e72720dc03c8436e6e471407169b0d39 Mon Sep 17 00:00:00 2001 From: "Matthieu MEZIL (MSFT)" Date: Mon, 10 Oct 2022 15:39:50 -0700 Subject: [PATCH 3/5] Update src/Artifacts.UnitTests/ArtifactsTests.cs 89bbe9df438240ffb3d8e6fee9e2d3db115ea940 Co-authored-by: Jeff Kluge --- src/Artifacts.UnitTests/ArtifactsTests.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Artifacts.UnitTests/ArtifactsTests.cs b/src/Artifacts.UnitTests/ArtifactsTests.cs index f57dc72a..dcc3601c 100644 --- a/src/Artifacts.UnitTests/ArtifactsTests.cs +++ b/src/Artifacts.UnitTests/ArtifactsTests.cs @@ -279,7 +279,6 @@ public void UsingSdkLogic(bool appendTargetFrameworkToOutputPath) }.Select(i => Path.Combine(artifactsPath.FullName, i)), ignoreOrder: true); } - [Fact] public void InvalidDestinationFolderShouldLogAnErrorRegardingDestinationFolder() { From f7e82b32649bdb50c0cba009e58777db8077271d Mon Sep 17 00:00:00 2001 From: Matthieu MEZIL Date: Mon, 10 Oct 2022 16:12:17 -0700 Subject: [PATCH 4/5] Add back empty line --- src/Artifacts.UnitTests/ArtifactsTests.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Artifacts.UnitTests/ArtifactsTests.cs b/src/Artifacts.UnitTests/ArtifactsTests.cs index dcc3601c..f57dc72a 100644 --- a/src/Artifacts.UnitTests/ArtifactsTests.cs +++ b/src/Artifacts.UnitTests/ArtifactsTests.cs @@ -279,6 +279,7 @@ public void UsingSdkLogic(bool appendTargetFrameworkToOutputPath) }.Select(i => Path.Combine(artifactsPath.FullName, i)), ignoreOrder: true); } + [Fact] public void InvalidDestinationFolderShouldLogAnErrorRegardingDestinationFolder() { From f6ed768b93189ddcda6df46a4b2fc469d625123f Mon Sep 17 00:00:00 2001 From: Jeff Kluge Date: Tue, 11 Oct 2022 09:53:03 -0700 Subject: [PATCH 5/5] Fix unit test --- src/Artifacts.UnitTests/ArtifactsTests.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Artifacts.UnitTests/ArtifactsTests.cs b/src/Artifacts.UnitTests/ArtifactsTests.cs index f57dc72a..ad44bcbb 100644 --- a/src/Artifacts.UnitTests/ArtifactsTests.cs +++ b/src/Artifacts.UnitTests/ArtifactsTests.cs @@ -296,7 +296,7 @@ public void InvalidDestinationFolderShouldLogAnErrorRegardingDestinationFolder() Path.Combine(baseOutputPath.FullName, "ref"), "bar.dll"); - string artifactPathes = "Foo\"Bar"; + string artifactPathes = "Foo" + Path.DirectorySeparatorChar + new string(Path.GetInvalidPathChars().Where(i => !char.IsWhiteSpace(i)).ToArray()); string outputPath = $"{Path.Combine("bin", "Debug")}{Path.DirectorySeparatorChar}"; @@ -310,7 +310,7 @@ public void InvalidDestinationFolderShouldLogAnErrorRegardingDestinationFolder() string consoleLog = buildOutput.GetConsoleLog(); result.ShouldBeFalse(consoleLog); - Assert.Contains("Failed to expand the path \"Foo\"Bar\"", consoleLog); + Assert.Contains($"Failed to expand the path \"{artifactPathes}", consoleLog); } } } \ No newline at end of file