Skip to content
This repository was archived by the owner on Jan 12, 2024. It is now read-only.

Commit dfa20c0

Browse files
committed
Don't pack reference assemblies or NETStandard library package
This improves our detection of the references that come from NETStandard, which changed in v2 and was causing additional files to be included in a package. Fixes NuGet/Home#5800 # Conflicts: # src/Build/NuGet.Build.Packaging.Tests/NuGet.Build.Packaging.Tests.csproj
1 parent 9441713 commit dfa20c0

4 files changed

Lines changed: 29 additions & 8 deletions

File tree

src/Build/NuGet.Build.Packaging.Tasks/NuGet.Build.Packaging.Inference.targets

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ Copyright (c) .NET Foundation. All rights reserved.
131131
</_InferredPackageFile>
132132

133133

134-
<_InferredPackageFile Include="@(PackageReference)" Condition="'%(PackageReference.Identity)' != 'NuGet.Build.Packaging' and '%(PackageReference.PrivateAssets)' != 'all'">
134+
<_InferredPackageFile Include="@(PackageReference)" Condition="'%(PackageReference.Identity)' != 'NuGet.Build.Packaging' and '%(PackageReference.Identity)' != 'NETStandard.Library' and '%(PackageReference.PrivateAssets)' != 'all'">
135135
<Kind>Dependency</Kind>
136136
</_InferredPackageFile>
137137

@@ -159,9 +159,28 @@ Copyright (c) .NET Foundation. All rights reserved.
159159
</ItemGroup>
160160
</Target>
161161

162+
<ItemDefinitionGroup>
163+
<ReferencePath>
164+
<Facade>false</Facade>
165+
<FrameworkFile>false</FrameworkFile>
166+
<NuGetPackageId />
167+
<Pack />
168+
</ReferencePath>
169+
<_ReferenceRelatedPaths>
170+
<Facade>false</Facade>
171+
<FrameworkFile>false</FrameworkFile>
172+
<NuGetPackageId />
173+
<Pack />
174+
</_ReferenceRelatedPaths>
175+
</ItemDefinitionGroup>
176+
162177
<Target Name="_CollectPrimaryOutputRelatedFiles" DependsOnTargets="BuildOnlySettings;ResolveReferences" Returns="@(_PrimaryOutputRelatedFile)">
163178
<ItemGroup>
164-
<_PrimaryOutputRelatedFile Include="@(ReferencePath);@(_ReferenceRelatedPaths)" />
179+
<_PrimaryOutputRelatedFile Include="@(ReferencePath);@(_ReferenceRelatedPaths)"
180+
Condition="'%(NuGetPackageId)' != 'NETStandard.Library' and
181+
'%(Facade)' != 'true' and
182+
'%(FrameworkFile)' != 'true' and
183+
'%(Pack)' != 'false'"/>
165184
</ItemGroup>
166185
</Target>
167186

@@ -171,7 +190,7 @@ Copyright (c) .NET Foundation. All rights reserved.
171190
Returns="@(_InferredPackageFile)"
172191
DependsOnTargets="_CollectPrimaryOutputRelatedFiles">
173192
<ItemGroup>
174-
<_NuGetPackageId Include="@(_PrimaryOutputRelatedFile -> '%(NuGetPackageId)')" />
193+
<_NuGetPackageId Include="@(_PrimaryOutputRelatedFile -> '%(NuGetPackageId)')" Condition="'%(NuGetPackageId)' != 'NETStandard.Library'" />
175194
</ItemGroup>
176195
<PropertyGroup>
177196
<_NuGetPackageId>@(_NuGetPackageId -> Distinct())</_NuGetPackageId>

src/Build/NuGet.Build.Packaging.Tests/Scenarios/Scenario.props

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@
2525

2626
<!-- Used for Dump/Introspect -->
2727
<UseCompiledTasks>true</UseCompiledTasks>
28-
28+
<!-- Skip the GitInfo stuff we inherit -->
29+
<GitThisAssembly>false</GitThisAssembly>
30+
2931
<!-- Avoids warnings from Xamarin global imports.-->
3032
<!--<ImportByWildcardAfterMicrosoftCommonTargets>false</ImportByWildcardAfterMicrosoftCommonTargets>
3133
<ImportByWildcardBeforeMicrosoftCommonTargets>false</ImportByWildcardBeforeMicrosoftCommonTargets>-->

src/Build/NuGet.Build.Packaging.Tests/Scenarios/given_a_packaging_project_with_netstandard/b/b.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
22
<PropertyGroup>
3-
<TargetFramework Condition="'$(CrossTargeting)' != 'true'">netstandard1.6</TargetFramework>
4-
<TargetFrameworks Condition="'$(CrossTargeting)' == 'true'">netstandard1.6;net45</TargetFrameworks>
3+
<TargetFramework Condition="'$(SimulateCrossTargeting)' != 'true'">netstandard1.6</TargetFramework>
4+
<TargetFrameworks Condition="'$(SimulateCrossTargeting)' == 'true'">netstandard1.6;net45</TargetFrameworks>
55
<ProjectGuid>{BBBBBBBB-BBBB-BBBB-BBBB-BBBBBBBBBBBB}</ProjectGuid>
66
</PropertyGroup>
77

src/Build/NuGet.Build.Packaging.Tests/given_a_packaging_project_with_netstandard.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public void can_get_content_from_referenced_single_targeting_netstandard()
1717
{
1818
var result = Builder.BuildScenario(nameof(given_a_packaging_project_with_netstandard),
1919
target: "GetPackageContents",
20-
properties: new { CrossTargeting = "false" },
20+
properties: new { SimulateCrossTargeting = "false" },
2121
//verbosity: Microsoft.Build.Framework.LoggerVerbosity.Diagnostic,
2222
output: output);
2323

@@ -34,7 +34,7 @@ public void can_get_content_from_referenced_cross_targeting_netstandard()
3434
{
3535
var result = Builder.BuildScenario(nameof(given_a_packaging_project_with_netstandard),
3636
target: "GetPackageContents",
37-
properties: new { CrossTargeting = "true" },
37+
properties: new { SimulateCrossTargeting = "true" },
3838
//verbosity: Microsoft.Build.Framework.LoggerVerbosity.Diagnostic,
3939
output: output);
4040

0 commit comments

Comments
 (0)