Skip to content

Commit

Permalink
Add warning when targeting net standard less then 2.0 (dotnet#41660)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcpopMSFT authored Jun 24, 2024
2 parents bf8d986 + 7153232 commit c6129dc
Show file tree
Hide file tree
Showing 16 changed files with 205 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/Tasks/Common/Resources/Strings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -948,5 +948,9 @@ You may need to build the project on another operating system or architecture, o
<value>NETSDK1214: PreferNativeArm64 applies only to .NET Framework targets. It is not supported and has no effect for when targeting .NET Core.</value>
<comment>{StrBegin="NETSDK1214: "}</comment>
</data>
<!-- The latest message added is Net8NotCompatibleWithDev177. Please update this value with each PR to catch parallel PRs both adding a new message -->
<data name="TargetFrameworkIsNotRecommended" xml:space="preserve">
<value>NETSDK1215: Targeting .NET Standard prior to 2.0 is no longer recommended. See {0} for more details.</value>
<comment>{StrBegin="NETSDK1215: "}</comment>
</data>
<!-- The latest message added is TargetFrameworkIsNotRecommended. Please update this value with each PR to catch parallel PRs both adding a new message -->
</root>
5 changes: 5 additions & 0 deletions src/Tasks/Common/Resources/xlf/Strings.cs.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/Tasks/Common/Resources/xlf/Strings.de.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/Tasks/Common/Resources/xlf/Strings.es.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/Tasks/Common/Resources/xlf/Strings.fr.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/Tasks/Common/Resources/xlf/Strings.it.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/Tasks/Common/Resources/xlf/Strings.ja.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/Tasks/Common/Resources/xlf/Strings.ko.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/Tasks/Common/Resources/xlf/Strings.pl.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/Tasks/Common/Resources/xlf/Strings.pt-BR.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/Tasks/Common/Resources/xlf/Strings.ru.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/Tasks/Common/Resources/xlf/Strings.tr.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/Tasks/Common/Resources/xlf/Strings.zh-Hans.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/Tasks/Common/Resources/xlf/Strings.zh-Hant.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ Copyright (c) .NET Foundation. All rights reserved.
</PropertyGroup>

<!--
Trigger an error if targeting a higher version of .NET Core or .NET Standard than is supported by the current SDK.
Trigger an error if targeting a higher version of .NET Core than is supported by the current SDK.
-->
<Target Name="_CheckForUnsupportedNETCoreVersion" BeforeTargets="_CheckForInvalidConfigurationAndPlatform;Restore;CollectPackageReferences"
Condition="'$(TargetFrameworkIdentifier)' == '.NETCoreApp' And '$(NETCoreAppMaximumVersion)' != ''">
Expand All @@ -174,6 +174,21 @@ Copyright (c) .NET Foundation. All rights reserved.
/>
</Target>

<!--
Trigger a warning if targeting a lower version of .NET Standard than is recommended
-->
<Target Name="_CheckForNotRecommendedNETStandardVersion" BeforeTargets="_CheckForInvalidConfigurationAndPlatform;Restore;CollectPackageReferences"
Condition="'$(TargetFrameworkIdentifier)' == '.NETStandard' and $([MSBuild]::VersionLessThan($(TargetFrameworkVersion), '2.0'))">
<PropertyGroup>
<!-- Default the check to true, but allow developers to turn the warning off. -->
<CheckNotRecommendedTargetFramework Condition="'$(CheckNotRecommendedTargetFramework)' == ''" >true</CheckNotRecommendedTargetFramework>
</PropertyGroup>

<NETSdkWarning Condition="'$(CheckNotRecommendedTargetFramework)' == 'true'"
ResourceName="TargetFrameworkIsNotRecommended"
FormatArguments="https://aka.ms/dotnet/dotnet-standard-guidance" />
</Target>

<!--
Trigger an error if C++ project targeting a lower version of .NET Core than 3.1.
-->
Expand Down
Loading

0 comments on commit c6129dc

Please sign in to comment.