-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clean up STJ references Fixes #39902 #40645
base: main
Are you sure you want to change the base?
Conversation
@@ -91,7 +91,7 @@ | |||
</ItemGroup> | |||
|
|||
<ItemGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework'"> | |||
<PackageReference Include="System.Text.Json" VersionOverride="8.0.0" /> | |||
<PackageReference Include="System.Text.Json" VersionOverride="$(SystemTextJsonPackageVersion)" Condition="'$(TargetFramework)' == 'net472'"/> |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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.
eng/Versions.props
Outdated
@@ -78,7 +78,7 @@ | |||
<SystemSecurityCryptographyXmlPackageVersion>8.0.0</SystemSecurityCryptographyXmlPackageVersion> | |||
<SystemSecurityPermissionsPackageVersion>8.0.0</SystemSecurityPermissionsPackageVersion> | |||
<SystemServiceProcessServiceControllerVersion>8.0.0</SystemServiceProcessServiceControllerVersion> | |||
<SystemTextJsonPackageVersion>8.0.2</SystemTextJsonPackageVersion> | |||
<SystemTextJsonPackageVersion>8.0.0</SystemTextJsonPackageVersion> |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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:
- 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 - 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.
- 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.
There was a problem hiding this comment.
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" /> |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
@@ -23,6 +23,7 @@ | |||
<Using Remove="Microsoft.NET.TestFramework.Utilities" /> | |||
<Using Remove="Xunit" /> | |||
<Using Remove="Xunit.Abstractions" /> | |||
<PackageReference Include="System.Text.Json" VersionOverride="$(SystemTextJsonPackageVersion)" /> |
There was a problem hiding this comment.
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
@@ -25,7 +25,9 @@ | |||
</ItemGroup> | |||
|
|||
<ItemGroup> | |||
<PackageReference Include="System.Text.Json" Condition="'$(UseSystemTextJson)'=='True'" /> | |||
<PackageReference Include="System.Text.Json" |
There was a problem hiding this comment.
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)
@@ -47,6 +47,7 @@ | |||
<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'"/> |
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
@@ -23,6 +23,7 @@ | |||
<Using Remove="Microsoft.NET.TestFramework.Utilities" /> | |||
<Using Remove="Xunit" /> | |||
<Using Remove="Xunit.Abstractions" /> | |||
<PackageReference Include="System.Text.Json" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you know why this was needed?
@@ -47,6 +47,7 @@ | |||
<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="$(SystemTextJsonBasePackageVersion)" Condition="'$(TargetFramework)' == 'net472'"/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why was this needed?
<!-- Netfx version builds against the lowest version of System.Text.Json that's guaranteed to be shipped with MSBuild in VS --> | ||
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" VersionOverride="8.0.0" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was confused in looking at the 8.0.4xx-targeted version, as this wasn't needed then...but that's because it was using Newtonsoft.Json instead. Apparently it was fully switched to STJ, so now it became a problem. Thanks for catching that 🙂
<ItemGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework'"> | ||
<PackageReference Include="System.Reflection.Metadata" VersionOverride="$(SystemReflectionMetadataVersion)" /> | ||
<PackageReference Include="System.Text.Json" /> | ||
<PackageReference Include="System.Text.Json" Condition="'$(TargetFramework)'=='net472'" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
revert?
@@ -25,7 +25,7 @@ | |||
<BuildOutputInPackage Include="@(ReferenceCopyLocalPaths->WithMetadataValue('ReferenceSourceTarget', 'ProjectReference'))" /> | |||
</ItemGroup> | |||
</Target> | |||
|
|||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
eng/Versions.props
Outdated
@@ -157,6 +157,7 @@ | |||
<SystemSecurityPermissionsPackageVersion>9.0.0-preview.7.24366.18</SystemSecurityPermissionsPackageVersion> | |||
<SystemTextEncodingCodePagesPackageVersion>9.0.0-preview.7.24366.18</SystemTextEncodingCodePagesPackageVersion> | |||
<SystemTextJsonPackageVersion>9.0.0-preview.7.24366.18</SystemTextJsonPackageVersion> | |||
<SystemTextJsonBasePackageVersion>8.0.0</SystemTextJsonBasePackageVersion> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does "Base" stand for here? You might want to add a comment.
Consider using |
eng/Versions.props
Outdated
<!-- This is a minimum version for various projects to work. It's used for netfx-targeted components that run in Visual Studio | ||
because in those cases, Visual Studio is providing System.Text.Json, and we should work with whichever version it ships. --> | ||
<SystemTextJsonBasePackageVersion>8.0.4</SystemTextJsonBasePackageVersion> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bumping the netfx reference to 8.0.4 will fail to satisfy this constraint for VS 17.11. That's bad, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
8.0.3 should be fine, right? I would assume 8.0.3 is better than 8.0.0.
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