Skip to content
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
6 changes: 6 additions & 0 deletions src/NuGetizer.Tasks/NuGetizer.PackageMetadata.targets
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ Copyright (c) .NET Foundation. All rights reserved.
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

<PropertyGroup Label="Hidden">
<!-- If this file is the configured SDK pack targets import and it was imported manually
first, prevent Microsoft.NET.Sdk\Sdk.targets from importing the same file again. -->
<ImportNuGetBuildTasksPackTargetsFromSdk
Condition="'$(NuGetBuildTasksPackTargets)' != '' and
'$([System.IO.Path]::GetFullPath(`$(NuGetBuildTasksPackTargets)`))' == '$(MSBuildThisFileFullPath)'">false</ImportNuGetBuildTasksPackTargetsFromSdk>

<!-- Matches the SDK Pack default when set to true. -->
<PackageId Condition="'$(IsPackable)' == 'true' and '$(PackageId)' == ''">$(AssemblyName)</PackageId>
<PackageId Condition="'$(IsPackable)' == 'true' and '$(PackageId)' == ''">$(MSBuildProjectName)</PackageId>
Expand Down
24 changes: 24 additions & 0 deletions src/NuGetizer.Tests/given_packinference.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,30 @@ public class given_packinference

public given_packinference(ITestOutputHelper output) => this.output = output;

[Fact]
public void when_pack_metadata_is_imported_from_directory_targets_then_does_not_warn_on_duplicate_import()
{
var result = Builder.BuildProject(@"
<Project Sdk='Microsoft.NET.Sdk'>
<PropertyGroup>
<PackageId>Library</PackageId>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>
<Import Project='manual-import.targets' Condition=""Exists('manual-import.targets')"" />
</Project>",
"GetPackageContents", output, null,
("manual-import.targets", @"
<Project>
<Import Project='$(NuGetTargetsPath)\NuGetizer.PackageMetadata.targets'
Condition=""Exists('$(NuGetTargetsPath)\NuGetizer.PackageMetadata.targets')"" />
</Project>"));

result.AssertSuccess(output);
Assert.DoesNotContain(result.Logger.Warnings, warning =>
warning.Code == "MSB4011" &&
warning.Message.Contains("NuGetizer.PackageMetadata.targets"));
}

[Fact]
public void when_none_has_PackagePath_then_packs()
{
Expand Down
Loading