Skip to content

Commit 801e84c

Browse files
authored
Merge pull request #11 from nike4613/strongname
Strong name Backports
2 parents 52ae77f + a6c7c26 commit 801e84c

8 files changed

Lines changed: 45 additions & 40 deletions

File tree

MonoMod.Backports.snk

1.14 KB
Binary file not shown.

src/MonoMod.Backports.Shims/Directory.Build.targets

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,7 @@
125125
DependsOnTargets="$(CoreCompileDependsOn);_PrepareRawTfmList;_GetShimmedPackages;ResolveProjectReferences"
126126
Inputs="$(MSBuildAllProjects);@(MMShimGen)"
127127
Outputs="$(_OutputTfmsTxt)"
128-
Condition="'$(dotnet-nugetize)' == ''"
129-
>
128+
Condition="'$(dotnet-nugetize)' == ''">
130129

131130
<ItemGroup>
132131
<_ExistingShimFiles Include="$(_ShimsDir)**/*" />
@@ -140,16 +139,37 @@
140139
<_ShimGenExe>%(MMShimGen.RelativeDir)%(FileName)$(_NativeExecutableExtension)</_ShimGenExe>
141140
<_SnkDir>$(MMRootPath)snk/</_SnkDir>
142141
</PropertyGroup>
142+
143+
<ItemGroup>
144+
<_BackportsProps Remove="@(_BackportsProps)"/>
145+
</ItemGroup>
146+
147+
<MSBuild Projects="$(MMSourcePath)MonoMod.Backports/MonoMod.Backports.csproj"
148+
Targets="GetAssemblyVersion;GetProperties"
149+
Properties="TargetFramework=net8.0;PropertyNames=AssemblyVersion,AssemblyOriginatorKeyFile;BuildProjectReferences=false">
150+
<Output ItemName="_BackportsProps" TaskParameter="TargetOutputs" />
151+
</MSBuild>
152+
153+
<PropertyGroup>
154+
<_BackportsAsmVersion></_BackportsAsmVersion>
155+
<_BackportsKeyFile></_BackportsKeyFile>
156+
<_BackportsAsmVersion Condition="'%(_BackportsProps.Identity)' == 'AssemblyVersion'">%(_BackportsProps.Value)</_BackportsAsmVersion>
157+
<_BackportsKeyFile Condition="'%(_BackportsProps.Identity)' == 'AssemblyOriginatorKeyFile'">%(_BackportsProps.Value)</_BackportsKeyFile>
158+
</PropertyGroup>
143159

144160
<ItemGroup>
145161
<_PPArguments Remove="@(_PPArguments)" />
146-
<!-- 1: the output directory -->
162+
<!-- 1: Backports version -->
163+
<_PPArguments Include="$(_BackportsAsmVersion)" />
164+
<!-- 2: Backports keyfile -->
165+
<_PPArguments Include="$(_BackportsKeyFile)" />
166+
<!-- 3: the output directory -->
147167
<_PPArguments Include="$(_ShimsDir)" />
148-
<!-- 2: snk directory -->
168+
<!-- 4: snk directory -->
149169
<_PPArguments Include="$(_SnkDir)" />
150-
<!-- 3: tfms file -->
170+
<!-- 5: tfms file -->
151171
<_PPArguments Include="$(_BackportsTfmsTxt)" />
152-
<!-- 4: the paths to the packages to process -->
172+
<!-- 6: the paths to the packages to process -->
153173
<_PPArguments Include="@(_ShimmedPackagePaths)" />
154174
</ItemGroup>
155175

src/MonoMod.Backports/MonoMod.Backports.csproj

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
44
<!-- target frameworks are defined in Common.props -->
55

66
<!-- We're not going to be having any of the logic that would use the shared sources, so we'll just not include them -->
77
<RootNamespace><![CDATA[ ]]></RootNamespace>
88
<NoWarn>$(NoWarn);CA1200;CA1716</NoWarn>
9-
<MMReferenceSourcePkgs>false</MMReferenceSourcePkgs>
109
</PropertyGroup>
1110

1211
<PropertyGroup>
1312
<Description>A set of backports of new BCL features to all frameworks which MonoMod supports.</Description>
1413
</PropertyGroup>
1514

15+
<PropertyGroup>
16+
<AssemblyOriginatorKeyFile>$(MMRootPath)MonoMod.Backports.snk</AssemblyOriginatorKeyFile>
17+
<SignAssembly>true</SignAssembly>
18+
</PropertyGroup>
19+
1620
<PropertyGroup>
1721
<MMTFKind>$([MSBuild]::GetTargetFrameworkIdentifier('$(TargetFramework)'))</MMTFKind>
1822
<MMTFVersion>$([MSBuild]::GetTargetFrameworkVersion('$(TargetFramework)'))</MMTFVersion>
@@ -24,9 +28,7 @@
2428
<PackageReference Include="js6pak.InlineIL.Fody" Version="1.10.0-js6pak.1" PrivateAssets="all" ExcludeAssets="runtime" Pack="false" />
2529
</ItemGroup>
2630

27-
<Target Name="RemoveImplicitOutOfBandAssemblies"
28-
BeforeTargets="BeforeCompile"
29-
AfterTargets="FindReferenceAssembliesForReferences">
31+
<Target Name="RemoveImplicitOutOfBandAssemblies" BeforeTargets="BeforeCompile" AfterTargets="FindReferenceAssembliesForReferences">
3032
<ItemGroup>
3133
<ReferencePathWithRefAssemblies Remove="@(ReferencePathWithRefAssemblies)" Condition="%(Filename) == 'System.Runtime.CompilerServices.Unsafe'" />
3234
</ItemGroup>

src/MonoMod.Backports/NuGet.targets

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
11
<Project>
22

3-
<Target Name="Backports_AddShimsDependency">
4-
<ItemGroup>
5-
<PackageReference Include="MonoMod.Backports.Shims" Version="$(Version)" />
6-
</ItemGroup>
7-
</Target>
8-
93
<ItemGroup>
104
<PackageFile Include="MonoMod.Backports.Shims" Version="$(Version)">
115
<Source>Explicit</Source>

src/build/MonoMod.Backports.Tasks/MonoMod.Backports.Tasks.csproj

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
<PropertyGroup>
44
<TargetFrameworks>netstandard2.0</TargetFrameworks>
55

6-
<MMReferenceSourcePkgs>false</MMReferenceSourcePkgs>
7-
86
<Nullable>disable</Nullable>
97

108
<IsPackable>false</IsPackable>
@@ -13,7 +11,6 @@
1311

1412
<ItemGroup>
1513
<PackageReference Include="Microsoft.Build.Utilities.Core" Version="$(MSBuildRequiredVersion)" />
16-
<!--<PackageReference Include="System.Collections.Immutable" Version="6.0.0" />-->
1714
</ItemGroup>
1815

1916
</Project>

src/build/ShimGen/Program.cs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,15 @@
1313
using System.Diagnostics.CodeAnalysis;
1414

1515
if (args is not [
16+
var backportsVersion,
17+
var backportsSnkFile,
1618
var outputRefDir,
1719
var snkPath,
1820
var tfmsFilePath,
1921
.. var dotnetOobPackagePaths
2022
])
2123
{
22-
Console.Error.WriteLine("Assemblies not provided.");
23-
Console.Error.WriteLine("Syntax: <output ref dir> <snk directory> <tfms file> <...oob package paths...>");
24+
Console.Error.WriteLine("Syntax: <backports version> <backports snk file> <output ref dir> <snk directory> <tfms file> <...oob package paths...>");
2425
Console.Error.WriteLine("Arguments provided: ");
2526
foreach (var arg in args)
2627
{
@@ -160,6 +161,12 @@ .. var dotnetOobPackagePaths
160161
.OrderBy(t => t.fwk, precSorter)
161162
.ToArray();
162163

164+
var backportsReferenceBase = new AssemblyReference(
165+
"MonoMod.Backports",
166+
new Version(backportsVersion),
167+
publicKey: true,
168+
StrongNamePrivateKey.FromFile(backportsSnkFile).CreatePublicKeyBlob(AssemblyHashAlgorithm.Sha1));
169+
163170
// Now, we have some work to do for shims. We want to check if there is an equivalent type to the shims
164171
// defined or exported from Backports, and rewrite a new shim forwarding to Backports as appropriate.
165172
var importedSet = new Dictionary<string, ExportedType>();
@@ -195,9 +202,7 @@ .. var dotnetOobPackagePaths
195202
HasPublicKey = bclShim.Assembly!.HasPublicKey,
196203
};
197204

198-
backportsReference =
199-
new AssemblyReference("MonoMod.Backports", new(1, 0, 0, 0))
200-
.ImportWith(backportsShim.DefaultImporter);
205+
backportsReference = backportsReferenceBase.ImportWith(backportsShim.DefaultImporter);
201206

202207
foreach (var file in dllsByDllName[dllName].Values.SelectMany(x => x))
203208
{

tools/Common.CS.props

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@
2121
<AnalysisMode>All</AnalysisMode>
2222
<AnalysisLevel>8.0</AnalysisLevel>
2323

24-
<MMReferenceSourcePkgs>true</MMReferenceSourcePkgs>
25-
2624
<NoWarn>$(NoWarn);CS1591</NoWarn> <!-- XML documentation warning. TODO: We should probably remove this at some point and ensure that MM is fully documented. -->
2725
<NoWarn>$(NoWarn);CA1716</NoWarn> <!-- Members have name shared with primitive type. -->
2826
<NoWarn>$(NoWarn);CA1003</NoWarn> <!-- Change event to use EventHandler<EventArgs> -->
@@ -37,16 +35,5 @@
3735
<!-- We want to remove JSImportGenerator by default, becuase it takes a good deal of compilation time -->
3836
<RemoveAnalyzer Include="Microsoft.Interop.JavaScript.JSImportGenerator" />
3937
</ItemGroup>
40-
41-
<ItemGroup Condition="'$(MMReferenceSourcePkgs)' == 'true'">
42-
<PackageReference Include="Nullable" Version="1.3.1">
43-
<PrivateAssets>all</PrivateAssets>
44-
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
45-
</PackageReference>
46-
<PackageReference Include="IsExternalInit" Version="1.0.3">
47-
<PrivateAssets>all</PrivateAssets>
48-
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
49-
</PackageReference>
50-
</ItemGroup>
5138

5239
</Project>

tools/Common.targets

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@
2222
</ItemGroup>
2323

2424
<ItemGroup>
25-
<_PropertiesToGet Include="$(PropertyNames)" />
25+
<_PropertiesToGet Include="$([System.String]::Copy($(PropertyNames)).Split(','))" />
2626
</ItemGroup>
2727

2828
<ItemGroup>
29-
<Properties Include="%(_PropertiesToGet.Identity)" Value="$(%(Identity))" />
29+
<Properties Include="%(_PropertiesToGet.Identity)" Value="$(%(_PropertiesToGet.Identity))" />
3030
</ItemGroup>
3131
</Target>
3232

0 commit comments

Comments
 (0)