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

🗑️ Add support for compatibility SuppressDependenciesWhenPacking property #68

Merged
merged 1 commit into from
Mar 28, 2021
Merged
Show file tree
Hide file tree
Changes from all 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
13 changes: 12 additions & 1 deletion src/NuGetizer.Tasks/NuGetizer.Compatibility.props
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ WARNING: DO NOT MODIFY this file unless you are knowledgeable about MSBuild and
This file brings SDK Pack compatibility conversions so that NuGetizer works with SDK Pack
properties and items as much as possible, to ease migration.

NOTE: this file is imported from NuGetizer.Shared.targets, so it comes *after* project
properties.

Copyright (c) .NET Foundation. All rights reserved.
***********************************************************************************************
-->
Expand All @@ -23,12 +26,20 @@ Copyright (c) .NET Foundation. All rights reserved.
<PackCompile Condition="'$(PackCompile)' == '' and '$(IncludeSource)' != ''">$(IncludeSource)</PackCompile>
<PackBuildOutput Condition="'$(PackBuildOutput)' == '' and '$(IncludeBuildOutput)' != ''">$(IncludeBuildOutput)</PackBuildOutput>
<Description Condition="'$(Description)' == '' and '$(PackageDescription)' != ''">$(PackageDescription)</Description>

<PackFrameworkReferences Condition="'$(PackFrameworkReferences)' == '' and '$(SuppressDependenciesWhenPacking)' == 'true'">false</PackFrameworkReferences>
</PropertyGroup>

<ItemDefinitionGroup Condition="'$(SuppressDependenciesWhenPacking)' == 'true'">
<PackageReference>
<Pack>false</Pack>
</PackageReference>
</ItemDefinitionGroup>

<PropertyGroup Label="Legacy NuGetizer Compat">
<PackFolder Condition="'$(PackFolder)' == '' and '$(BuildOutputKind)' != ''">$(BuildOutputKind)</PackFolder>
<PackFolder Condition="'$(PackFolder)' == '' and '$(PrimaryOutputKind)' != ''">$(PrimaryOutputKind)</PackFolder>

<PackContent Condition="'$(PackContent)' == '' and '$(IncludeContentInPackage)' != ''">$(IncludeContentInPackage)</PackContent>
<PackNone Condition="'$(PackNone)' == '' and '$(IncludeNoneInPackage)' != ''">$(IncludeNoneInPackage)</PackNone>
<PackBuildOutput Condition="'$(PackBuildOutput)' == '' and '$(IncludeOutputsInPackage)' != ''">$(IncludeOutputsInPackage)</PackBuildOutput>
Expand Down
1 change: 1 addition & 0 deletions src/NuGetizer.Tasks/NuGetizer.Inference.targets
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ Copyright (c) .NET Foundation. All rights reserved.
<ItemDefinitionGroup>
<PackageReference>
<Pack />
<Pack Condition="'$(SuppressDependenciesWhenPacking)' == 'true'">false</Pack>
<PrivateAssets />
</PackageReference>
<ImplicitPackageReference>
Expand Down
56 changes: 56 additions & 0 deletions src/NuGetizer.Tests/given_packagereferences.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,62 @@ public void when_privateassets_pack_false_then_does_not_pack()
}));
}

[Fact]
public void when_SuppressDependenciesWhenPacking_then_does_not_pack()
{
var result = Builder.BuildProject(@"
<Project Sdk='Microsoft.NET.Sdk'>
<PropertyGroup>
<PackageId>Library</PackageId>
<TargetFramework>net472</TargetFramework>
<SuppressDependenciesWhenPacking>true</SuppressDependenciesWhenPacking>
</PropertyGroup>
<ItemGroup>
<Reference Include='WindowsBase' />
<PackageReference Include='Newtonsoft.Json' Version='1.0.0' />
</ItemGroup>
</Project>",
"GetPackageContents", output);

result.AssertSuccess(output);
Assert.DoesNotContain(result.Items, item => item.Matches(new
{
Identity = "Newtonsoft.Json"
}));
Assert.DoesNotContain(result.Items, item => item.Matches(new
{
Identity = "WindowsBase"
}));
}

[Fact]
public void when_SuppressDependenciesWhenPackingFalse_then_packs()
{
var result = Builder.BuildProject(@"
<Project Sdk='Microsoft.NET.Sdk'>
<PropertyGroup>
<PackageId>Library</PackageId>
<TargetFramework>net472</TargetFramework>
<SuppressDependenciesWhenPacking>false</SuppressDependenciesWhenPacking>
</PropertyGroup>
<ItemGroup>
<Reference Include='WindowsBase' />
<PackageReference Include='Newtonsoft.Json' Version='1.0.0' />
</ItemGroup>
</Project>",
"GetPackageContents", output);

result.AssertSuccess(output);
Assert.Contains(result.Items, item => item.Matches(new
{
Identity = "Newtonsoft.Json"
}));
Assert.Contains(result.Items, item => item.Matches(new
{
Identity = "WindowsBase"
}));
}

[Fact]
public void when_build_kind_then_does_not_pack_msbuild()
{
Expand Down