Skip to content

Commit

Permalink
Merge pull request #6 from ionide/support-multitargeted-builds
Browse files Browse the repository at this point in the history
  • Loading branch information
baronfel authored Feb 14, 2022
2 parents 53dfbd0 + 04d49e3 commit a153d04
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 23 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## [0.1.2] - 2022.02.13

### Added

- Now supports multiTargeted builds and packs by the addition of the buildMultiTargeting folder. The outer build is hooked at the GenerateNuspec target.

## [0.1.1] - 2022.01.14

### Added
Expand Down
20 changes: 12 additions & 8 deletions src/Ionide.KeepAChangelog.Tasks/Ionide.KeepAChangelog.Tasks.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,24 @@
<DebugType>embedded</DebugType>
<IsPackable>true</IsPackable>
<Description>MSBuild Tasks and Targets that set your Assembly Version, Package Version, and Package Release Notes from your KeepAChangelog-compatible Changelogs.</Description>
<Version>0.1.1</Version>
<PackageReleaseNotes>### Added
<Version>0.1.2</Version>
<PackageReleaseNotes>
### Added

- Now writes an assembly-level AssemblyMetadataAttribute with the key "BuildDate" whose value is the `YYYY-mm-dd`-formatted date in the release changelog
- Now supports multiTargeted builds and packs by the addition of the buildMultiTargeting folder. The outer build is hooked at the GenerateNuspec target.
</PackageReleaseNotes>
</PropertyGroup>

<ItemGroup>
<Compile Include="Library.fs" />
<!-- these lines pack the build props/targets files to the `build` folder in the generated package.
by convention, the .NET SDK will look for build\<Package Id>.props and build\<Package Id>.targets
for automatic inclusion in the build. -->
<Content Include="build\Ionide.KeepAChangelog.Tasks.props" PackagePath="build\" />
<Content Include="build\Ionide.KeepAChangelog.Tasks.targets" PackagePath="build\" />
<!-- these lines pack the single-TFM build props/targets files to the `build` folder in the generated package.
By convention, the .NET SDK will look for `build\<Package Id>.props` and `build\<Package Id>.targets`
for automatic inclusion in a single-TFM build. -->
<Content Include="build\*" PackagePath="build\" />
<!-- these lines pack the multi-target TFM build props/targets files to the `buildMultiTargeting` folder in the generated package.
By convention, the .NET SDK will look for `buildMultiTargeting\<Package Id>.props` and `buildMultiTargeting\<Package Id>.targets`
for automatic inclusion in a multi-TFM build. -->
<Content Include="buildMultiTargeting\*" PackagePath="buildMultiTargeting\" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Build.Utilities.Core" Version="17.0.0" PrivateAssets="All" IncludeAssets="Compile" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,36 +1,33 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<UsingTask AssemblyFile="$(MSBuildThisFileDirectory)../lib/netstandard2.0/Ionide.KeepAChangelog.Tasks.dll" TaskName="Ionide.KeepAChangelog.Tasks.ParseChangeLogs"/>
<UsingTask AssemblyFile="$(MSBuildThisFileDirectory)../lib/netstandard2.0/Ionide.KeepAChangelog.Tasks.dll" TaskName="Ionide.KeepAChangelog.Tasks.ParseChangeLogs" />

<PropertyGroup>
<!-- For single-target builds (or inner builds of a multi-targeted build) we must run before any of the normal versioning-related targets are run.
This is surprisingly hard to time correctly. PrepareForBuild is the best location I've been able to find, and Rainer agrees this is a logical spot. -->
<PrepareForBuildDependsOn>
SetVersionFromChangelog;
$(PrepareForBuildDependsOn)
</PrepareForBuildDependsOn>
</PropertyGroup>

<Target Name="GetChangelogVersion"
Condition="'$(ChangelogFile)' != '' and Exists('$(ChangelogFile)')"
Inputs="$(ChangelogFile)"
Outputs="UnreleasedChangelog;CurrentReleaseChangelog;AllReleasedChangelogslLatestReleaseNotes">
<Ionide.KeepAChangelog.Tasks.ParseChangeLogs
ChangelogFile="$(ChangelogFile)">
<Output TaskParameter="UnreleasedChangelog" ItemName="UnreleasedChangelog"/>
<Output TaskParameter="CurrentReleaseChangelog" ItemName="CurrentReleaseChangelog"/>

<Target Name="GetChangelogVersion" Condition="'$(ChangelogFile)' != '' and Exists('$(ChangelogFile)')" Inputs="$(ChangelogFile)" Outputs="UnreleasedChangelog;CurrentReleaseChangelog;AllReleasedChangelogslLatestReleaseNotes">
<Ionide.KeepAChangelog.Tasks.ParseChangeLogs ChangelogFile="$(ChangelogFile)">
<Output TaskParameter="UnreleasedChangelog" ItemName="UnreleasedChangelog" />
<Output TaskParameter="CurrentReleaseChangelog" ItemName="CurrentReleaseChangelog" />
<Output TaskParameter="AllReleasedChangelogs" ItemName="AllReleasedChangelogs" />
<Output TaskParameter="LatestReleaseNotes" ItemName="LatestReleaseNotes" />
</Ionide.KeepAChangelog.Tasks.ParseChangeLogs>
</Target>

<Target Name="SetVersionFromChangelog"
DependsOnTargets="GetChangelogVersion">
<Target Name="SetVersionFromChangelog" DependsOnTargets="GetChangelogVersion">
<PropertyGroup Condition="'@(CurrentReleaseChangelog)' != ''">
<Version>%(CurrentReleaseChangelog.Identity)</Version>
<PackageVersion>%(CurrentReleaseChangelog.Identity)</PackageVersion>
<PackageReleaseNotes>@(LatestReleaseNotes)</PackageReleaseNotes>
</PropertyGroup>

<ItemGroup Condition="'@(CurrentReleaseChangelog)' != '' and '$(GenerateAssemblyInfo)' == 'true'">
<AssemblyAttribute Include="System.Reflection.AssemblyMetadataAttribute" Condition="'$(GenerateRepositoryUrlAttribute)' == 'true' and ('$(RepositoryUrl)' != '' or '$(PublishRepositoryUrl)' == 'true')" >
<AssemblyAttribute Include="System.Reflection.AssemblyMetadataAttribute" Condition="'$(GenerateRepositoryUrlAttribute)' == 'true' and ('$(RepositoryUrl)' != '' or '$(PublishRepositoryUrl)' == 'true')">
<_Parameter1>BuildDate</_Parameter1>
<_Parameter2>%(CurrentReleaseChangelog.Date)</_Parameter2>
</AssemblyAttribute>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ChangelogFile Condition="'$(ChangelogFile)' == ''">CHANGELOG.md</ChangelogFile>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<UsingTask AssemblyFile="$(MSBuildThisFileDirectory)../lib/netstandard2.0/Ionide.KeepAChangelog.Tasks.dll" TaskName="Ionide.KeepAChangelog.Tasks.ParseChangeLogs" />

<PropertyGroup>
<!-- For multitargeting builds, the 'outer' build is used for things like packing, and so never hits the `PrepareForBuildDependsOn` condition group
That works for 'inner', TFM-specific builds. Therefore we need another hook. Luckily, for packaging we can be much less restrictive on
_when_ the versioning information is collected, because assemblies don't need to be stamped, so this can just happen sometime before
the GenerateNuspec task. -->
<GenerateNuspecDependsOn>
SetVersionFromChangelog;
$(GenerateNuspecDependsOn)
</GenerateNuspecDependsOn>
</PropertyGroup>

<Target Name="GetChangelogVersion" Condition="'$(ChangelogFile)' != '' and Exists('$(ChangelogFile)')" Inputs="$(ChangelogFile)" Outputs="UnreleasedChangelog;CurrentReleaseChangelog;AllReleasedChangelogslLatestReleaseNotes">
<Ionide.KeepAChangelog.Tasks.ParseChangeLogs ChangelogFile="$(ChangelogFile)">
<Output TaskParameter="UnreleasedChangelog" ItemName="UnreleasedChangelog" />
<Output TaskParameter="CurrentReleaseChangelog" ItemName="CurrentReleaseChangelog" />
<Output TaskParameter="AllReleasedChangelogs" ItemName="AllReleasedChangelogs" />
<Output TaskParameter="LatestReleaseNotes" ItemName="LatestReleaseNotes" />
</Ionide.KeepAChangelog.Tasks.ParseChangeLogs>
</Target>

<Target Name="SetVersionFromChangelog" DependsOnTargets="GetChangelogVersion">
<PropertyGroup Condition="'@(CurrentReleaseChangelog)' != ''">
<Version>%(CurrentReleaseChangelog.Identity)</Version>
<PackageVersion>%(CurrentReleaseChangelog.Identity)</PackageVersion>
<PackageReleaseNotes>@(LatestReleaseNotes)</PackageReleaseNotes>
</PropertyGroup>

<ItemGroup Condition="'@(CurrentReleaseChangelog)' != '' and '$(GenerateAssemblyInfo)' == 'true'">
<AssemblyAttribute Include="System.Reflection.AssemblyMetadataAttribute" Condition="'$(GenerateRepositoryUrlAttribute)' == 'true' and ('$(RepositoryUrl)' != '' or '$(PublishRepositoryUrl)' == 'true')">
<_Parameter1>BuildDate</_Parameter1>
<_Parameter2>%(CurrentReleaseChangelog.Date)</_Parameter2>
</AssemblyAttribute>
</ItemGroup>
</Target>

</Project>
7 changes: 5 additions & 2 deletions src/Ionide.KeepAChangelog/Ionide.KeepAChangelog.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@
<DebugType>embedded</DebugType>
<IsPackable>true</IsPackable>
<Description>A self-contained parser for the KeepAChangelog format.</Description>
<Version>0.1.1</Version>
<PackageReleaseNotes>Initial release of the KeepAChangelog parser.</PackageReleaseNotes>
<Version>0.1.2</Version>
<PackageReleaseNotes>
### Added

- Now supports multiTargeted builds and packs by the addition of the buildMultiTargeting folder. The outer build is hooked at the GenerateNuspec target.</PackageReleaseNotes>
</PropertyGroup>

<ItemGroup>
Expand Down

0 comments on commit a153d04

Please sign in to comment.