Skip to content

Commit

Permalink
Ensure generator removal target is for all TFMs
Browse files Browse the repository at this point in the history
  • Loading branch information
layomia committed Apr 7, 2023
1 parent d4275bf commit 9eab1ce
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,10 @@

<PropertyGroup>
<IncludeMultiTargetRoslynComponentTargets>false</IncludeMultiTargetRoslynComponentTargets>
<DisableNETStandardCompatErrors>true</DisableNETStandardCompatErrors>
</PropertyGroup>

<ItemGroup>
<Content Include="buildTransitive\$(MSBuildProjectName).*"
PackagePath="buildTransitive\netstandard2.0\;
buildTransitive\$(NetCoreAppMinimum)\;
buildTransitive\$(NetFrameworkMinimum)\" />
<Content Include="buildTransitive\$(PackageId).targets" PackagePath="buildTransitive\netstandard2.0\" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project>
<Project InitialTargets="NETStandardCompatError_Microsoft_Extensions_Configuration_Binder">
<Target Name="_Microsoft_Extensions_Configuration_BinderRemoveAnalyzer"
Condition="'$(EnableConfigurationBindingGenerator)' != 'true'"
AfterTargets="ResolvePackageDependenciesForBuild;ResolveNuGetPackageAssets">
Expand All @@ -7,4 +7,22 @@
<Analyzer Remove="@(Analyzer->WithMetadataValue('NuGetPackageId', 'Microsoft.Extensions.Configuration.Binder'))" />
</ItemGroup>
</Target>

<!-- Only apply for [net4.6.1] and [netcoreapp2.0, net6.0) -->
<Target Name="NETStandardCompatError_Microsoft_Extensions_Configuration_Binder"
Condition="'$(SuppressTfmSupportBuildWarnings)' == '' AND
(
(
$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net4.6.1')) AND
!$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net4.6.2'))
)
OR
(
$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'netcoreapp2.0')) AND
!$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net6.0'))
)
)
">
<Warning Text="Microsoft.Extensions.Configuration.Binder doesn't support $(TargetFramework) and has not been tested with it. Consider upgrading your TargetFramework to net6.0 or later. You may also set &lt;SuppressTfmSupportBuildWarnings&gt;true&lt;/SuppressTfmSupportBuildWarnings&gt; in the project file to ignore this warning and attempt to run in this unsupported configuration at your own risk." />
</Target>
</Project>

0 comments on commit 9eab1ce

Please sign in to comment.