Skip to content

Exe do not inclue app package #2395

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

Merged
merged 2 commits into from
Jul 13, 2018
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
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ Copyright (c) .NET Foundation. All rights reserved.
<ItemGroup Condition=" '$(DisableImplicitFrameworkReferences)' != 'true' and '$(TargetFrameworkIdentifier)' == '.NETCoreApp'">
<PackageReference Include="Microsoft.NETCore.App" Version="$(RuntimeFrameworkVersion)" IsImplicitlyDefined="true" />

<!-- For libraries targeting .NET Core 2.0 or higher, don't include a dependency on Microsoft.NETCore.App in the package produced by pack.
Packing an app (for example a .NET CLI tool) should include the Microsoft.NETCore.App package dependency. -->
<!-- For targeting .NET Core 2.0 or higher, don't include a dependency on Microsoft.NETCore.App in the package produced by pack.
Packing an DotnetCliTool should include the Microsoft.NETCore.App package dependency. -->
<PackageReference Update="Microsoft.NETCore.App"
Condition="('$(OutputType)' != 'Exe') And ('$(_TargetFrameworkVersionWithoutV)' != '') And ('$(_TargetFrameworkVersionWithoutV)' >= '2.0')"
Condition="('$(_TargetFrameworkVersionWithoutV)' != '') And ('$(_TargetFrameworkVersionWithoutV)' >= '2.0') And ('$(PackageType)' != 'DotnetCliTool')"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want another escape hatch than setting PackageType? What else does that impact?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would say we already have another escape hatch: put the following in your project:

<ItemGroup>
    <PackageReference Update="Microsoft.NETCore.App" PrivateAssets="None" />
</ItemGroup>

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. I'm convinced. :)

PrivateAssets="All"
Publish="true" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ public void It_creates_a_deps_file_for_the_tool_and_the_tool_runs()
IsExe = true
};

toolProject.AdditionalProperties.Add("PackageType", "DotnetCliTool");

GenerateDepsAndRunTool(toolProject)
.Should()
.Pass()
Expand All @@ -59,6 +61,8 @@ public void It_handles_conflicts_when_creating_a_tool_deps_file()
IsExe = true
};

toolProject.AdditionalProperties.Add("PackageType", "DotnetCliTool");

toolProject.PackageReferences.Add(new TestPackageReference("Microsoft.Extensions.DependencyModel", "1.1.0", null));

string toolSource = @"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ public void Packing_an_app_exclude_dependencys_framework_assemblies_dependency()
}

[Fact]
public void Packing_a_netcoreapp_2_0_app_includes_the_implicit_dependency()
public void Packing_a_netcoreapp_2_0_app_does_not_include_the_implicit_dependency()
{
TestProject testProject = new TestProject()
{
Expand All @@ -155,6 +155,24 @@ public void Packing_a_netcoreapp_2_0_app_includes_the_implicit_dependency()

var dependencies = PackAndGetDependencies(testProject);

dependencies.Should().BeEmpty();
}

[Fact]
public void Packing_a_netcoreapp_2_0_DotnetCliTool_app_includes_the_implicit_dependency()
{
TestProject testProject = new TestProject()
{
Name = "PackNetCoreApp20App",
IsSdkProject = true,
TargetFrameworks = "netcoreapp2.0",
IsExe = true
};

testProject.AdditionalProperties.Add("PackageType", "DotnetCliTool");

var dependencies = PackAndGetDependencies(testProject);

dependencies.Count().Should().Be(1);
dependencies.Single().Attribute("id").Value
.Should().Be("Microsoft.NETCore.App");
Expand Down