Skip to content
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

Remove unnecessary NuGet package references. #3449

Merged
merged 7 commits into from
Jul 13, 2020
Merged

Remove unnecessary NuGet package references. #3449

merged 7 commits into from
Jul 13, 2020

Conversation

teo-tsirpanis
Copy link
Contributor

@teo-tsirpanis teo-tsirpanis commented Jun 15, 2020

Bug

Fix

Details: This PR removes packages that are not meant for .NET Standard 2.0, significantly trimming the dependency tree, in a similar way to dotnet/msbuild#5242.

Testing/Validation

Tests Added: No
Reason for not adding tests: No functionality changed
Validation: The CI builds still succeed

@nkolev92
Copy link
Member

nkolev92 commented Jun 26, 2020

Hey @teo-tsirpanis

Thanks for this change.
At this point we're in a stabilization phase, so it'll take us a few days before we are ready to take this PR.

In the meantime would you please rebase as there some added conflicts, because we added support for .NET 5.

Finally, can you please create a tracking issue for this and follow the PR template?

Thanks!

@teo-tsirpanis
Copy link
Contributor Author

Hello @nkolev92, I created an issue, rebased the branch and edited the PR's description.

@zivkan zivkan self-assigned this Jun 29, 2020
@zivkan
Copy link
Member

zivkan commented Jun 29, 2020

@teo-tsirpanis I ran a build, but it's failing restore with package downgrade wanrings that are elevated to errors:

##[error]test\TestExtensions\TestablePlugin\TestablePlugin.csproj(0,0): Error NU1605: Detected package downgrade: System.Collections from 4.3.0 to 4.0.11. Reference the package directly from the project to select a different version. 
##[error]test\TestExtensions\TestablePlugin\TestablePlugin.csproj(0,0): Error NU1605: Detected package downgrade: System.IO.FileSystem.Primitives from 4.3.0 to 4.0.1. Reference the package directly from the project to select a different version. 
##[error]test\TestExtensions\TestablePlugin\TestablePlugin.csproj(0,0): Error NU1605: Detected package downgrade: System.Runtime.Extensions from 4.3.0 to 4.1.0. Reference the package directly from the project to select a different version. 
##[error]test\TestExtensions\TestablePlugin\TestablePlugin.csproj(0,0): Error NU1605: Detected package downgrade: System.Text.Encoding.Extensions from 4.3.0 to 4.0.11. Reference the package directly from the project to select a different version. 

@teo-tsirpanis
Copy link
Contributor Author

@zivkan, the versioning conflicts were caused by an old version of Newtonsoft.Json which does not directly target .NET Standard 2.0. I updated it and restoring works.

@nkolev92
Copy link
Member

@teo-tsirpanis

Unfortunately we can't update the newtonsoft.json version. There are some upstream dependencies of NuGet that are tied to a specific version.

See #3347 and #3383.

If all the warnings are happening in a test utility, I think it's ok to bump the versions for those projects only.

@teo-tsirpanis
Copy link
Contributor Author

OK @nkolev92, I reverted to Newtonsoft.Json 9.0.1.

@zivkan
Copy link
Member

zivkan commented Jul 9, 2020

@teo-tsirpanis sorry about the delays. We've been in a mad rush try to meet a deadline.

The builds are now failing with this error:

##[error]test\TestExtensions\GenerateLicenseList\GenerateLicenseList.csproj(0,0): Error NU1604: Project dependency System.Runtime.Loader does not contain an inclusive lower bound. Include a lower bound in the dependency version to ensure consistent restore results.

@teo-tsirpanis
Copy link
Contributor Author

OK @zivkan, I removed the dependency (it was unnecessary for netcoreapp).

@teo-tsirpanis
Copy link
Contributor Author

teo-tsirpanis commented Jul 10, 2020

All tests passed except of 16. At least one of them (ReadStringArrayAsList_WithSupportedTypes_ReturnsStringArray) failed because in the Greek culture the decimal separator is the comma instead of the dot. Other tests failed because the expected error messages are in Greek and not English. But I hope it will be fine on the CI.

@zivkan
Copy link
Member

zivkan commented Jul 11, 2020

Sorry, I forgot that the .NET 5 SDK had a bug in preview 5 and 6: 070c016 dotnet/sdk#11862

If you make sure your machine has the .NET 5 preview 4 SDK, or one of the nightly preview 7 or 8 SDKs, I think it should be ok. Your branch didn't change any code, only packages, so as long as the code compiles, we should be good. Although I'm interested in which tests failed because of the different number formats, because it sounds like we have a bug, even if it's just in the tests.

If you can revert your change adding the AssemblyMetadataAttribute class, I can run another CI build. It might be worthwhile to rebase on the latest dev branch because I think we might have skipped some flaky tests in the last 25 days.

thanks.

@teo-tsirpanis
Copy link
Contributor Author

Done. By the way, configure.ps1 had downloaded a nightly SDK (preview 7), but anyway.

@zivkan zivkan changed the base branch from dev to release-5.7.x July 11, 2020 11:25
@zivkan zivkan changed the base branch from release-5.7.x to dev July 11, 2020 11:25
@zivkan
Copy link
Member

zivkan commented Jul 11, 2020

I'm not sure what happened but github is now showing 31 commits and 133 files changed.

@teo-tsirpanis
Copy link
Contributor Author

teo-tsirpanis commented Jul 11, 2020

I rebased the branch... 😳

@zivkan
Copy link
Member

zivkan commented Jul 11, 2020

It looks like you merged NuGet's dev branch, rather than rebasing. Since your work was in your fork's dev branch, when you merged NuGet's dev branch, NuGet's dev commits got added after your commits in the commit history, which means all their commits hashes got changed, hence why GitHub says they're changed. I think you should be able to fix it with an interactive rebase. Otherwise feel free to close this PR and open a new one (and use a different branch name, just in case).

@teo-tsirpanis
Copy link
Contributor Author

OK, I cherry-picked each commit into the dev branch. Now it says I want to merge only 5 commits.

Copy link
Member

@nkolev92 nkolev92 left a comment

Choose a reason for hiding this comment

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

This looks great, thanks @teo-tsirpanis!

There's one small change I'd like for you to make before I approve this PR.

@@ -21,6 +21,13 @@
<ProjectReference Include="$(NuGetCoreSrcDirectory)NuGet.Versioning\NuGet.Versioning.csproj" />
</ItemGroup>

<ItemGroup Condition="'$(IsCore)' == 'true'">
<PackageReference Include="System.Collections" Version="4.3.0" />
Copy link
Member

Choose a reason for hiding this comment

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

I'll surprised this did not fail the build.

The versions should remain managed in packages.targets.

There's a section with packages used in test.

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 also surprised it didn't fail the build, but it didn't. This suggests that removing the versions might leave these PackageReferences without a version, in which cause the build might fail. So, my thought is we merge as-is, and we should fix our msbuild files as an engineering improvement, and not burden the contributor for this.

Copy link
Member

Choose a reason for hiding this comment

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

I buy that.
Can we create a follow-up issue first?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Too late, I used the SystemPackagesVersion property.

If I recall correctly, these references stayed because they resolve package version conflicts.

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

@teo-tsirpanis teo-tsirpanis Jul 13, 2020

Choose a reason for hiding this comment

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

I tried it again to build without these references and got this (adjusted for brevity):

error NU1605: Detected package downgrade: System.Collections from 4.3.0 to 4.0.11. Reference the package directly fr
om the project to select a different version.
error NU1605:  Plugin.Testable -> NuGet.Protocol -> NuGet.Packaging -> Newtonsoft.Json 9.0.1 -> System.Xml.ReaderWri
ter 4.0.11 -> System.IO.FileSystem 4.0.1 -> runtime.win.System.IO.FileSystem 4.3.0 -> System.Collections (>= 4.3.0)
error NU1605:  Plugin.Testable -> NuGet.Protocol -> NuGet.Packaging -> Newtonsoft.Json 9.0.1 -> System.Collections (
>= 4.0.11)

Same with the other packages. The real fix was to upgrade Newtonsoft.Json but unfortunately it can't be done at the moment.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@zivkan, it didn't fail the build because the SystemPackagesVersion property is equal to 4.3.0.

Copy link
Member

Choose a reason for hiding this comment

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

As per the issue I linked, our MSBuild targets are supposed to validate that no PackageReference has a Version attribute set before it then applies all the versions. This isn't working, but is out of scope for your PR. Assuming the current build in progress is green, I'll merge this PR and the NuGet team will be responsible for fixing up our MSBuild files (unless someone in the community wants to do it and send a PR 😊 ).

Copy link
Member

@nkolev92 nkolev92 left a comment

Choose a reason for hiding this comment

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

We have a follow up :)

@teo-tsirpanis
Copy link
Contributor Author

Hmm, why is the CI failing? 🤨

@zivkan
Copy link
Member

zivkan commented Jul 13, 2020

One unit test on Windows failed, it looks like a flaky test. A directory was not empty when it was trying to be deleted (I'm guessing cleanup after a test ran). About 5% of Linux build hang, and this build was one of those. I've started a new build.

@zivkan zivkan merged commit abce9cb into NuGet:dev Jul 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Community PRs created by someone not in the NuGet team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove .NET Standard 1.x packages from NuGet SDK packages
3 participants