Skip to content

Commit

Permalink
Preload System.Text.Json 8.0.0.4
Browse files Browse the repository at this point in the history
This works around dotnet/sdk#43339 by preloading a copy of the assembly
that can't be located with the normal load processes. It should be
harmless (other than wasting time) in circumstances where it's not
necessary.
  • Loading branch information
rainersigwald committed Sep 11, 2024
1 parent d93deee commit 2e8f2dc
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,30 @@
<RemoveDir Directories="$(_PackageFolderInGlobalPackages)"
Condition="Exists('$(_PackageFolderInGlobalPackages)')" />
</Target>

<!-- BEGIN workaround for https://github.com/dotnet/sdk/issues/43339; remove after updated to VS 17.12 or a future 17.11 patch -->
<Target Name="WorkaroundDotnetSdk43339" BeforeTargets="ResolvePackageAssets" Condition=" '$(MSBuildRuntimeType)' == 'Full' and $([MSBuild]::VersionLessThan($(MSBuildVersion), 17.12.0))">
<PrimeSystemTextJson804 />
</Target>
<UsingTask
TaskName="PrimeSystemTextJson804"
TaskFactory="RoslynCodeTaskFactory"
AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.Core.dll" >
<Task>
<Code Type="Fragment" Language="cs">
<![CDATA[
try
{
System.Reflection.Assembly.LoadFrom(@"$(MicrosoftNETBuildTasksDirectoryRoot)\..\..\..\DotnetTools\dotnet-format\BuildHost-net472\System.Text.Json.dll");
}
catch
{
// Best effort: if something moves in the SDK don't break the build.
}
]]>
</Code>
</Task>
</UsingTask>
<!-- END workaround for https://github.com/dotnet/sdk/issues/43339 -->

</Project>

0 comments on commit 2e8f2dc

Please sign in to comment.