From 2f0d0ca9c15110c7299ddabca2b2725355b5fd51 Mon Sep 17 00:00:00 2001 From: Daniel Cazzulino Date: Wed, 7 Aug 2024 18:21:34 -0300 Subject: [PATCH] Automatically infer PackAsTool when ToolCommandName is used --- .../NuGetizer.Inference.targets | 3 +++ src/NuGetizer.Tests/given_a_tool_project.cs | 27 +++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/src/NuGetizer.Tasks/NuGetizer.Inference.targets b/src/NuGetizer.Tasks/NuGetizer.Inference.targets index 0f62c94a..fa20d07e 100644 --- a/src/NuGetizer.Tasks/NuGetizer.Inference.targets +++ b/src/NuGetizer.Tasks/NuGetizer.Inference.targets @@ -14,6 +14,9 @@ Copyright (c) .NET Foundation. All rights reserved. + + true + lib diff --git a/src/NuGetizer.Tests/given_a_tool_project.cs b/src/NuGetizer.Tests/given_a_tool_project.cs index 57861bd9..498f8447 100644 --- a/src/NuGetizer.Tests/given_a_tool_project.cs +++ b/src/NuGetizer.Tests/given_a_tool_project.cs @@ -37,6 +37,33 @@ public void when_pack_as_tool_then_packs_no_dependencies() })); } + [Fact] + public void when_toolcommand_then_packs_as_tool_with_no_dependencies() + { + var result = Builder.BuildProject(@" + + + MyTool + net8.0 + mycommand + + + + +", + "GetPackageContents", output); + + result.AssertSuccess(output); + Assert.DoesNotContain(result.Items, item => item.Matches(new + { + Identity = "Microsoft.Extensions.DependencyModel" + })); + Assert.Contains(result.Items, item => item.Matches(new + { + PackageFile = "Microsoft.Extensions.DependencyModel.dll" + })); + } + [Fact] public void when_pack_as_tool_then_packs_dotnet_tool_runtime_assets() {