Created
August 6, 2021 16:13
-
-
Save baronfel/e17db94545def8245aa1c4bf8251cd76 to your computer and use it in GitHub Desktop.
Targets to discover and set README and PackageIcon based on Item metadata
This file contains hidden or 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
<!-- | |
If no PackageReadmeFile is present and there's a _PackageFiles with the metadata node `PackageReadmeFile="true"` set, | |
use its resolved PackagePath as the `PackageReadmeFile` | |
eg. <None Include="../../README.md" Pack="true" PackagePath="\" PackageReadmeFile="true" /> | |
--> | |
<Target Name="_SetPackageReadmeFileByConvention" | |
DependsOnTargets="_GetPackageFiles" | |
BeforeTargets="GenerateNuspec" | |
Condition="'$(PackageReadmeFile)' == ''"> | |
<ItemGroup> | |
<DiscoveredReadmeFile Include="@(_PackageFiles)" Condition="'%(_PackageFiles.PackageReadmeFile)' == 'true'"> | |
<_PackagePath>%(_PackageFiles.PackagePath)</_PackagePath> | |
<_PackagePath Condition="'%(_PackageFiles.PackagePath)' == '/'"></_PackagePath> | |
</DiscoveredReadmeFile> | |
</ItemGroup> | |
<PropertyGroup Condition="'@(DiscoveredReadmeFile)' != ''"> | |
<PackageReadmeFile>%(DiscoveredReadmeFile._PackagePath)$([System.IO.Path]::GetFileName(%(DiscoveredReadmeFile.Identity)))</PackageReadmeFile> | |
</PropertyGroup> | |
</Target> | |
<!-- | |
If no PackageIcon is present and there's a _PackageFiles with the metadata node `PackageIcon="true"` set, | |
use its resolved PackagePath as the `PackageIcon` | |
eg. <None Include="logo.png" Pack="true" PackagePath="\" PackageIcon="true" /> | |
--> | |
<Target Name="_SetPackageIconByConvention" | |
DependsOnTargets="_GetPackageFiles" | |
BeforeTargets="GenerateNuspec" | |
Condition="'$(PackageIcon)' == ''"> | |
<ItemGroup> | |
<DiscoveredIcon Include="@(_PackageFiles)" Condition="'%(_PackageFiles.PackageIcon)' == 'true'"> | |
<_PackagePath>%(_PackageFiles.PackagePath)</_PackagePath> | |
<_PackagePath Condition="'%(_PackageFiles.PackagePath)' == '/'"></_PackagePath> | |
</DiscoveredIcon> | |
</ItemGroup> | |
<PropertyGroup Condition="'@(DiscoveredIcon)' != ''"> | |
<PackageIcon>%(DiscoveredIcon._PackagePath)$([System.IO.Path]::GetFileName(%(DiscoveredIcon.Identity)))</PackageIcon> | |
</PropertyGroup> | |
</Target> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment