Skip to content

Commit

Permalink
Fixes dotnet#4924
Browse files Browse the repository at this point in the history
* Changes the level of the compatibility log messages from Error to Warning
* Updates the logic of copying buildTransitive files
  • Loading branch information
iliar-turdushev committed Sep 5, 2024
1 parent f219224 commit 51721ad
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 39 deletions.
8 changes: 5 additions & 3 deletions eng/MSBuild/Packaging.targets
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,17 @@
<PropertyGroup>
<IsPackable Condition="'$(Stage)' == ''">false</IsPackable>
<BeforePack>$(BeforePack);_VerifyMinimumSupportedTfmForPackagingIsUsed;_AddNETStandardCompatErrorFileForPackaging</BeforePack>
<IsPackNet462 Condition="'$(MinimumSupportedTfmForPackaging)' != '' and
'$(ConditionalNet462)' != '' and
($(TargetFrameworks.Contains('$(MinimumSupportedTfmForPackaging)')) and $(TargetFrameworks.Contains('$(ConditionalNet462)')))"
>true</IsPackNet462>
</PropertyGroup>

<!-- Include a compat warning for users trying to use our packages on unsupported TFMs -->
<ItemGroup>
<NETStandardCompatError Include="$(ConditionalNet462)"
Supported="$(MinimumSupportedTfmForPackaging)"
Condition="'$(MinimumSupportedTfmForPackaging)' != '' and
'$(ConditionalNet462)' != '' and
($(TargetFrameworks.Contains('$(MinimumSupportedTfmForPackaging)')) and $(TargetFrameworks.Contains('$(ConditionalNet462)')))" />
Condition="'$(IsPackNet462)' == 'true'" />
</ItemGroup>

<PropertyGroup Condition=" '$(IsPackable)' == 'true' and '$(IsShipping)' == 'true' ">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,43 +39,35 @@
<InternalsVisibleToDynamicProxyGenAssembly2 Include="*" />
</ItemGroup>

<PropertyGroup>
<!-- Defines whether we need to pack buildTransitive artifacts for net462. -->
<PackNet462 Condition=" '$(MinimumSupportedTfmForPackaging)' != '' and
'$(ConditionalNet462)' != '' and
($(TargetFrameworks.Contains('$(MinimumSupportedTfmForPackaging)')) and $(TargetFrameworks.Contains('$(ConditionalNet462)'))) "
>true</PackNet462>
</PropertyGroup>

<ItemGroup>
<None Include="buildTransitive\$(MSBuildProjectName).*"
<None Include="buildTransitive\**\*"
CopyToOutputDirectory="PreserveNewest"
Pack="true"
PackagePath="buildTransitive\$(MinimumSupportedTfmForPackaging)\"
Condition="'$(MinimumSupportedTfmForPackaging)' != '' and $(TargetFrameworks.Contains('$(MinimumSupportedTfmForPackaging)'))" />

<!-- For net462 we copy all buildTransitive files except the .targets file. We have to rename the .targets file
when copying it because our build process automatically adds a .targets file with the same name as the project
file. Then we'll import the renamed .targets file in the automatically added .targets file. For that we need
to set the _AdditionalNETStandardCompatErrorFileContents variable. -->
<None Include="buildTransitive\$(MSBuildProjectName).*"
to set the _AdditionalNETStandardCompatErrorFileContents variable. -->
<None Include="buildTransitive\**\*"
Exclude="buildTransitive\$(MSBuildProjectName).targets"
CopyToOutputDirectory="PreserveNewest"
Pack="true"
PackagePath="buildTransitive\net462\"
Condition="'$(PackNet462)' == 'true'" />
Condition="'$(IsPackNet462)' == 'true'" />

<None Include="buildTransitive\$(MSBuildProjectName).targets"
CopyToOutputDirectory="PreserveNewest"
Pack="true"
PackagePath="buildTransitive\net462\$(MSBuildProjectName).net462.targets"
Condition="'$(PackNet462)' == 'true'" />
Condition="'$(IsPackNet462)' == 'true'" />
</ItemGroup>

<!-- For net462 we automatically add the .targets file, and to include the code that checks the version of the
Grpc.Net.ClientFactory package we need to set the _AdditionalNETStandardCompatErrorFileContents variable. -->
<PropertyGroup>
<_AdditionalNETStandardCompatErrorFileContents Condition="'$(PackNet462)' == 'true'">
<_AdditionalNETStandardCompatErrorFileContents>
<![CDATA[
<Import Project="%24(MSBuildThisFileDirectory)\$(MSBuildProjectName).net462.targets" />
]]>
Expand Down
4 changes: 2 additions & 2 deletions src/Libraries/Microsoft.Extensions.Http.Resilience/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ System.InvalidOperationException: The ConfigureHttpClient method is not supporte
To resolve this issue, we recommend upgrading to `Grpc.Net.ClientFactory` version `2.64.0` or later.

We've implemented a build time check that verifies if you're using `Grpc.Net.ClientFactory` version
`2.63.0` or earlier, and if you are the check produces a compilation error. You can suppress the
check and the error by setting the following property in your project file:
`2.63.0` or earlier, and if you are the check produces a compilation warning. You can suppress the
warning by setting the following property in your project file:

```xml
<PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<_GrpcNetClientFactory>Grpc.Net.ClientFactory</_GrpcNetClientFactory>
<_CompatibleGrpcNetClientFactoryVersion>2.64.0</_CompatibleGrpcNetClientFactoryVersion>
<_GrpcNetClientFactoryVersionIsIncorrect>Grpc.Net.ClientFactory 2.63.0 or earlier could cause issues when used together with Microsoft.Extensions.Http.Resilience. For more details, see https://learn.microsoft.com/en-us/dotnet/core/resilience/http-resilience#known-issues. Consider using Grpc.Net.ClientFactory $(_CompatibleGrpcNetClientFactoryVersion) or later. To suppress the error set SuppressCheckGrpcNetClientFactoryVersion=true.</_GrpcNetClientFactoryVersionIsIncorrect>
<_GrpcNetClientFactoryVersionIsIncorrect>Grpc.Net.ClientFactory 2.63.0 or earlier could cause issues when used together with Microsoft.Extensions.Http.Resilience. For more details, see https://learn.microsoft.com/en-us/dotnet/core/resilience/http-resilience#known-issues. Consider using Grpc.Net.ClientFactory $(_CompatibleGrpcNetClientFactoryVersion) or later. To suppress the warning set SuppressCheckGrpcNetClientFactoryVersion=true.</_GrpcNetClientFactoryVersionIsIncorrect>
</PropertyGroup>

<!--
Expand All @@ -25,29 +25,30 @@
</ItemGroup>

<!-- The version of the package is included in the .csproj file. -->
<Error Condition=" @(_GrpcNetClientFactoryPackageReference->Count()) &gt; 0
AND '%(_GrpcNetClientFactoryPackageReference.Version)' != ''
AND $([MSBuild]::VersionLessThan('%(_GrpcNetClientFactoryPackageReference.Version)', '$(_CompatibleGrpcNetClientFactoryVersion)')) "
Text="$(_GrpcNetClientFactoryVersionIsIncorrect)" />
<Warning Condition=" @(_GrpcNetClientFactoryPackageReference->Count()) &gt; 0
AND '%(_GrpcNetClientFactoryPackageReference.Version)' != ''
AND $([MSBuild]::VersionLessThan('%(_GrpcNetClientFactoryPackageReference.Version)', '$(_CompatibleGrpcNetClientFactoryVersion)')) "
Text="$(_GrpcNetClientFactoryVersionIsIncorrect)" />

<!-- The solution uses the Central Package Management and the version of the package is overridden in the .csproj file using the VersionOverride property. -->
<Error Condition=" '$(ManagePackageVersionsCentrally)' == 'true'
AND @(_GrpcNetClientFactoryPackageReference->Count()) &gt; 0
AND '%(_GrpcNetClientFactoryPackageReference.VersionOverride)' != ''
AND $([MSBuild]::VersionLessThan('%(_GrpcNetClientFactoryPackageReference.VersionOverride)', '$(_CompatibleGrpcNetClientFactoryVersion)')) "
Text="$(_GrpcNetClientFactoryVersionIsIncorrect)" />
<Warning Condition=" '$(ManagePackageVersionsCentrally)' == 'true'
AND @(_GrpcNetClientFactoryPackageReference->Count()) &gt; 0
AND '%(_GrpcNetClientFactoryPackageReference.VersionOverride)' != ''
AND $([MSBuild]::VersionLessThan('%(_GrpcNetClientFactoryPackageReference.VersionOverride)', '$(_CompatibleGrpcNetClientFactoryVersion)')) "
Text="$(_GrpcNetClientFactoryVersionIsIncorrect)" />

<!-- The solution uses the Central Package Management and the version of the package is included in the Central Package Source. -->
<Error Condition=" '$(ManagePackageVersionsCentrally)' == 'true'
AND @(_GrpcNetClientFactoryPackageReference->Count()) &gt; 0
AND '%(_GrpcNetClientFactoryPackageVersion.Version)' != ''
AND $([MSBuild]::VersionLessThan('%(_GrpcNetClientFactoryPackageVersion.Version)', '$(_CompatibleGrpcNetClientFactoryVersion)')) "
Text="$(_GrpcNetClientFactoryVersionIsIncorrect)" />
<Warning Condition=" '$(ManagePackageVersionsCentrally)' == 'true'
AND @(_GrpcNetClientFactoryPackageReference->Count()) &gt; 0
AND '%(_GrpcNetClientFactoryPackageVersion.Version)' != ''
AND $([MSBuild]::VersionLessThan('%(_GrpcNetClientFactoryPackageVersion.Version)', '$(_CompatibleGrpcNetClientFactoryVersion)')) "
Text="$(_GrpcNetClientFactoryVersionIsIncorrect)" />

<!-- This condition handles a case when the package is added to the project as a transitive dependency. -->
<Error Condition=" @(_GrpcNetClientFactoryTransitiveDependency->Count()) &gt; 0
AND '%(_GrpcNetClientFactoryTransitiveDependency.NuGetPackageVersion)' != ''
AND $([MSBuild]::VersionLessThan('%(_GrpcNetClientFactoryTransitiveDependency.NuGetPackageVersion)', '$(_CompatibleGrpcNetClientFactoryVersion)')) "
Text="$(_GrpcNetClientFactoryVersionIsIncorrect)" />
<Warning Condition=" @(_GrpcNetClientFactoryPackageReference->Count()) == 0
AND @(_GrpcNetClientFactoryTransitiveDependency->Count()) &gt; 0
AND '%(_GrpcNetClientFactoryTransitiveDependency.NuGetPackageVersion)' != ''
AND $([MSBuild]::VersionLessThan('%(_GrpcNetClientFactoryTransitiveDependency.NuGetPackageVersion)', '$(_CompatibleGrpcNetClientFactoryVersion)')) "
Text="$(_GrpcNetClientFactoryVersionIsIncorrect)" />
</Target>
</Project>

0 comments on commit 51721ad

Please sign in to comment.