Last active
March 23, 2022 00:44
-
-
Save robatwilliams/6512233 to your computer and use it in GitHub Desktop.
Get the names of directories under a specified directory in MSBuild
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<PropertyGroup> | |
<ParentDir>$(MSBuildProjectDirectory)\some\folder</ParentDir><!-- This folder has subfolders folders a, b, c--> | |
</PropertyGroup> | |
<Target> | |
<ItemGroup> | |
<SubfolderFullPaths Include="$([System.IO.Directory]::GetDirectories('$(ParentDir)'))" /> | |
<SubfolderNames Include="@(SubfolderFullPaths->'$([System.IO.Path]::GetFileName('%(SubfolderFullPaths.Identity)'))')" /> | |
</ItemGroup> | |
<!-- SubfolderNames now has 3 items, with their Identity metadata "a", "b", "c" --> | |
<!-- If you want to use the well-known item metadata to define further metadata, | |
it seems you have to us the above as an intermediate step: --> | |
<SubfolderNames2 Include="$(SubfolderNames)" > | |
<!-- Identity refers to that of the Included items, so can't do this in SubfolderNames directly --> | |
<OutputDir>%(Identity)</OutputDir> | |
</SubfolderNames2> | |
</Target> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment