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

Automatically infer PackAsTool when ToolCommandName is used #508

Merged
merged 1 commit into from
Aug 7, 2024
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
3 changes: 3 additions & 0 deletions src/NuGetizer.Tasks/NuGetizer.Inference.targets
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ Copyright (c) .NET Foundation. All rights reserved.
<UsingTask TaskName="NuGetizer.Tasks.EvaluateWildcards" AssemblyFile="NuGetizer.Tasks.dll" />

<PropertyGroup>
<!-- When ToolCommandName is set, infer that packaging should default to PackAsTool -->
<PackAsTool Condition="'$(PackAsTool)' == '' and '$(ToolCommandName)' != ''">true</PackAsTool>

<!-- The PackFolder of primary output (build, symbols, doc and satellite assemblies) set if PackBuildOutput = true -->
<PackFolder Condition="'$(PackFolder)' == ''">lib</PackFolder>

Expand Down
27 changes: 27 additions & 0 deletions src/NuGetizer.Tests/given_a_tool_project.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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(@"
<Project Sdk='Microsoft.Build.NoTargets/3.7.0'>
<PropertyGroup>
<PackageId>MyTool</PackageId>
<TargetFramework>net8.0</TargetFramework>
<ToolCommandName>mycommand</ToolCommandName>
</PropertyGroup>
<ItemGroup>
<PackageReference Include='Microsoft.Extensions.DependencyModel' Version='8.0.0' />
</ItemGroup>
</Project>",
"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()
{
Expand Down
Loading