Skip to content

Conversation

@jrdodds
Copy link
Contributor

@jrdodds jrdodds commented Jun 6, 2023

Fixes #5881

Context

Implementation of proposed ITaskItem[] SourceFolders parameter.

Changes Made

Within Copy.cs:

  • Added ITaskItem[] SourceFolders parameter
  • Modified ValidateInputs() to support the new parameter
  • Modified InitializeDestinationFiles()
    • Previously this method iterated SourceFiles to create DestinationFiles items given the DestinationFolder.
    • The Copy task actually only operates on SourceFiles and DestinationFiles.
    • Extended the method to:
      • Use FileMatcher::GetFiles() for each directory in SourceFolders
      • Create items in both SourceFiles and DestinationFiles for each file found

Added additional unit tests in Copy_Tests.cs.

Added new error MSB3894 Copy.IncompatibleParameters for the case where SourceFolders and DestinationFiles are both present. This is very close to the existing MSB3022 Copy.ExactlyOneTypeOfDestination but it seemed prudent not to re-use MSB3022.

Testing

Tested on Windows 11 and macOS 12

Ran full suite of unit tests from the command line

Ran some sample project files

Notes

This implementation conforms to the proposed design with the exception that it does not copy empty directories.

This implementation leverages the existing FileMatcher::GetFiles() which recurses the directory tree using multiple threads. GetFiles() returns a list of files. Empty directories are not identified.

The use of FileMatcher could be replaced. The Copy task could implement its own support for recursing a directory tree. The wildcard matching logic in FileMatcher is not relevant for the Copy task.

@AR-May AR-May self-assigned this Jun 6, 2023
@jrdodds
Copy link
Contributor Author

jrdodds commented Jun 6, 2023

Can the build be re-run? Or is it necessary to push a new commit?

Update: Pushed a new commit to address a TODO.

The question remains. When the PR build fails for causes in the build infrastructure and not the repo, is there a way to re-run the build or request that the build be re-run?

In the backing Azure Pipelines, I can only view. In the GitHub desktop client, there is a "Re-run Checks" button. Clicking the button for the dotnet/msbuild repo does nothing.

@AR-May
Copy link
Member

AR-May commented Jun 8, 2023

Can the build be re-run? Or is it necessary to push a new commit?

You can write "/azp run" in the comment to the PR to re-run checks.

@azure-pipelines
Copy link

Commenter does not have sufficient privileges for PR 8843 in repo dotnet/msbuild

@rainersigwald
Copy link
Member

Yeah, only committers have permission for /azp run--and committers should use the finer-grained rerun capabilities in AzDO or GitHub to rerun only failed jobs that failed for known, tracked-by-bugs issues.

@rainersigwald rainersigwald added this to the VS 17.8 milestone Jun 22, 2023
@AR-May AR-May merged commit 909ca6b into dotnet:main Dec 14, 2023
@KirillOsenkov
Copy link
Member

Is the new capability documented anywhere? I’d like to see a couple of examples.

@AR-May
Copy link
Member

AR-May commented Dec 14, 2023

Feature is fully described in the issue with feature request:
#5881 (comment)
But it would be good idea to add documentation about it somewhere else too.

@KirillOsenkov
Copy link
Member

does the description in the issue match the actual implementation? I’m afraid documenting a feature in an issue is insufficient. Ideally if there’s existing documentation for the Copy task, we should augment that.

@AR-May
Copy link
Member

AR-May commented Dec 14, 2023

Yes, I agree, documenting in an issue is insufficient, we should add this to https://learn.microsoft.com/en-us/visualstudio/msbuild/copy-task.
Yes, the implementation matches the suggested design.

@jrdodds jrdodds deleted the CopyTask-SourceFolders branch December 15, 2023 13:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Copy task should support copying a directory easily

5 participants