Skip to content

Commit af39659

Browse files
Multi-target Microsoft.NET.HostModel (#114343)
* Multi-target Microsoft.NET.HostModel Multi-targeting helps to use latest on .NETCoreApp and LKG (toolset) on .NETFramework. Should partially unblock m-p packages dependency flow in dotnet/sdk: dotnet/sdk#48034 --------- Co-authored-by: Carlos Sánchez López <1175054+carlossanlop@users.noreply.github.com>
1 parent f9afc71 commit af39659

File tree

4 files changed

+19
-9
lines changed

4 files changed

+19
-9
lines changed

eng/Versions.props

-1
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,6 @@
143143
<SystemCollectionsImmutableToolsetVersion>8.0.0</SystemCollectionsImmutableToolsetVersion>
144144
<SystemMemoryToolsetVersion>4.5.5</SystemMemoryToolsetVersion>
145145
<SystemTextJsonToolsetVersion>8.0.5</SystemTextJsonToolsetVersion>
146-
<SystemReflectionMetadataToolsetVersion>8.0.0</SystemReflectionMetadataToolsetVersion>
147146
<SystemReflectionMetadataLoadContextToolsetVersion>8.0.0</SystemReflectionMetadataLoadContextToolsetVersion>
148147
<SystemReflectionMetadataToolsetVersion>8.0.0</SystemReflectionMetadataToolsetVersion>
149148
<SystemTextEncodingsWebToolsetVersion>8.0.0</SystemTextEncodingsWebToolsetVersion>

src/installer/managed/Microsoft.NET.HostModel/ComHost/ConflictingGuidException.cs

+5
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ public class ConflictingGuidException : Exception
1414
{
1515
public ConflictingGuidException(string typeName1, string typeName2, Guid guid)
1616
{
17+
#if NET
18+
ArgumentNullException.ThrowIfNull(typeName1);
19+
ArgumentNullException.ThrowIfNull(typeName2);
20+
#else
1721
if (typeName1 is null)
1822
{
1923
throw new ArgumentNullException(nameof(typeName1));
@@ -22,6 +26,7 @@ public ConflictingGuidException(string typeName1, string typeName2, Guid guid)
2226
{
2327
throw new ArgumentNullException(nameof(typeName2));
2428
}
29+
#endif
2530
TypeName1 = typeName1;
2631
TypeName2 = typeName2;
2732
Guid = guid;

src/installer/managed/Microsoft.NET.HostModel/ComHost/MissingGuidException.cs

+4
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,14 @@ public class MissingGuidException : Exception
1414
{
1515
public MissingGuidException(string typeName)
1616
{
17+
#if NET
18+
ArgumentNullException.ThrowIfNull(typeName);
19+
#else
1720
if (typeName is null)
1821
{
1922
throw new ArgumentNullException(nameof(typeName));
2023
}
24+
#endif
2125
TypeName = typeName;
2226
}
2327

src/installer/managed/Microsoft.NET.HostModel/Microsoft.NET.HostModel.csproj

+10-8
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>netstandard2.0</TargetFramework>
4+
<TargetFrameworks>$(NetCoreAppToolCurrent);$(NetFrameworkToolCurrent)</TargetFrameworks>
55
<Description>Abstractions for modifying .NET host binaries</Description>
66
<IsShipping>false</IsShipping>
77
<IsPackable Condition="'$(BuildOnlyPgoInstrumentedAssets)' != 'true'">true</IsPackable>
@@ -14,16 +14,16 @@
1414
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
1515
<!-- Historically, the key for the managed projects is the AspNetCore key Arcade carries. -->
1616
<StrongNameKeyId>MicrosoftAspNetCore</StrongNameKeyId>
17-
<PublicSign Condition=" '$(OS)' != 'Windows_NT' ">true</PublicSign>
17+
<PublicSign Condition="'$(OS)' != 'Windows_NT'">true</PublicSign>
1818
<DefineConstants>$(DefineConstants);HOST_MODEL</DefineConstants>
1919
</PropertyGroup>
2020

21-
<ItemGroup>
22-
<!-- SDK pins this to a lower version https://github.com/dotnet/sdk/issues/43325 -->
23-
<PackageReference Include="System.Reflection.Metadata" Version="$(SystemReflectionMetadataToolsetVersion)" />
24-
<PackageReference Include="System.Memory" Version="$(SystemMemoryVersion)" />
25-
26-
<ProjectReference Include="$(LibrariesProjectRoot)System.Text.Json\src\System.Text.Json.csproj" />
21+
<!-- Manually reference these assemblies which are provided by MSBuild / .NET SDK -->
22+
<ItemGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework'">
23+
<PackageDownloadAndReference Include="System.Collections.Immutable" Version="$(SystemCollectionsImmutableToolsetVersion)" Folder="lib/net462" />
24+
<PackageDownloadAndReference Include="System.Memory" Version="$(SystemMemoryToolsetVersion)" Folder="lib/net461" />
25+
<PackageDownloadAndReference Include="System.Text.Json" Version="$(SystemTextJsonToolsetVersion)" Folder="lib/net462" />
26+
<PackageDownloadAndReference Include="System.Reflection.Metadata" Version="$(SystemReflectionMetadataToolsetVersion)" Folder="lib/net462" />
2727
</ItemGroup>
2828

2929
<ItemGroup>
@@ -35,4 +35,6 @@
3535
<Compile Include="$(CoreClrProjectRoot)tools\Common\System\Collections\Generic\ArrayBuilder.cs" Link="Common\ArrayBuilder.cs" />
3636
</ItemGroup>
3737

38+
<Import Project="$(RepositoryEngineeringDir)PackageDownloadAndReference.targets" />
39+
3840
</Project>

0 commit comments

Comments
 (0)