WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit 57699ff

Browse files
Merge pull request #54 from SixLabors/js/license-keys
Add licensing package reference transform targets
2 parents d0f141b + d149825 commit 57699ff

File tree

3 files changed

+71
-8
lines changed

3 files changed

+71
-8
lines changed

SharedInfrastructure.sln

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio Version 16
4-
VisualStudioVersion = 16.0.29709.97
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.14.36310.24
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SharedInfrastructure.Tests", "tests\SharedInfrastructure.Tests\SharedInfrastructure.Tests.csproj", "{1664B46A-D99F-4C66-9424-A3A17C926A4C}"
77
EndProject
@@ -66,10 +66,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "targets", "targets", "{A411
6666
EndProjectSection
6767
EndProject
6868
Global
69-
GlobalSection(SharedMSBuildProjectFiles) = preSolution
70-
src\SharedInfrastructure\SharedInfrastructure.projitems*{1664b46a-d99f-4c66-9424-a3a17c926a4c}*SharedItemsImports = 5
71-
src\SharedInfrastructure\SharedInfrastructure.projitems*{68a8cc40-6aed-4e96-b524-31b1158fdeea}*SharedItemsImports = 13
72-
EndGlobalSection
7369
GlobalSection(SolutionConfigurationPlatforms) = preSolution
7470
Debug|Any CPU = Debug|Any CPU
7571
Release|Any CPU = Release|Any CPU
@@ -95,4 +91,8 @@ Global
9591
GlobalSection(ExtensibilityGlobals) = postSolution
9692
SolutionGuid = {CDD6BE8E-01A1-4A70-AA7E-F1D64E8FA829}
9793
EndGlobalSection
94+
GlobalSection(SharedMSBuildProjectFiles) = preSolution
95+
src\SharedInfrastructure\SharedInfrastructure.projitems*{1664b46a-d99f-4c66-9424-a3a17c926a4c}*SharedItemsImports = 5
96+
src\SharedInfrastructure\SharedInfrastructure.projitems*{68a8cc40-6aed-4e96-b524-31b1158fdeea}*SharedItemsImports = 13
97+
EndGlobalSection
9898
EndGlobal

msbuild/props/SixLabors.Src.props

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@
2424

2525
<!--
2626
Define Environmental conditionals. Determined by environmental settings set in build-and-test.yml
27-
These properties are defined 2X to ensure both MSBuild and Visual Studio (preprocessor directives)
28-
can correctly detect them.
2927
-->
3028
<PropertyGroup>
3129
<IsContinuousIntegration Condition="'$(CI)' == 'true'">true</IsContinuousIntegration>
@@ -47,6 +45,19 @@
4745
<MinVerVerbosity>normal</MinVerVerbosity>
4846
</PropertyGroup>
4947

48+
<!--
49+
Package reference to the license project which is consumed by src projects
50+
This is a dev only reference. See the SixLabors.Src.targets file for usage.
51+
-->
52+
<ItemGroup>
53+
<PackageReference
54+
Include="SixLabors.Licensing"
55+
Version="1.0.0"
56+
PrivateAssets="all"
57+
GeneratePathProperty="true"
58+
Condition="'$(PackageId)' != 'SixLabors.Licensing' and '$(MSBuildProjectName)' != 'SixLabors.Licensing'" />
59+
</ItemGroup>
60+
5061
<!-- Package references and additional files which are consumed by src projects. CI Only -->
5162
<ItemGroup Condition="'$(IsContinuousIntegration)'=='true'">
5263
<PackageReference Include="Microsoft.SourceLink.GitHub"

msbuild/targets/SixLabors.Src.targets

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,56 @@
1717
DestinationFolder="$(SixLaborsSolutionDirectory)" />
1818
</Target>
1919

20+
<!--
21+
This target is responsible for copying licensing files to the licensing NuGet package
22+
to our build output.
23+
See SixLabors.Src.props for the package references.
24+
Hook into NuGet pack.
25+
-->
26+
<PropertyGroup>
27+
<TargetsForTfmSpecificContentInPackage>
28+
$(TargetsForTfmSpecificContentInPackage);_SixLabors_AddLicensingFiles
29+
</TargetsForTfmSpecificContentInPackage>
30+
</PropertyGroup>
31+
32+
<!-- Add files per TFM from the *package cache* only -->
33+
<Target Name="_SixLabors_AddLicensingFiles"
34+
Condition="'$(IsPackable)'=='true'
35+
and '$(TargetFramework)'!=''
36+
and $([System.String]::Copy('$(PackageId)').StartsWith('SixLabors.'))
37+
and '$(PackageId)'!='SixLabors.Licensing'
38+
and '$(PkgSixLabors_Licensing)'!=''">
39+
40+
<ItemGroup>
41+
<!-- Rename the validator template into the consuming package -->
42+
<TfmSpecificPackageFile Include="$(PkgSixLabors_Licensing)\build\SixLabors.ValidateLicense.targets"
43+
Condition="Exists('$(PkgSixLabors_Licensing)\build\SixLabors.ValidateLicense.targets')">
44+
<PackagePath>build\$(PackageId).targets</PackagePath>
45+
</TfmSpecificPackageFile>
46+
47+
<!-- dotnet MSBuild task -->
48+
<TfmSpecificPackageFile Include="$(PkgSixLabors_Licensing)\build\net8.0\SixLabors.Licensing.dll"
49+
Condition="Exists('$(PkgSixLabors_Licensing)\build\net8.0\SixLabors.Licensing.dll')">
50+
<PackagePath>build\net8.0\SixLabors.Licensing.dll</PackagePath>
51+
</TfmSpecificPackageFile>
52+
53+
<!-- VS/CLR4 MSBuild task -->
54+
<TfmSpecificPackageFile Include="$(PkgSixLabors_Licensing)\build\net472\SixLabors.Licensing.dll"
55+
Condition="Exists('$(PkgSixLabors_Licensing)\build\net472\SixLabors.Licensing.dll')">
56+
<PackagePath>build\net472\SixLabors.Licensing.dll</PackagePath>
57+
</TfmSpecificPackageFile>
58+
</ItemGroup>
59+
</Target>
60+
61+
<!-- Hard fail if the package path isn't resolvable -->
62+
<Target Name="FailIfLicensingPathMissing" BeforeTargets="Pack"
63+
Condition="'$(IsPackable)'=='true'
64+
and '$(TargetFramework)'!=''
65+
and $([System.String]::Copy('$(PackageId)').StartsWith('SixLabors.'))
66+
and '$(PackageId)'!='SixLabors.Licensing'
67+
and ( '$(PkgSixLabors_Licensing)'==''
68+
or !Exists('$(PkgSixLabors_Licensing)\build\net8.0\SixLabors.Licensing.dll') )">
69+
<Error Text="Licensing task not found under $(PkgSixLabors_Licensing)\build\net8.0. Ensure the dev-only PackageReference (GeneratePathProperty='true') is present and restore ran." />
70+
</Target>
71+
2072
</Project>

0 commit comments

Comments
 (0)