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

Commit 6836e4d

Browse files
committed
Only default IncludeFrameworkReferencesInPackage to true for libs
Improves the fix for NuGet/Home#5110
1 parent bd6b554 commit 6836e4d

2 files changed

Lines changed: 22 additions & 13 deletions

File tree

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,8 @@ Copyright (c) .NET Foundation. All rights reserved.
4040
<IncludeSymbolsInPackage Condition="'$(IncludeSymbolsInPackage)' == '' and '$(IncludeOutputsInPackage)' == 'true' and '$(Configuration)' == 'Debug'">true</IncludeSymbolsInPackage>
4141
<!-- Whether to include framework references (%(ReferencePath.ResolvedFrom)' == '{TargetFrameworkDirectory}') in the package -->
4242

43-
<!-- Only default to true if the project isn't a nuget packaging project itself. -->
44-
<_DefaultIncludeFrameworkReferencesInPackage Condition="'$(PrimaryOutputPackageFileKind)' == 'build' Or '$(PrimaryOutputPackageFileKind)' == 'tool' Or '$(PrimaryOutputPackageFileKind)' == 'tools'">false</_DefaultIncludeFrameworkReferencesInPackage>
45-
<_DefaultIncludeFrameworkReferencesInPackage Condition="'$(_DefaultIncludeFrameworkReferencesInPackage)' == ''">true</_DefaultIncludeFrameworkReferencesInPackage>
46-
<IncludeFrameworkReferencesInPackage Condition="'$(IncludeFrameworkReferencesInPackage)' == '' and '$(IsPackagingProject)' != 'true'">$(_DefaultIncludeFrameworkReferencesInPackage)</IncludeFrameworkReferencesInPackage>
43+
<!-- Only default to true if the project isn't a nuget packaging project itself and its primary output is lib. -->
44+
<IncludeFrameworkReferencesInPackage Condition="'$(IncludeFrameworkReferencesInPackage)' == '' and '$(IsPackagingProject)' != 'true' and '$(PrimaryOutputPackageFileKind)' == 'Lib'">true</IncludeFrameworkReferencesInPackage>
4745

4846
<PackageRequireLicenseAcceptance Condition="'$(PackageRequireLicenseAcceptance)' == ''">false</PackageRequireLicenseAcceptance>
4947

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

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,57 +17,68 @@ public class TargetsTests
1717
public TargetsTests(ITestOutputHelper output) => this.output = output;
1818

1919
[Fact]
20-
public void IncludeFrameworkReferencesInPackage_defaults_to_false_for_build_primary_output()
20+
public void IncludeFrameworkReferencesInPackage_is_not_true_for_build_primary_output()
2121
{
2222
var project = new Project("NuGet.Build.Packaging.targets", new Dictionary<string, string>
2323
{
2424
{ "PrimaryOutputPackageFileKind", "build" }
2525
}, "14.0");
2626

27-
Assert.Equal("false", project.GetPropertyValue("IncludeFrameworkReferencesInPackage"));
27+
Assert.NotEqual("true", project.GetPropertyValue("IncludeFrameworkReferencesInPackage"));
2828
}
2929

3030
[Fact]
31-
public void IncludeFrameworkReferencesInPackage_defaults_to_false_for_tool_primary_output()
31+
public void IncludeFrameworkReferencesInPackage_is_not_true_for_tool_primary_output()
3232
{
3333
var project = new Project("NuGet.Build.Packaging.targets", new Dictionary<string, string>
3434
{
3535
{ "PrimaryOutputPackageFileKind", "tool" }
3636
}, "14.0");
3737

38-
Assert.Equal("false", project.GetPropertyValue("IncludeFrameworkReferencesInPackage"));
38+
Assert.NotEqual("true", project.GetPropertyValue("IncludeFrameworkReferencesInPackage"));
3939
}
4040

4141
[Fact]
42-
public void IncludeFrameworkReferencesInPackage_defaults_to_false_for_tools_primary_output()
42+
public void IncludeFrameworkReferencesInPackage_is_not_true_for_tools_primary_output()
4343
{
4444
var project = new Project("NuGet.Build.Packaging.targets", new Dictionary<string, string>
4545
{
4646
{ "PrimaryOutputPackageFileKind", "tools" }
4747
}, "14.0");
4848

49-
Assert.Equal("false", project.GetPropertyValue("IncludeFrameworkReferencesInPackage"));
49+
Assert.NotEqual("true", project.GetPropertyValue("IncludeFrameworkReferencesInPackage"));
5050
}
5151

5252
[Fact]
53-
public void IncludeFrameworkReferencesInPackage_defaults_to_true_for_default_primary_output()
53+
public void IncludeFrameworkReferencesInPackage_is_true_for_primary_output_lib()
5454
{
5555
var project = new Project("NuGet.Build.Packaging.targets", new Dictionary<string, string>
5656
{
57+
{ "PrimaryOutputPackageFileKind", "lib" }
5758
}, "14.0");
5859

5960
Assert.Equal("true", project.GetPropertyValue("IncludeFrameworkReferencesInPackage"));
6061
}
6162

6263
[Fact]
63-
public void IncludeFrameworkReferencesInPackage_defaults_to_false_for_compat_istool()
64+
public void IncludeFrameworkReferencesInPackage_is_true_for_default_primary_output_kind()
65+
{
66+
var project = new Project("NuGet.Build.Packaging.targets", new Dictionary<string, string>
67+
{
68+
}, "14.0");
69+
70+
Assert.Equal("true", project.GetPropertyValue("IncludeFrameworkReferencesInPackage"));
71+
}
72+
73+
[Fact]
74+
public void IncludeFrameworkReferencesInPackage_is_not_true_for_compat_istool()
6475
{
6576
var project = new Project("NuGet.Build.Packaging.targets", new Dictionary<string, string>
6677
{
6778
{ "IsTool", "true" }
6879
}, "14.0");
6980

70-
Assert.Equal("false", project.GetPropertyValue("IncludeFrameworkReferencesInPackage"));
81+
Assert.NotEqual("true", project.GetPropertyValue("IncludeFrameworkReferencesInPackage"));
7182
}
7283

7384
[Fact]

0 commit comments

Comments
 (0)