Skip to content

Commit 5a6b1f3

Browse files
committed
Rely on CommonTargetsPath to detect unknown TargetFramework
1 parent f907e76 commit 5a6b1f3

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

Source/MSBuild.Sdk.Extras/Build/LanguageTargets/CheckMissing.targets

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,16 @@
1111
<_SdkLanguageTargetsMissing Condition="'$(_SdkLanguageTargetsMissing)' == ''">true</_SdkLanguageTargetsMissing>
1212
</PropertyGroup>
1313

14+
<!-- Check if the Common targets have been loaded, see https://github.com/onovotny/MSBuildSdkExtras/pull/186 -->
15+
<!-- https://github.com/microsoft/msbuild/blob/d42d3504057ef2b88dd4f68c4bfc5591371bd6fe/src/Tasks/Microsoft.Common.targets#L32-L43 -->
16+
<PropertyGroup Condition=" '$(CommonTargetsPath)' == '' Or '$(MSBuildVersion)' &gt;= '16.0' ">
17+
<_SdkLanguageTargetsMissing Condition="'$(CommonTargetsPath)'!=''">false</_SdkLanguageTargetsMissing>
18+
<_SdkLanguageTargetsMissing Condition="'$(_SdkLanguageTargetsMissing)' == ''">true</_SdkLanguageTargetsMissing>
19+
</PropertyGroup>
20+
1421
<!-- Check to see if the Lang targets exist and if not, trigger an error on Compile -->
1522
<!-- We clear out the lang targets so the defaults are used for the error to show -->
16-
<PropertyGroup Condition="'$(_ExtrasSkipTargetsCheck)' != 'true' ">
23+
<PropertyGroup Condition="'$(_ExtrasSkipTargetsCheck)' != 'true' and '$(_SdkLanguageTargetsMissing)' == 'true' ">
1724

1825
<!-- Reset LanguageTargets Eval-->
1926
<!-- https://github.com/dotnet/sdk/blob/581f5371dac022ad2b3e5bcdbb2e576bd73b5c4a/src/Tasks/Microsoft.NET.Build.Tasks/sdk/Sdk.targets#L28-L37 -->
@@ -30,7 +37,7 @@
3037

3138
<!-- Import common targets so NuGet restore succeeds -->
3239
<!-- https://github.com/dotnet/sdk/blob/979eed136b786b6e2d77f567eb5a368952982740/src/Tasks/Microsoft.NET.Build.Tasks/sdk/Sdk.targets#L33 -->
33-
<Import Project="$(LanguageTargets)" />
40+
<Import Condition=" '$(_SdkLanguageTargetsMissing)' == 'true' " Project="$(LanguageTargets)" />
3441

3542

3643
<Target Name="_ShowMissingLanguageTargetsError" BeforeTargets="_CheckForUnsupportedTargetFramework" Condition="'$(_SdkLanguageTargetsMissing)' == 'true' and '$(_SdkIgnoreMissingLanguageTargetsError)' != 'true' ">

0 commit comments

Comments
 (0)