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
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -197,3 +197,6 @@ launchSettings.json
# include the test packages
!test/EndToEnd/Packages/**/*
!test/EndToEnd/ProjectTemplates/**/*.pfx

.idea
.ionide
7 changes: 0 additions & 7 deletions build/packages.targets
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,12 @@
<PackageReference Update="Microsoft.Web.Xdt" Version="2.1.2" />
<PackageReference Update="Newtonsoft.Json" Version="$(NewtonsoftJsonPackageVersion)" />
<PackageReference Update="System.Collections.Immutable" Version="1.5.0" />
<PackageReference Update="System.Diagnostics.Process" Version="$(SystemPackagesVersion)" />
<PackageReference Update="System.Dynamic.Runtime" Version="$(SystemPackagesVersion)" />
<PackageReference Update="System.Runtime.Serialization.Formatters" Version="$(SystemPackagesVersion)" />
<PackageReference Update="System.Runtime.Serialization.Primitives" Version="$(SystemPackagesVersion)" />
<PackageReference Update="System.Security.Cryptography.Pkcs" Version="$(PatchedSystemPackagesVersion)" />
<PackageReference Update="System.Security.Cryptography.Cng" Version="$(PatchedSystemPackagesVersion)" />
<PackageReference Update="System.Security.Cryptography.ProtectedData" Version="$(SystemPackagesVersion)" />
<PackageReference Update="System.Threading.Tasks.Dataflow" Version="4.9.0" />
<PackageReference Update="System.Threading.Thread" Version="$(SystemPackagesVersion)" />
<PackageReference Update="VSLangProj" Version="7.0.3300" />
<PackageReference Update="VSLangProj110" Version="11.0.61030" />
<PackageReference Update="VSLangProj157" Version="15.7.0" />
Expand Down Expand Up @@ -102,10 +99,6 @@
<PackageReference Update="Moq" Version="$(MoqVersion)" />
<PackageReference Update="NuGet.Core" Version="2.14.0-rtm-832" />
<PackageReference Update="Portable.BouncyCastle" Version="1.8.1.3" />
<PackageReference Update="System.Diagnostics.TraceSource" Version="$(SystemPackagesVersion)" />
<PackageReference Update="System.IO.Compression.ZipFile" Version="$(SystemPackagesVersion)" />
<PackageReference Update="System.Runtime.Loader" Version="$(SystemPackagesVersion)" />
<PackageReference Update="System.Threading.Tasks.Parallel" Version="$(SystemPackagesVersion)" />
<PackageReference Update="Xunit.StaFact" Version="0.2.9" />
<PackageReference Update="xunit" Version="$(XunitVersion)" />
<PackageReference Update="xunit.runner.visualstudio" Version="$(XunitVersion)" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.CommandLineUtils" />
<PackageReference Include="System.Runtime.Serialization.Primitives" />
</ItemGroup>

<!-- Microsoft.Build.Locator is needed when debugging, but should not be used in the assemblies we insert.
Expand Down
5 changes: 0 additions & 5 deletions src/NuGet.Core/NuGet.Common/NuGet.Common.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,6 @@
<Reference Include="System.IO.Compression" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == '$(NetStandardVersion)' ">
<PackageReference Include="System.Diagnostics.Process" />
<PackageReference Include="System.Threading.Thread" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\NuGet.Frameworks\NuGet.Frameworks.csproj" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@

<ItemGroup>
<ProjectReference Include="$(NuGetCoreSrcDirectory)\NuGet.Protocol\NuGet.Protocol.csproj" />
<PackageReference Include="System.Runtime.Serialization.Formatters" Condition=" '$(IsCore)' == 'true' " />
</ItemGroup>

<ItemGroup>
Expand Down
6 changes: 2 additions & 4 deletions src/NuGet.Core/NuGet.Packaging/NuGet.Packaging.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project>
<Project>
<PropertyGroup>
<RequiresSigningXplatAPIs>true</RequiresSigningXplatAPIs>
</PropertyGroup>
Expand Down Expand Up @@ -48,8 +48,6 @@
</ItemGroup>

<ItemGroup Condition=" '$(IsCore)' == 'true' ">
<PackageReference Include="System.Dynamic.Runtime" />
<!-- TODO - remove this when temporary patching is no longer necessary. See https://github.com/nuget/home/issues/8952 -->
<PackageReference Include="System.Security.Cryptography.Pkcs" />
<PackageReference Include="System.Security.Cryptography.Cng" />
teo-tsirpanis marked this conversation as resolved.
Show resolved Hide resolved
</ItemGroup>
Expand Down Expand Up @@ -95,7 +93,7 @@
<LastGenOutput>NuGetResources.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>

<Import Project="$(BuildCommonDirectory)common.targets" />
<Import Project="Sdk.targets" Sdk="Microsoft.NET.Sdk" />
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,14 @@
<ProjectReference Include="..\NuGet.DependencyResolver.Core\NuGet.DependencyResolver.Core.csproj" />
</ItemGroup>

<ItemGroup Condition=" '$(IsCore)' == 'true' ">
<PackageReference Include="System.Dynamic.Runtime" />
<PackageReference Include="System.Threading.Thread" />
</ItemGroup>

<ItemGroup>
<Compile Update="Strings.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>Strings.resx</DependentUpon>
</Compile>
</ItemGroup>

<ItemGroup>
<EmbeddedResource Update="Strings.resx">
<Generator>ResXFileCodeGenerator</Generator>
Expand Down
8 changes: 2 additions & 6 deletions src/NuGet.Core/NuGet.Protocol/NuGet.Protocol.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
<DependentUpon>Strings.resx</DependentUpon>
</Compile>
</ItemGroup>

<ItemGroup>
<EmbeddedResource Update="Strings.resx">
<Generator>ResXFileCodeGenerator</Generator>
Expand All @@ -50,10 +50,6 @@
<Reference Include="System.IO.Compression" />
</ItemGroup>

<ItemGroup Condition=" '$(IsCore)' == 'true' ">
<PackageReference Include="System.Dynamic.Runtime" />
</ItemGroup>

<Import Project="$(BuildCommonDirectory)common.targets" />
<Import Project="Sdk.targets" Sdk="Microsoft.NET.Sdk" />
</Project>
</Project>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project>
<Project>
<PropertyGroup>
<RequiresSigningXplatAPIs>true</RequiresSigningXplatAPIs>
</PropertyGroup>
Expand All @@ -23,10 +23,6 @@
<ProjectReference Include="$(TestUtilitiesDirectory)Test.Utility\Test.Utility.csproj" />
</ItemGroup>

<ItemGroup Condition=" '$(IsCore)' == 'true' ">
<PackageReference Include="System.Diagnostics.TraceSource" Version="$(SystemPackagesVersion)" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == '$(NETFXTargetFramework)' ">
<Reference Include="System.IO.Compression" />
<Reference Include="System.Net.Http" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), 'README.md'))\build\common.test.props" />
<Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk" />

<PropertyGroup>
<TargetFrameworks>$(TargetFrameworksExe)</TargetFrameworks>
<TargetFrameworks Condition=" '$(IsXPlat)' == 'true' ">$(NETCoreTargetFrameworks)</TargetFrameworks>
Expand All @@ -25,7 +25,6 @@
</ItemGroup>

<ItemGroup Condition=" '$(IsCore)' == 'true' ">
<PackageReference Include="System.Diagnostics.TraceSource" />
<PackageReference Include="Microsoft.Build.Framework" PrivateAssets="All" />
<PackageReference Include="Microsoft.Build.Tasks.Core" PrivateAssets="All" />
<PackageReference Include="Microsoft.Build.Utilities.Core" PrivateAssets="All" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="System.Diagnostics.TraceSource" />
<PackageReference Include="Microsoft.Build.Framework" PrivateAssets="All" />
<PackageReference Include="Microsoft.Build.Tasks.Core" PrivateAssets="All" />
<PackageReference Include="Microsoft.Build.Utilities.Core" PrivateAssets="All" />
Expand Down Expand Up @@ -55,7 +54,7 @@
<LastGenOutput>TestStrings.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>

<Import Project="$(BuildCommonDirectory)common.targets" />
<Import Project="Sdk.targets" Sdk="Microsoft.NET.Sdk" />
</Project>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project>
<Project>
<PropertyGroup>
<RequiresSigningXplatAPIs>true</RequiresSigningXplatAPIs>
</PropertyGroup>
Expand All @@ -19,10 +19,6 @@
<ProjectReference Include="..\NuGet.Configuration.Test\NuGet.Configuration.Test.csproj" />
</ItemGroup>

<ItemGroup Condition=" '$(IsCore)' == 'true' ">
<PackageReference Include="System.Diagnostics.TraceSource" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == '$(NETFXTargetFramework)' ">
<Reference Include="System.IO.Compression" />
<Reference Include="System.Net.Http" />
Expand All @@ -36,7 +32,7 @@
<ItemGroup>
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
</ItemGroup>

<Import Project="$(BuildCommonDirectory)common.targets" />
<Import Project="Sdk.targets" Sdk="Microsoft.NET.Sdk" />
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,6 @@
<ProjectReference Include="$(TestUtilitiesDirectory)Test.Utility\Test.Utility.csproj" />
</ItemGroup>

<ItemGroup Condition=" '$(IsCore)' == 'true' ">
<PackageReference Include="System.Threading.Tasks.Parallel" />
<PackageReference Include="System.Threading.Thread" />
<PackageReference Include="System.Diagnostics.TraceSource" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == '$(NETFXTargetFramework)' ">
<Reference Include="System.Net" />
<Reference Include="System.Net.Http" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@
</ItemGroup>

<ItemGroup Condition=" '$(IsCore)' == 'true' ">
<PackageReference Include="System.Diagnostics.TraceSource" />
<PackageReference Include="System.Security.Cryptography.ProtectedData" />
<PackageReference Include="System.Threading.Tasks.Parallel" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == '$(NETFXTargetFramework)' ">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@
<ProjectReference Include="$(TestUtilitiesDirectory)Test.Utility\Test.Utility.csproj" />
</ItemGroup>

<ItemGroup Condition=" '$(IsCore)' == 'true' ">
<PackageReference Include="System.Diagnostics.TraceSource" />
</ItemGroup>

<ItemGroup>
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@
<ProjectReference Include="..\NuGet.Configuration.Test\NuGet.Configuration.Test.csproj" />
</ItemGroup>

<ItemGroup Condition=" '$(IsCore)' == 'true' ">
<PackageReference Include="System.Diagnostics.TraceSource" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == '$(NETFXTargetFramework)' ">
<Reference Include="System.IO.Compression" />
<Reference Include="System.Security" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,15 @@
<ProjectReference Include="$(TestUtilitiesDirectory)Test.Utility\Test.Utility.csproj" />
</ItemGroup>

<ItemGroup Condition=" '$(IsCore)' == 'true' ">
<PackageReference Include="System.Diagnostics.TraceSource" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == '$(NETFXTargetFramework)' ">
<Reference Include="System.IO.Compression" />
<Reference Include="System.Net.Http" />
</ItemGroup>

<ItemGroup>
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
</ItemGroup>

<Import Project="$(BuildCommonDirectory)common.targets" />
<Import Project="Sdk.targets" Sdk="Microsoft.NET.Sdk" />
</Project>
</Project>
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), 'README.md'))\build\common.props" />
<Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk" />

<PropertyGroup>
<SkipShared>true</SkipShared>
<OutputType>Exe</OutputType>
Expand All @@ -12,7 +12,6 @@

<ItemGroup>
<PackageReference Include="Newtonsoft.Json" />
<PackageReference Include="System.Runtime.Loader" />
<PackageReference Include="Microsoft.CodeAnalysis" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" />
</ItemGroup>
Expand All @@ -24,4 +23,4 @@
<PackageReference Update="Microsoft.CodeAnalysis.CSharp" Version="3.0.0" />
</ItemGroup>
<Import Project="Sdk.targets" Sdk="Microsoft.NET.Sdk" />
</Project>
</Project>
9 changes: 8 additions & 1 deletion test/TestExtensions/TestablePlugin/TestablePlugin.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -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 😊 ).

<PackageReference Include="System.Runtime.Extensions" Version="4.3.0" />
<PackageReference Include="System.Text.Encoding.Extensions" Version="4.3.0" />
<PackageReference Include="System.IO.FileSystem.Primitives" Version="4.3.0" />
</ItemGroup>

<Import Project="$(BuildCommonDirectory)common.targets"/>
<Import Project="Sdk.targets" Sdk="Microsoft.NET.Sdk" />
</Project>
</Project>
2 changes: 0 additions & 2 deletions test/TestUtilities/Test.Utility/Test.Utility.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,6 @@
</ItemGroup>

<ItemGroup Condition=" '$(IsCore)' == 'true' ">
<PackageReference Include="System.Diagnostics.Process" />
<PackageReference Include="System.IO.Compression.ZipFile" />
<PackageReference Include="System.Security.Cryptography.Pkcs" />
</ItemGroup>

Expand Down