Skip to content

Commit b3446e8

Browse files
Extract common PackageReferences for MSBuild tasks into SDKDeliveredMSBuildTask.props
Co-authored-by: rainersigwald <3347530+rainersigwald@users.noreply.github.com>
1 parent e41b8ae commit b3446e8

File tree

5 files changed

+26
-15
lines changed

5 files changed

+26
-15
lines changed

eng/SDKDeliveredMSBuildTask.props

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<!-- Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the MIT license. See License.txt in the project root for full license information. -->
2+
<Project>
3+
4+
<!--
5+
This file contains common package references for MSBuild task assemblies that ship in the SDK.
6+
7+
These packages use VersionOverride to ensure compatibility with MSBuild's binding redirects.
8+
Microsoft.NET.HostModel and other components also use these dependencies, so we need to ensure
9+
that all components can load the same assembly versions.
10+
11+
See MSBuild binding redirect configuration:
12+
https://github.com/dotnet/msbuild/blob/main/src/MSBuild/app.config
13+
-->
14+
15+
<ItemGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework'">
16+
<PackageReference Include="System.Collections.Immutable" VersionOverride="$(SystemCollectionsImmutableToolsetPackageVersion)" />
17+
<PackageReference Include="System.Reflection.Metadata" VersionOverride="$(SystemReflectionMetadataToolsetPackageVersion)" />
18+
<PackageReference Include="System.Reflection.MetadataLoadContext" VersionOverride="$(SystemReflectionMetadataLoadContextToolsetPackageVersion)" />
19+
</ItemGroup>
20+
21+
</Project>

src/RazorSdk/Tasks/Microsoft.NET.Sdk.Razor.Tasks.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
</PropertyGroup>
1111

1212
<Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk" />
13+
<Import Project="$(RepositoryEngineeringDir)SDKDeliveredMSBuildTask.props" />
1314

1415
<PropertyGroup>
1516
<OutputType>Library</OutputType>
@@ -45,7 +46,6 @@
4546
</ItemGroup>
4647

4748
<ItemGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework'">
48-
<PackageReference Include="System.Reflection.Metadata" VersionOverride="$(SystemReflectionMetadataToolsetPackageVersion)" />
4949
<PackageReference Include="System.Text.Json" VersionOverride="$(SystemTextJsonToolsetPackageVersion)" />
5050
</ItemGroup>
5151

src/StaticWebAssetsSdk/Tasks/Microsoft.NET.Sdk.StaticWebAssets.Tasks.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
</PropertyGroup>
1212

1313
<Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk" />
14+
<Import Project="$(RepositoryEngineeringDir)SDKDeliveredMSBuildTask.props" />
1415

1516
<PropertyGroup>
1617
<TargetFrameworks>$(SdkTargetFramework);net472</TargetFrameworks>
@@ -47,7 +48,6 @@
4748
</ItemGroup>
4849

4950
<ItemGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework'">
50-
<PackageReference Include="System.Reflection.Metadata" VersionOverride="$(SystemReflectionMetadataToolsetPackageVersion)" />
5151
<PackageReference Include="System.Text.Json" VersionOverride="$(SystemTextJsonToolsetPackageVersion)" />
5252
<PackageReference Include="System.Diagnostics.DiagnosticSource" VersionOverride="$(SystemDiagnosticsDiagnosticSourceToolsetPackageVersion)" />
5353
</ItemGroup>

src/Tasks/Microsoft.NET.Build.Tasks/Microsoft.NET.Build.Tasks.csproj

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
</PropertyGroup>
88

99
<Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk" />
10+
<Import Project="$(RepositoryEngineeringDir)SDKDeliveredMSBuildTask.props" />
1011

1112
<PropertyGroup>
1213
<Description>The MSBuild targets and properties for building .NET Core projects.</Description>
@@ -73,16 +74,6 @@
7374
<ItemGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework'">
7475
<PackageReference Include="System.Text.Json" />
7576
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" />
76-
77-
<!--
78-
Microsoft.NET.HostModel also uses System.Reflection.Metadata. Don't move ahead of the version of System.Reflection.Metadata
79-
that MSBuild supports with the binding redirect to ensure that both this project and Microsoft.NET.HostModel can load
80-
the same System.Reflection.Metadata assembly and their types can unify. See the following link for the MSBuild binding redirect config.
81-
https://github.com/dotnet/msbuild/blob/299e0514835a1588e6ef21b1da748462dec706b8/src/MSBuild/app.config#L60
82-
-->
83-
<PackageReference Include="System.Collections.Immutable" VersionOverride="$(SystemCollectionsImmutableToolsetPackageVersion)" />
84-
<PackageReference Include="System.Reflection.Metadata" VersionOverride="$(SystemReflectionMetadataToolsetPackageVersion)" />
85-
<PackageReference Include="System.Reflection.MetadataLoadContext" VersionOverride="$(SystemReflectionMetadataLoadContextToolsetPackageVersion)" />
8677
</ItemGroup>
8778

8879
<!-- These are loaded from the CLI's copy on .NET Core, we don't need to duplicate them on disk -->

src/Tasks/sdk-tasks/sdk-tasks.csproj

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
77
</PropertyGroup>
88

9+
<Import Project="$(RepositoryEngineeringDir)SDKDeliveredMSBuildTask.props" />
10+
911
<ItemGroup>
1012
<Compile Include="$(RepoRoot)\src\Resolvers\Microsoft.NET.Sdk.WorkloadManifestReader\SdkFeatureBand.cs" LinkBase="Common"/>
1113
<Compile Include="$(RepoRoot)src\Common\WorkloadSetVersion.cs" LinkBase="Common" />
@@ -22,9 +24,6 @@
2224
</ItemGroup>
2325

2426
<ItemGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework'">
25-
<PackageReference Include="System.Collections.Immutable" VersionOverride="$(SystemCollectionsImmutableToolsetPackageVersion)" />
26-
<PackageReference Include="System.Reflection.Metadata" VersionOverride="$(SystemReflectionMetadataToolsetPackageVersion)" />
27-
<PackageReference Include="System.Reflection.MetadataLoadContext" VersionOverride="$(SystemReflectionMetadataLoadContextToolsetPackageVersion)" />
2827
<PackageReference Include="System.Resources.Extensions" VersionOverride="$(SystemResourcesExtensionsToolsetPackageVersion)" />
2928
<Reference Include="System.Net.Http" />
3029
</ItemGroup>

0 commit comments

Comments
 (0)