Skip to content

Commit b0cf048

Browse files
committed
Restore GetTargetFrameworkProperties temporarily
This is a compat shim, and should be reverted once dotnet/msbuild#1866 is available for use in the SDK. It will not be used with common targets that contain that change.
1 parent 1bf9c81 commit b0cf048

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

src/Tasks/Microsoft.NET.Build.Tasks/build/Microsoft.NET.Sdk.Common.targets

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,5 +103,28 @@ Copyright (c) .NET Foundation. All rights reserved.
103103
</ProjectBuildInstructions>
104104
</ItemGroup>
105105
</Target>
106-
106+
107+
<!-- This target is a compat shim, allowing the SDK to continue to function with older common targets that haven't switched to GetReferenceProperties.
108+
109+
TODO: After the SDK has picked up an MSBuild with https://github.com/Microsoft/msbuild/pull/1866, it should be deleted. -->
110+
<Target Name="GetTargetFrameworkProperties" Returns="TargetFramework=$(NearestTargetFramework);ProjectHasSingleTargetFramework=$(_HasSingleTargetFramework);ProjectIsRidAgnostic=$(_IsRidAgnostic)"
111+
DependsOnTargets="ShouldQueryForProperties">
112+
113+
<PropertyGroup>
114+
<!-- If a ReferringTargetFramework was not specified, and we only have one TargetFramework, then don't try to check compatibility -->
115+
<_SkipNearestTargetFrameworkResolution Condition="'$(TargetFramework)' != '' and '$(ReferringTargetFramework)' == ''">true</_SkipNearestTargetFrameworkResolution>
116+
<NearestTargetFramework Condition="'$(_SkipNearestTargetFrameworkResolution)' == 'true'">$(TargetFramework)</NearestTargetFramework>
117+
118+
<_PossibleTargetFrameworks Condition="'$(TargetFramework)' != ''">$(TargetFramework)</_PossibleTargetFrameworks>
119+
<_PossibleTargetFrameworks Condition="'$(TargetFramework)' == ''">$(TargetFrameworks)</_PossibleTargetFrameworks>
120+
</PropertyGroup>
121+
122+
<GetNearestTargetFramework ReferringTargetFramework="$(ReferringTargetFramework)"
123+
PossibleTargetFrameworks="$(_PossibleTargetFrameworks)"
124+
ProjectFilePath="$(MSBuildProjectFullPath)"
125+
Condition="'$(_SkipNearestTargetFrameworkResolution)' != 'true'">
126+
<Output PropertyName="NearestTargetFramework" TaskParameter="NearestTargetFramework" />
127+
</GetNearestTargetFramework>
128+
</Target>
129+
107130
</Project>

0 commit comments

Comments
 (0)