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
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ artifacts:
- path: '**\*.nupkg'
name: NuGet Packages
on_failure:
- ps: Get-ChildItem .\*.log -Recursive | % { Push-AppveyorArtifact $_.FullName -FileName $_.Name }
- ps: Get-ChildItem .\*log -Recurse | % { Push-AppveyorArtifact $_.FullName -FileName $_.Name }
23 changes: 23 additions & 0 deletions src/MSBuildProjectCreator.UnitTests/ItemTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,29 @@ public void ItemIncludeNotAddedIfNull()
StringCompareShould.IgnoreLineEndings);
}

[Fact]
public void MetadataNotAddedIfNull()
{
ProjectCreator.Create(projectFileOptions: NewProjectFileOptions.None)
.ItemInclude(
itemType: "DB5003A476FA461EB0452DDDCCE7F802",
include: "303F33834A6843EDB44DB8D3186E97E0",
metadata: new Dictionary<string, string>
{
{ "CDBA5A760C9C45CFB2E9532D4B4AE2B7", "D6A68EA723C848E19D2E17C09F7F2532" },
{ "FDD9C6C5582B404188CD8C938DB2CDD9", null }
})
.Xml.ShouldBe(
@"<Project>
<ItemGroup>
<DB5003A476FA461EB0452DDDCCE7F802 Include=""303F33834A6843EDB44DB8D3186E97E0"">
<CDBA5A760C9C45CFB2E9532D4B4AE2B7>D6A68EA723C848E19D2E17C09F7F2532</CDBA5A760C9C45CFB2E9532D4B4AE2B7>
</DB5003A476FA461EB0452DDDCCE7F802>
</ItemGroup>
</Project>",
StringCompareShould.IgnoreLineEndings);
}

[Fact]
public void NoneItem()
{
Expand Down
3 changes: 2 additions & 1 deletion src/MSBuildProjectCreator/ProjectCreator.Items.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using Microsoft.Build.Construction;
using Microsoft.Build.Evaluation;
using System.Collections.Generic;
using System.Linq;

namespace Microsoft.Build.Utilities.ProjectCreation
{
Expand Down Expand Up @@ -291,7 +292,7 @@ private ProjectCreator Item(

if (metadata != null)
{
foreach (KeyValuePair<string, string> metadatum in metadata)
foreach (KeyValuePair<string, string> metadatum in metadata.Where(i => i.Value != null))
{
item.AddMetadata(metadatum.Key, metadatum.Value);
}
Expand Down