Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable nullable warnings on .NET Standard and Framework #10677

Merged
merged 1 commit into from
Jul 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,21 @@
<PackageVersion Condition=" '$(PackageVersion)' == '' ">$(Version)</PackageVersion>
</PropertyGroup>

<PropertyGroup>
<!--
Disable nullable warnings when targeting anything other than our supported .NET core version(s).
This condition will be evaluated multiple times in multi-targeted projects hence need to be careful
to only set in the inner builds, not the outer build where only $(TargetFrameworks) is defined.
We still check $(TargetFrameworks) for empty though, because for single-targeted builds we want to
allow nullable warnings regardless of target framework.
-->
<DisableNullableWarnings Condition="'$(DisableNullableWarnings)' == '' AND '$(TargetFrameworks)' != '' AND '$(TargetFramework)' != '' AND '$(TargetFrameworkIdentifier)' != '.NETCoreApp'">true</DisableNullableWarnings>
</PropertyGroup>

<PropertyGroup Condition="'$(DisableNullableWarnings)' == 'true'">
<NoWarn>$(NoWarn);Nullable</NoWarn>
</PropertyGroup>

<Import Project="eng\targets\Packaging.targets" />

<!-- Workaround https://github.com/dotnet/cli/issues/10528 -->
Expand Down