From b2b7c6dc7ed33fd7fa7c60977dd27a99aeb0a1db Mon Sep 17 00:00:00 2001 From: Daniel Plaisted Date: Fri, 13 Aug 2021 14:16:58 -0700 Subject: [PATCH 1/2] Fix publishing .NET Standard facades --- ....NET.Build.Extensions.NETFramework.targets | 4 +- .../PublishNetFrameworkApp.cs | 64 +++++++++++++++++++ 2 files changed, 65 insertions(+), 3 deletions(-) create mode 100644 src/Tests/Microsoft.NET.Publish.Tests/PublishNetFrameworkApp.cs diff --git a/src/Tasks/Microsoft.NET.Build.Extensions.Tasks/msbuildExtensions/Microsoft/Microsoft.NET.Build.Extensions/Microsoft.NET.Build.Extensions.NETFramework.targets b/src/Tasks/Microsoft.NET.Build.Extensions.Tasks/msbuildExtensions/Microsoft/Microsoft.NET.Build.Extensions/Microsoft.NET.Build.Extensions.NETFramework.targets index d7bb19fdbab1..ae88b6c851fe 100644 --- a/src/Tasks/Microsoft.NET.Build.Extensions.Tasks/msbuildExtensions/Microsoft/Microsoft.NET.Build.Extensions/Microsoft.NET.Build.Extensions.NETFramework.targets +++ b/src/Tasks/Microsoft.NET.Build.Extensions.Tasks/msbuildExtensions/Microsoft/Microsoft.NET.Build.Extensions/Microsoft.NET.Build.Extensions.NETFramework.targets @@ -104,9 +104,7 @@ Copyright (c) .NET Foundation. All rights reserved. and VS won't show a warning icon on the reference. See https://github.com/dotnet/sdk/issues/1499 --> - - false - + <_UpdatedReference Remove="@(_UpdatedReference)" /> diff --git a/src/Tests/Microsoft.NET.Publish.Tests/PublishNetFrameworkApp.cs b/src/Tests/Microsoft.NET.Publish.Tests/PublishNetFrameworkApp.cs new file mode 100644 index 000000000000..f2e35ba49de5 --- /dev/null +++ b/src/Tests/Microsoft.NET.Publish.Tests/PublishNetFrameworkApp.cs @@ -0,0 +1,64 @@ +// 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; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using FluentAssertions; +using Microsoft.DotNet.Cli.Utils; +using Microsoft.NET.TestFramework; +using Microsoft.NET.TestFramework.Assertions; +using Microsoft.NET.TestFramework.Commands; +using Microsoft.NET.TestFramework.ProjectConstruction; +using Xunit; +using Xunit.Abstractions; + +namespace Microsoft.NET.Publish.Tests +{ + public class PublishNetFrameworkApp : SdkTest + { + public PublishNetFrameworkApp(ITestOutputHelper log) : base(log) + { + } + + [Fact] + public void NetStandardFacadesArePublished() + { + var netStandardProject = new TestProject() + { + Name = "NetStandardProject", + TargetFrameworks = "netstandard2.0" + }; + + var testProject = new TestProject() + { + TargetFrameworks = "net461", + IsExe = true + }; + testProject.ReferencedProjects.Add(netStandardProject); + + var testAsset = _testAssetsManager.CreateTestProject(testProject); + + var publishCommand = new PublishCommand(testAsset); + + publishCommand.Execute() + .Should() + .Pass(); + + // There are close to 100 facades that should be copied, just check for a few of them here + publishCommand.GetOutputDirectory(testProject.TargetFrameworks) + .Should() + .HaveFiles(new[] + { + "netstandard.dll", + "System.IO.dll", + "System.Runtime.dll" + }) + .And + .NotHaveFile("netfx.force.conflicts.dll"); + } + } +} From effc5a8975cf6ac6b75f08faf9031c1fa9d63313 Mon Sep 17 00:00:00 2001 From: Daniel Plaisted Date: Fri, 13 Aug 2021 17:34:04 -0700 Subject: [PATCH 2/2] Update test to account for which file wins conflicts --- .../GivenThatWeWantToPublishWithoutConflicts.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Tests/Microsoft.NET.Publish.Tests/GivenThatWeWantToPublishWithoutConflicts.cs b/src/Tests/Microsoft.NET.Publish.Tests/GivenThatWeWantToPublishWithoutConflicts.cs index 9b051e786de4..9a4ce9d78b8e 100644 --- a/src/Tests/Microsoft.NET.Publish.Tests/GivenThatWeWantToPublishWithoutConflicts.cs +++ b/src/Tests/Microsoft.NET.Publish.Tests/GivenThatWeWantToPublishWithoutConflicts.cs @@ -50,8 +50,9 @@ public void It_solves_conflicts_between_package_and_implicit_references() var files = getValuesCommand.GetValues() .Where(file => file.Contains(reference)); files.Count().Should().Be(1); - // We should choose the file from system.runtime.interopservices.runtimeinformation package version - files.FirstOrDefault().Contains(@"system.runtime.interopservices.runtimeinformation\4.3.0").Should().BeTrue(); + + // We should choose the system.runtime.interopservices.runtimeinformation file from Microsoft.NET.Build.Extensions as it has a higher AssemblyVersion (4.0.2.0 compared to 4.0.1.0) + files.FirstOrDefault().Contains(@"Microsoft.NET.Build.Extensions\net461\lib\System.Runtime.InteropServices.RuntimeInformation.dll").Should().BeTrue(); } [Theory]