Skip to content

Commit

Permalink
Merge pull request #809 from dsplaisted/privateassets-publish-376
Browse files Browse the repository at this point in the history
Use case insensitive comparison for determining which packages should be excluded from publishing
  • Loading branch information
srivatsn authored Feb 4, 2017
2 parents 0d73192 + e342ee6 commit fde4b29
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Tasks/Microsoft.NET.Build.Tasks/LockFileExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public static HashSet<string> GetPlatformExclusionList(
LockFileTargetLibrary platformLibrary,
IDictionary<string, LockFileTargetLibrary> libraryLookup)
{
var exclusionList = new HashSet<string>();
var exclusionList = new HashSet<string>(StringComparer.OrdinalIgnoreCase);

exclusionList.Add(platformLibrary.Name);
CollectDependencies(libraryLookup, platformLibrary.Dependencies, exclusionList);
Expand Down
2 changes: 1 addition & 1 deletion src/Tasks/Microsoft.NET.Build.Tasks/ProjectContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public IEnumerable<LockFileTargetLibrary> GetRuntimeLibraries(IEnumerable<string
Dictionary<string, LockFileTargetLibrary> libraryLookup =
runtimeLibraries.ToDictionary(e => e.Name, StringComparer.OrdinalIgnoreCase);

HashSet<string> allExclusionList = new HashSet<string>();
HashSet<string> allExclusionList = new HashSet<string>(StringComparer.OrdinalIgnoreCase);

if (IsPortable)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
// Copyright (c) .NET Foundation and contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using System.IO;
using System.Runtime.InteropServices;
using Microsoft.DotNet.Cli.Utils;
using Microsoft.DotNet.InternalAbstractions;
using Microsoft.NET.TestFramework;
using Microsoft.NET.TestFramework.Assertions;
using Microsoft.NET.TestFramework.Commands;
using Xunit;
using static Microsoft.NET.TestFramework.Commands.MSBuildTest;
using System.Xml.Linq;

namespace Microsoft.NET.Publish.Tests
{
public class GivenThatWeWantToExcludeAPackageFromPublish : SdkTest
{
[Fact]
public void It_does_not_publish_a_PackageReference_with_PrivateAssets_All()
{
var helloWorldAsset = _testAssetsManager
.CopyTestAsset("HelloWorld", "PublishExcludePackage")
.WithSource()
.WithProjectChanges(project =>
{
var ns = project.Root.Name.Namespace;

var itemGroup = new XElement(ns + "ItemGroup");
project.Root.Add(itemGroup);

// Using different casing for the package ID here, to test the scenario from https://github.com/dotnet/sdk/issues/376
itemGroup.Add(new XElement(ns + "PackageReference", new XAttribute("Include", "NEWTONSOFT.Json"),
new XAttribute("Version", "9.0.1"),
new XAttribute("PrivateAssets", "All")));
})
.Restore();

var publishCommand = new PublishCommand(Stage0MSBuild, helloWorldAsset.TestRoot);
var publishResult = publishCommand.Execute();

publishResult.Should().Pass();

var publishDirectory = publishCommand.GetOutputDirectory();

publishDirectory.Should().OnlyHaveFiles(new[] {
"HelloWorld.dll",
"HelloWorld.pdb",
"HelloWorld.deps.json",
"HelloWorld.runtimeconfig.json"
});
}
}
}

0 comments on commit fde4b29

Please sign in to comment.