Skip to content

Commit aaa6e4d

Browse files
committed
more packaging fixes to prevent end-user dependency pollution
1 parent 18a348a commit aaa6e4d

File tree

6 files changed

+82
-28
lines changed

6 files changed

+82
-28
lines changed

.vscode/settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
{
22
"[fsharp]": {
33
"editor.formatOnSave": true
4+
},
5+
"files.associations": {
6+
"**/build*/*[props|targets]": "msbuild"
47
}
58
}

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Changelog
22

3+
## [0.1.7] - 2022.03.31
4+
5+
### Changed
6+
7+
* Better packaging of the task to prevent task DLL dependencies from impacting your project's dependencies
8+
* Updated the parser to provide to `ToMarkdown()` member for more general use
9+
310
## [0.1.6] - 2022.03.31
411

512
### Changed

src/Directory.Build.props

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
<Project>
22
<PropertyGroup>
3-
<Version>0.1.6</Version>
3+
<Version>0.1.7</Version>
44
<PackageReleaseNotes>
55
### Changed
66

7-
- bump SDK
7+
* Better packaging of the task to prevent task DLL dependencies from impacting your project's dependencies
8+
* Updated the parser to provide to `ToMarkdown()` member for more general use
89
</PackageReleaseNotes>
910
</PropertyGroup>
1011
</Project>
Lines changed: 46 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,75 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>netstandard2.0</TargetFramework>
4+
<TargetFrameworks>net472;net6.0</TargetFrameworks>
55
<!-- we need the assemblies bundled, so set this so we don't expose any dependencies to the outside world -->
66
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
77
<TargetsForTfmSpecificBuildOutput>$(TargetsForTfmSpecificBuildOutput);CopyProjectReferencesToPackage</TargetsForTfmSpecificBuildOutput>
88
<DebugType>embedded</DebugType>
99
<IsPackable>true</IsPackable>
1010
<Description>MSBuild Tasks and Targets that set your Assembly Version, Package Version, and Package Release Notes from your KeepAChangelog-compatible Changelogs.</Description>
1111
<EnableDynamicLoading>true</EnableDynamicLoading>
12+
<GenerateDependencyFile>true</GenerateDependencyFile>
13+
<!-- <SuppressDependenciesWhenPacking>true</SuppressDependenciesWhenPacking> -->
14+
<NoWarn>NU5128;NU5100</NoWarn><!-- NU5100 is because we pack to tasks/, not lib/ -->
15+
<BuildOutputTargetFolder>tasks</BuildOutputTargetFolder>
1216
</PropertyGroup>
1317

1418
<ItemGroup>
1519
<Compile Include="Library.fs" />
1620
<!-- these lines pack the single-TFM build props/targets files to the `build` folder in the generated package.
1721
By convention, the .NET SDK will look for `build\<Package Id>.props` and `build\<Package Id>.targets`
1822
for automatic inclusion in a single-TFM build. -->
19-
<Content Include="build\*" PackagePath="build\" />
23+
<Content
24+
Include="build\*"
25+
PackagePath="build\" />
2026
<!-- these lines pack the multi-target TFM build props/targets files to the `buildMultiTargeting` folder in the generated package.
2127
By convention, the .NET SDK will look for `buildMultiTargeting\<Package Id>.props` and `buildMultiTargeting\<Package Id>.targets`
2228
for automatic inclusion in a multi-TFM build. -->
23-
<Content Include="buildMultiTargeting\*" PackagePath="buildMultiTargeting\" />
29+
<Content
30+
Include="buildMultiTargeting\*"
31+
PackagePath="buildMultiTargeting\" />
2432
</ItemGroup>
2533
<ItemGroup>
26-
<PackageReference Include="Microsoft.Build.Utilities.Core" Version="17.0.0" PrivateAssets="All" ExcludeAssets="Runtime" />
27-
<PackageReference Include="SemanticVersion" Version="2.1.0" PrivateAssets="All" />
28-
<PackageReference Include="FParsec" Version="1.1.1" PrivateAssets="All" />
29-
<PackageReference Update="FSharp.Core" PrivateAssets="All" />
30-
<ProjectReference Include="../Ionide.KeepAChangelog/Ionide.KeepAChangelog.fsproj" PrivateAssets="All" />
34+
<PackageReference
35+
Include="Microsoft.Build.Utilities.Core"
36+
Version="17.0.0"
37+
ExcludeAssets="Runtime"
38+
PrivateAssets="all"/>
39+
<PackageReference
40+
Include="SemanticVersion"
41+
Version="2.1.0"
42+
PrivateAssets="all"/>
43+
<PackageReference
44+
Include="FParsec"
45+
Version="1.1.1"
46+
PrivateAssets="all"/>
47+
<PackageReference Update="FSharp.Core" PrivateAssets="all"/>
48+
<ProjectReference Include="../Ionide.KeepAChangelog/Ionide.KeepAChangelog.fsproj" PrivateAssets="all"/>
3149
</ItemGroup>
3250

33-
<Target Name="CopyProjectReferencesToPackage" DependsOnTargets="ResolveReferences">
51+
<Target
52+
Name="AddBuildDependencyFileToBuiltProjectOutputGroupOutput"
53+
BeforeTargets="BuiltProjectOutputGroup"
54+
Condition=" '$(GenerateDependencyFile)' == 'true'">
55+
56+
<ItemGroup>
57+
<BuiltProjectOutputGroupOutput
58+
Include="$(ProjectDepsFilePath)"
59+
TargetPath="$(ProjectDepsFileName)"
60+
FinalOutputPath="$(ProjectDepsFilePath)" />
61+
</ItemGroup>
62+
</Target>
63+
64+
<Target
65+
Name="CopyProjectReferencesToPackage"
66+
DependsOnTargets="ResolveReferences">
3467
<ItemGroup>
35-
<BuildOutputInPackage Include="$(OutputPath)/*.deps.json" />
3668
<!-- the dependencies of your MSBuild task must be packaged inside the package, they cannot be expressed as normal PackageReferences -->
37-
<BuildOutputInPackage Include="@(ReferenceCopyLocalPaths)" TargetPath="%(ReferenceCopyLocalPaths.DestinationSubPath)" />
69+
<BuildOutputInPackage
70+
Include="@(ReferenceCopyLocalPaths)"
71+
TargetPath="%(ReferenceCopyLocalPaths.DestinationSubPath)" />
3872
</ItemGroup>
3973
</Target>
4074

41-
</Project>
75+
</Project>

src/Ionide.KeepAChangelog.Tasks/build/Ionide.KeepAChangelog.Tasks.targets

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,27 @@
11
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2-
<UsingTask
3-
AssemblyFile="$(MSBuildThisFileDirectory)../lib/netstandard2.0/Ionide.KeepAChangelog.Tasks.dll"
4-
TaskName="Ionide.KeepAChangelog.Tasks.ParseChangeLogs" />
52

63
<PropertyGroup>
74
<!-- 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.
8-
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. -->
5+
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. -->
96
<PrepareForBuildDependsOn>
10-
SetVersionFromChangelog;
11-
$(PrepareForBuildDependsOn)
12-
</PrepareForBuildDependsOn>
7+
SetVersionFromChangelog;
8+
$(PrepareForBuildDependsOn)
9+
</PrepareForBuildDependsOn>
1310
<!-- For project-to-project dependencies, GetPackageVersionDependsOn can be used as a well-known hook to ensure the project's versioning properties are run. -->
1411
<GetPackageVersionDependsOn>
15-
SetVersionFromChangelog
16-
$(GetPackageVersionDependsOn);
17-
</GetPackageVersionDependsOn>
12+
SetVersionFromChangelog
13+
$(GetPackageVersionDependsOn);
14+
</GetPackageVersionDependsOn>
15+
16+
<_Ionide_KeepAChangelog_Tasks_TFM Condition=" '$(MSBuildRuntimeType)' == 'Full' ">net472</_Ionide_KeepAChangelog_Tasks_TFM>
17+
<_Ionide_KeepAChangelog_Tasks_TFM Condition=" '$(MSBuildRuntimeType)' == 'Core' ">net6.0</_Ionide_KeepAChangelog_Tasks_TFM>
18+
<_Ionide_KeepAChangelog_Tasks_TFM Condition="'$(_Ionide_KeepAChangelog_Tasks_TFM)' == '' ">net6.0</_Ionide_KeepAChangelog_Tasks_TFM>
1819
</PropertyGroup>
1920

21+
<UsingTask
22+
AssemblyFile="$(MSBuildThisFileDirectory)../tasks/$(_Ionide_KeepAChangelog_Tasks_TFM)/Ionide.KeepAChangelog.Tasks.dll"
23+
TaskName="Ionide.KeepAChangelog.Tasks.ParseChangeLogs" />
24+
2025
<Target
2126
Name="GetChangelogVersion"
2227
Condition="'$(ChangelogFile)' != '' and Exists('$(ChangelogFile)')"

src/Ionide.KeepAChangelog.Tasks/buildMultiTargeting/Ionide.KeepAChangelog.Tasks.targets

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
11
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2-
<UsingTask
3-
AssemblyFile="$(MSBuildThisFileDirectory)../lib/netstandard2.0/Ionide.KeepAChangelog.Tasks.dll"
4-
TaskName="Ionide.KeepAChangelog.Tasks.ParseChangeLogs" />
5-
62
<PropertyGroup>
73
<!-- For multitargeting builds, the 'outer' build is used for things like packing, and so never hits the `PrepareForBuildDependsOn` condition group
84
That works for 'inner', TFM-specific builds. Therefore we need another hook. Luckily, for packaging we can be much less restrictive on
@@ -16,8 +12,16 @@
1612
SetVersionFromChangelog
1713
$(GetPackageVersionDependsOn);
1814
</GetPackageVersionDependsOn>
15+
16+
<_Ionide_KeepAChangelog_Tasks_TFM Condition=" '$(MSBuildRuntimeType)' == 'Full' ">net472</_Ionide_KeepAChangelog_Tasks_TFM>
17+
<_Ionide_KeepAChangelog_Tasks_TFM Condition=" '$(MSBuildRuntimeType)' == 'Core' ">net6.0</_Ionide_KeepAChangelog_Tasks_TFM>
18+
<_Ionide_KeepAChangelog_Tasks_TFM Condition="'$(_Ionide_KeepAChangelog_Tasks_TFM)' == '' ">net6.0</_Ionide_KeepAChangelog_Tasks_TFM>
1919
</PropertyGroup>
2020

21+
<UsingTask
22+
AssemblyFile="$(MSBuildThisFileDirectory)../tasks/$(_Ionide_KeepAChangelog_Tasks_TFM)/Ionide.KeepAChangelog.Tasks.dll"
23+
TaskName="Ionide.KeepAChangelog.Tasks.ParseChangeLogs" />
24+
2125
<Target
2226
Name="GetChangelogVersion"
2327
Condition="'$(ChangelogFile)' != '' and Exists('$(ChangelogFile)')"

0 commit comments

Comments
 (0)