public void RecursiveWildcards() { DirectoryInfo source = CreateFiles( "source", "foo.txt", "foo.exe", "foo.exe.config", "foo.dll", "foo.pdb", "foo.xml", "foo.cs", "foo.ini", "bar.dll", "bar.pdb", "bar.xml", "bar.cs", Path.Combine("baz", "baz.dll")); DirectoryInfo destination = new DirectoryInfo(Path.Combine(TestRootPath, "destination")); BuildEngine buildEngine = BuildEngine.Create(); Robocopy copyArtifacts = new Robocopy { BuildEngine = buildEngine, Sources = new ITaskItem[] { new MockTaskItem(source.FullName) { ["DestinationFolder"] = destination.FullName, ["FileMatch"] = "*exe *dll *exe.config", }, }, Sleep = duration => { }, }; copyArtifacts.Execute().ShouldBeTrue(buildEngine.GetConsoleLog()); destination.GetFiles("*", SearchOption.AllDirectories) .Select(i => i.FullName) .ShouldBe( new[] { "bar.dll", "foo.dll", "foo.exe", "foo.exe.config", Path.Combine("baz", "baz.dll"), }.Select(i => Path.Combine(destination.FullName, i)), ignoreOrder: true); }
public void NonRecursiveWildcards() { DirectoryInfo source = CreateFiles( "source", @"foo.txt", @"foo.ini", @"bar.txt", @"bar\bar.pdb", @"bar\bar.txt", @"bar.cs", @"baz\baz.dll", @"baz\baz.txt"); DirectoryInfo destination = new DirectoryInfo(Path.Combine(TestRootPath, "destination")); BuildEngine buildEngine = BuildEngine.Create(); Robocopy copyArtifacts = new Robocopy { BuildEngine = buildEngine, Sources = new ITaskItem[] { new MockTaskItem(source.FullName) { ["DestinationFolder"] = destination.FullName, ["FileMatch"] = "*txt", [nameof(RobocopyMetadata.IsRecursive)] = "false" } }, Sleep = duration => { } }; copyArtifacts.Execute().ShouldBeTrue(buildEngine.GetConsoleLog()); destination.GetFiles("*", SearchOption.AllDirectories) .Select(i => i.FullName) .ShouldBe(new[] { "bar.txt", "foo.txt", }.Select(i => Path.Combine(destination.FullName, i))); }