Skip to content

Commit f8b8a09

Browse files
authored
Merge pull request #19731 from dsplaisted/fix-netstandard-facades
Fix publishing .NET Standard facades
2 parents c720799 + effc5a8 commit f8b8a09

File tree

3 files changed

+68
-5
lines changed

3 files changed

+68
-5
lines changed

src/Tasks/Microsoft.NET.Build.Extensions.Tasks/msbuildExtensions/Microsoft/Microsoft.NET.Build.Extensions/Microsoft.NET.Build.Extensions.NETFramework.targets

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,7 @@ Copyright (c) .NET Foundation. All rights reserved.
104104
and VS won't show a warning icon on the reference. See https://github.com/dotnet/sdk/issues/1499
105105
-->
106106

107-
<ReferenceCopyLocalPaths Include="@(_NETStandardLibraryNETFrameworkLib)" Condition="'%(FileName)' != 'netfx.force.conflicts'">
108-
<Private>false</Private>
109-
</ReferenceCopyLocalPaths>
107+
<ReferenceCopyLocalPaths Include="@(_NETStandardLibraryNETFrameworkLib)" Condition="'%(FileName)' != 'netfx.force.conflicts'"/>
110108

111109
<_UpdatedReference Remove="@(_UpdatedReference)" />
112110
</ItemGroup>

src/Tests/Microsoft.NET.Publish.Tests/GivenThatWeWantToPublishWithoutConflicts.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,9 @@ public void It_solves_conflicts_between_package_and_implicit_references()
5050
var files = getValuesCommand.GetValues()
5151
.Where(file => file.Contains(reference));
5252
files.Count().Should().Be(1);
53-
// We should choose the file from system.runtime.interopservices.runtimeinformation package version
54-
files.FirstOrDefault().Contains(@"system.runtime.interopservices.runtimeinformation\4.3.0").Should().BeTrue();
53+
54+
// 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)
55+
files.FirstOrDefault().Contains(@"Microsoft.NET.Build.Extensions\net461\lib\System.Runtime.InteropServices.RuntimeInformation.dll").Should().BeTrue();
5556
}
5657

5758
[Theory]
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
// Copyright (c) .NET Foundation and contributors. All rights reserved.
2+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
3+
//
4+
5+
using System;
6+
using System.Collections.Generic;
7+
using System.IO;
8+
using System.Linq;
9+
using System.Text;
10+
using FluentAssertions;
11+
using Microsoft.DotNet.Cli.Utils;
12+
using Microsoft.NET.TestFramework;
13+
using Microsoft.NET.TestFramework.Assertions;
14+
using Microsoft.NET.TestFramework.Commands;
15+
using Microsoft.NET.TestFramework.ProjectConstruction;
16+
using Xunit;
17+
using Xunit.Abstractions;
18+
19+
namespace Microsoft.NET.Publish.Tests
20+
{
21+
public class PublishNetFrameworkApp : SdkTest
22+
{
23+
public PublishNetFrameworkApp(ITestOutputHelper log) : base(log)
24+
{
25+
}
26+
27+
[Fact]
28+
public void NetStandardFacadesArePublished()
29+
{
30+
var netStandardProject = new TestProject()
31+
{
32+
Name = "NetStandardProject",
33+
TargetFrameworks = "netstandard2.0"
34+
};
35+
36+
var testProject = new TestProject()
37+
{
38+
TargetFrameworks = "net461",
39+
IsExe = true
40+
};
41+
testProject.ReferencedProjects.Add(netStandardProject);
42+
43+
var testAsset = _testAssetsManager.CreateTestProject(testProject);
44+
45+
var publishCommand = new PublishCommand(testAsset);
46+
47+
publishCommand.Execute()
48+
.Should()
49+
.Pass();
50+
51+
// There are close to 100 facades that should be copied, just check for a few of them here
52+
publishCommand.GetOutputDirectory(testProject.TargetFrameworks)
53+
.Should()
54+
.HaveFiles(new[]
55+
{
56+
"netstandard.dll",
57+
"System.IO.dll",
58+
"System.Runtime.dll"
59+
})
60+
.And
61+
.NotHaveFile("netfx.force.conflicts.dll");
62+
}
63+
}
64+
}

0 commit comments

Comments
 (0)