Skip to content

Conversation

@kzu
Copy link
Member

@kzu kzu commented Mar 2, 2023

Consider the scenario where we include multiple files from a relative path that's outside the project directory:

<PackageFile Include="..\..\docs\**\*.*" PackagePath="docs\" />

In this case, the natural expectation is that starting from the wildcard, the paths are reconstructed under the specified target package path, just as if we had added %(RecursiveDir)%(Filename)%(Extension) at the end of the docs\ expression.

We don't do that right now, just appending a relative path that is invalid since it goes outside the package root scope (we add the full ..\..\ as part of concatenating the RelativeDir, which includes that).

Granted, this can be worked-around by just constructing the right package path via MSBuild or setting a Link property, but it should Just Work OOB.

This commit adds that support, including the (tricky) scenario where RecursiveDir isn't populated at all, as in the case of a file under ....\docs\foo.txt above (since the ** won't have matched any subdirs, it will be empty). So we need to detect the scenario by reading the actual wildcard include, if any.

@kzu kzu added the enhancement New feature or request label Mar 2, 2023
Consider the scenario where we include multiple files from a relative path that's outside the project directory:

    <PackageFile Include="..\..\docs\**\*.*" PackagePath="docs\" />

In this case, the natural expectation is that starting from the wildcard, the paths are reconstructed under the specified target package path, just as if we had added %(RecursiveDir)%(Filename)%(Extension) at the end of the `docs\` expression.

We don't do that right now, just appending a relative path that is invalid since it goes outside the package root scope (we add the full `..\..\` as part of concatenating the `RelativeDir`, which includes that).

Granted, this can be worked-around by just constructing the right package path via MSBuild or setting a Link property, but it should Just Work OOB.

This commit adds that support, including the (tricky) scenario where RecursiveDir isn't populated at all, as in the case of a file under ..\..\docs\foo.txt above (since the ** won't have matched any subdirs, it will be empty). So we need to detect the scenario by reading the actual wildcard include, if any.
@kzu kzu force-pushed the dev/RecursiveDirPath branch from a6d5d88 to 3b956d4 Compare March 2, 2023 14:37
@kzu kzu enabled auto-merge (rebase) March 2, 2023 14:37
@kzu kzu merged commit 48b6872 into main Mar 2, 2023
@kzu kzu deleted the dev/RecursiveDirPath branch March 2, 2023 14:54
@devlooped devlooped locked and limited conversation to collaborators Nov 23, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants