Skip to content

Conversation

@Forgind
Copy link
Contributor

@Forgind Forgind commented May 2, 2024

Fixes #39902

First commit removes references to S.T.J that shouldn't be necessary because we have our own "WorkloadManifestReader.SystemTextJson" class.

The second commit forces all our package versions to 8.0.0.

I was a bit confused with this logic:
<UseSystemTextJson Condition="'$(TargetFramework)'!='netstandard2.0' And '$(TargetFramework)'!='net472'">True</UseSystemTextJson>

This seems to say that we should use System.Text.Json on core only

@ghost ghost added Area-Infrastructure untriaged Request triage from a team member labels May 2, 2024
@Forgind Forgind changed the title Clean up STJ references Clean up STJ references Fixes #39902 May 2, 2024

<ItemGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework'">
<PackageReference Include="System.Text.Json" VersionOverride="8.0.0" />
<PackageReference Include="System.Text.Json" VersionOverride="$(SystemTextJsonPackageVersion)" Condition="'$(TargetFramework)' == 'net472'"/>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

duplicate condition (previous line covered it)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm just confused why things aren't working the way I'd expect, so I was adding some duplication in case I had missed something, and it didn't work as I'd thought.

<SystemSecurityPermissionsPackageVersion>8.0.0</SystemSecurityPermissionsPackageVersion>
<SystemServiceProcessServiceControllerVersion>8.0.0</SystemServiceProcessServiceControllerVersion>
<SystemTextJsonPackageVersion>8.0.2</SystemTextJsonPackageVersion>
<SystemTextJsonPackageVersion>8.0.0</SystemTextJsonPackageVersion>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This property is used in directory.packages.props so what you're doing here is actually overriding the version used by transitive pinning (so overriding the version for all implicit .net core references). You'll need a separate property to use for pinning to 8.0.0 and let the d.p.props version float to current. Runtime does this too if you see here: https://github.com/dotnet/runtime/blob/main/eng/Versions.props#L137

FYI, I talked to Eric and I'll be prepping a change for 8.0.1xx and 8.0.3xx for how we handle STJ. We'll want that change in 8.0.4xx as well. It depends on a change in runtime so you won't be able to get this PR working in 4xx as it turns out. You should be able to retarget to main, make the above change, apply my changes, and get it sorted out. I'll talk to you offline as it's complicated as there are actually 3 different classes of STJ references, not 2 like I thought.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Following up on this, I believe there are three categories of project that we talked about:

  1. The four task projects should have STJ references with no version override. Razor and static web assets should have a net472 check but build and publish should not. I recommend looking at the 8.0.3xx internal AzDo branches to confirm:
    https://dev.azure.com/dnceng/internal/_git/dotnet-sdk?path=/src/WebSdk/Publish/Tasks/Microsoft.NET.Sdk.Publish.Tasks.csproj&version=GBinternal/release/8.0.3xx&_a=contents
  2. The components we have that build for framework and run in VS should have a reference to STJ for netfx targeting and should have a VersionOverride to version 8.0.0. That's because in these cases, VS is providing STJ and we need to work with whichever version they ship.
  3. No other .net core building projects should have a reference to STJ.

CC @ericstj to confirm. We discussed this in a 1:1 a few weeks ago but didn't write it down so writing it down here now.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This sounds correct. Minimize the places where you ship a copy if you can reference the version provided by your host process.

Explicit System.Text.Json package reference is required for source-build to pick up the live package.
Avoids picking up an old version via transitive dependency from Microsoft.Build or Microsoft.CodeAnalysis.Workspaces.MSBuild.
-->
<PackageReference Include="System.Text.Json" />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably want a review from @tmat but with CPM now enabled, this may not be required anymore like it was before.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having an explicit package reference is no longer required, or removing it is no longer required?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having the explicit reference is no longer required, I think. If I understand the original issue per the comment, a transitive version was picked up that didn't work with source build and adding the explicit reference up-versioned to one that was supported. CPM should do the version change as well.

<Using Remove="Microsoft.NET.TestFramework.Utilities" />
<Using Remove="Xunit" />
<Using Remove="Xunit.Abstractions" />
<PackageReference Include="System.Text.Json" VersionOverride="$(SystemTextJsonPackageVersion)" />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a test so not sure it'll need the version override


<ItemGroup>
<PackageReference Include="System.Text.Json" Condition="'$(UseSystemTextJson)'=='True'" />
<PackageReference Include="System.Text.Json"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one will require more investigation. The conditional above that sets UseSystemTextJson is configured for core only which we don't need a reference for so I think we might be able to just remove it from here but you'd have to confirm the framework build doesn't use STJ (as I know things changed so this property may not be accurately named anymore)

<PackageReference Include="Microsoft.Build" ExcludeAssets="runtime" PrivateAssets="all" />
<PackageReference Include="Microsoft.Build.Utilities.Core" ExcludeAssets="runtime" PrivateAssets="all" />
<PackageReference Include="System.CommandLine" />
<PackageReference Include="System.Text.Json" VersionOverride="$(SystemTextJsonPackageVersion)" Condition="'$(TargetFramework)' == 'net472'"/>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where is SystemTextJsonPackageVersion set and what is it set to? I think it should be 8.0.0 but don't see it in this PR (also the name is really close to what darc will update so it may need a slight update to ensure darc doesn't get confused).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm starting to think the PR to create the specific package versions was never ported to main. I'll need to investigate.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My PR is now in which should enable you to update the minimum version name #41890

@Forgind Forgind marked this pull request as ready for review July 11, 2024 21:45
@Forgind Forgind requested review from a team and vijayrkn as code owners July 11, 2024 21:45
@ViktorHofer
Copy link
Member

@Forgind
Copy link
Contributor Author

Forgind commented Jul 29, 2024

The ubuntu failure appears to be dotnet/source-build#4503

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area-Infrastructure untriaged Request triage from a team member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Clean up our System.Text.Json references

6 participants