|
1 | 1 | <?xml version="1.0" encoding="utf-8"?> |
2 | 2 | <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
3 | 3 |
|
4 | | - <Target Name="GenerateReleaseNotes" BeforeTargets="GenerateNuspec" Label="NuGet"> |
| 4 | + <PropertyGroup> |
| 5 | + <SourcePackageReadmeFile>$(MSBuildProjectDirectory)\README.md</SourcePackageReadmeFile> |
| 6 | + <TargetPackageReadmeFile>$(BaseIntermediateOutputPath)\README.md</TargetPackageReadmeFile> |
| 7 | + </PropertyGroup> |
| 8 | + |
| 9 | + <PropertyGroup> |
| 10 | + <TargetsForTfmSpecificContentInPackage>$(TargetsForTfmSpecificContentInPackage);IncludeNuGetReadme</TargetsForTfmSpecificContentInPackage> |
| 11 | + </PropertyGroup> |
| 12 | + |
| 13 | + <Target Name="IncludeNuGetReadme"> |
| 14 | + <ItemGroup> |
| 15 | + <TfmSpecificPackageFile Include="$(TargetPackageReadmeFile)" PackagePath="" /> |
| 16 | + </ItemGroup> |
| 17 | + </Target> |
| 18 | + |
| 19 | + <!-- |
| 20 | + reads the lines from the 'ReleaseNotes.txt' file, if any, and transforms them into a bulleted list. |
| 21 | + if there are no specific release notes, then the corresponding release link is used. minor and |
| 22 | + patch versions will typically have release notes. major releases often have too many items to list |
| 23 | + and are better served by the official release page. the original read me file is copied to the |
| 24 | + intermediate output, the releases notes appended, and the final file is packed in the package |
| 25 | + --> |
| 26 | + <Target Name="GenerateReadme" |
| 27 | + BeforeTargets="GenerateNuspec" |
| 28 | + Condition="Exists('$(SourcePackageReadmeFile)')" |
| 29 | + Label="NuGet"> |
5 | 30 |
|
6 | 31 | <PropertyGroup> |
7 | 32 | <ReleaseNotesFile>$(MSBuildProjectDirectory)\ReleaseNotes.txt</ReleaseNotesFile> |
| 33 | + <PackageReleaseNotes>https://github.com/dotnet/aspnet-api-versioning/releases/tag/v$(PackageVersion)</PackageReleaseNotes> |
| 34 | + </PropertyGroup> |
| 35 | + |
| 36 | + <!-- if there is banner text, merge as one big string |
| 37 | + note: ReadLinesFromFile as items won't work here because empty lines are discarded --> |
| 38 | + <PropertyGroup Condition=" '$(ReadmeBanner)' != '' "> |
| 39 | + <ReadmeContent>| :mega: $(ReadmeBanner) | |
| 40 | +|-| |
| 41 | + |
| 42 | +$([System.IO.File]::ReadAllText('$(SourcePackageReadmeFile)')) |
| 43 | + </ReadmeContent> |
8 | 44 | </PropertyGroup> |
9 | | - |
| 45 | + |
| 46 | + <!-- write all text with the banner --> |
| 47 | + <WriteLinesToFile File="$(TargetPackageReadmeFile)" |
| 48 | + Lines="$(ReadmeContent)" |
| 49 | + Overwrite="true" |
| 50 | + Condition=" '$(ReadmeBanner)' != '' "/> |
| 51 | + |
| 52 | + <!-- just copy the file without a banner --> |
| 53 | + <Copy SourceFiles="$(SourcePackageReadmeFile)" |
| 54 | + DestinationFiles="$(TargetPackageReadmeFile)" |
| 55 | + OverwriteReadOnlyFiles="true" |
| 56 | + Condition=" '$(ReadmeBanner)' == '' " /> |
| 57 | + |
10 | 58 | <ReadLinesFromFile File="$(ReleaseNotesFile)" Condition="Exists('$(ReleaseNotesFile)')" > |
11 | 59 | <Output TaskParameter="Lines" ItemName="ReleaseNotes"/> |
12 | 60 | </ReadLinesFromFile> |
13 | 61 |
|
14 | | - <ItemGroup Condition=" @(ReleaseNotes->Count()) == 0 "> |
15 | | - <ReleaseNotes Include="https://github.com/Microsoft/aspnet-api-versioning/releases/tag/v$(PackageVersion)" /> |
16 | | - </ItemGroup> |
| 62 | + <!-- append link to release --> |
| 63 | + <WriteLinesToFile File="$(TargetPackageReadmeFile)" |
| 64 | + Lines="$(PackageReleaseNotes)" |
| 65 | + Condition="@(ReleaseNotes->Count()) == 0" /> |
17 | 66 |
|
18 | | - <PropertyGroup> |
19 | | - <ReleaseNoteCount>@(ReleaseNotes->Count())</ReleaseNoteCount> |
20 | | - <PackageReleaseNotes Condition=" $(ReleaseNoteCount) < 2 " >@(ReleaseNotes->'%(Identity)')</PackageReleaseNotes> |
21 | | - <PackageReleaseNotes Condition=" $(ReleaseNoteCount) > 1 " >@(ReleaseNotes->'• %(Identity)','%0D%0A')</PackageReleaseNotes> |
22 | | - </PropertyGroup> |
| 67 | + <!-- append specific release notes --> |
| 68 | + <WriteLinesToFile File="$(TargetPackageReadmeFile)" |
| 69 | + Lines="@(ReleaseNotes->'- %(Identity)')" |
| 70 | + Condition="@(ReleaseNotes->Count()) > 0" /> |
23 | 71 |
|
24 | 72 | </Target> |
25 | 73 |
|
|
0 commit comments