Skip to content

Commit

Permalink
Fixes dotnet#4924
Browse files Browse the repository at this point in the history
* Add conditions to pack buildTransitive .targets for net462 only when net462 is included as a target framework
* Changed the documentation link to the learn.microsoft.com site
  • Loading branch information
iliar-turdushev committed Sep 4, 2024
1 parent 35b0971 commit 60ef8ee
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,25 +39,43 @@
<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).targets"
<None Include="buildTransitive\$(MSBuildProjectName).*"
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).*"
Exclude="buildTransitive\$(MSBuildProjectName).targets"
CopyToOutputDirectory="PreserveNewest"
Pack="true"
PackagePath="buildTransitive\$(MinimumSupportedTfmForPackaging)\" />
PackagePath="buildTransitive\net462\"
Condition="'$(PackNet462)' == 'true'" />

<!-- For net462 we have to rename the .targets file, 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).targets"
CopyToOutputDirectory="PreserveNewest"
Pack="true"
PackagePath="buildTransitive\net462\$(MSBuildProjectName).net462.targets" />
PackagePath="buildTransitive\net462\$(MSBuildProjectName).net462.targets"
Condition="'$(PackNet462)' == '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>
<_AdditionalNETStandardCompatErrorFileContents Condition="'$(PackNet462)' == 'true'">
<![CDATA[
<Import Project="%24(MSBuildThisFileDirectory)\$(MSBuildProjectName).net462.targets" />
]]>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
<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://github.com/dotnet/extensions/tree/main/src/Libraries/Microsoft.Extensions.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 error set SuppressCheckGrpcNetClientFactoryVersion=true.</_GrpcNetClientFactoryVersionIsIncorrect>
</PropertyGroup>

<!--
Check whether the project is referencing Grpc.Net.ClientFactory 2.64.0 or later.
If the vesion is earlier warn the user to update.
See https://github.com/dotnet/extensions/tree/main/src/Libraries/Microsoft.Extensions.Http.Resilience#known-issues for more details.
See https://learn.microsoft.com/en-us/dotnet/core/resilience/http-resilience#known-issues for more details.
-->
<Target Name="_CheckGrpcNetClientFactoryVersion"
BeforeTargets="ResolveReferences"
Expand Down

0 comments on commit 60ef8ee

Please sign in to comment.