Skip to content

Commit 3e87ad5

Browse files
authored
Merge pull request #12720 from sfoslund/ProduceReferenceAssembly
Default ProduceReferenceAssembly to true
2 parents 9b39d77 + ffc2a32 commit 3e87ad5

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed

src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.TargetFrameworkInference.targets

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,10 @@ Copyright (c) .NET Foundation. All rights reserved.
211211
<AppendTargetFrameworkToOutputPath Condition="'$(AppendTargetFrameworkToOutputPath)' == ''">true</AppendTargetFrameworkToOutputPath>
212212
</PropertyGroup>
213213

214+
<PropertyGroup>
215+
<ProduceReferenceAssembly Condition="'$(ProduceReferenceAssembly)' == '' and '$(TargetFrameworkIdentifier)' == '.NETCoreApp' and $([MSBuild]::VersionGreaterThanOrEquals($(TargetFrameworkVersion), 5.0))" >true</ProduceReferenceAssembly>
216+
</PropertyGroup>
217+
214218
<!--
215219
Append $(TargetFramework) directory to output and intermediate paths to prevent bin clashes between
216220
targets.
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
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+
using System.IO;
5+
using FluentAssertions;
6+
using Microsoft.NET.TestFramework;
7+
using Microsoft.NET.TestFramework.Commands;
8+
using Xunit;
9+
using Xunit.Abstractions;
10+
using Microsoft.NET.TestFramework.Assertions;
11+
using Microsoft.NET.TestFramework.ProjectConstruction;
12+
using System.Collections.Generic;
13+
14+
namespace Microsoft.NET.Build.Tests
15+
{
16+
public class GivenThatWeWantToProduceReferenceAssembly : SdkTest
17+
{
18+
public GivenThatWeWantToProduceReferenceAssembly(ITestOutputHelper log) : base(log)
19+
{}
20+
21+
[Theory]
22+
[InlineData("netcoreapp3.1", false)]
23+
[InlineData("net5.0", true)]
24+
public void It_produces_ref_assembly_for_appropriate_frameworks(string targetFramework, bool expectedExists)
25+
{
26+
TestProject testProject = new TestProject()
27+
{
28+
Name = "ProduceRefAssembly",
29+
IsSdkProject = true,
30+
IsExe = true,
31+
TargetFrameworks = targetFramework
32+
};
33+
34+
var testAsset = _testAssetsManager.CreateTestProject(testProject);
35+
36+
var buildCommand = new BuildCommand(testAsset);
37+
buildCommand.Execute()
38+
.Should()
39+
.Pass();
40+
var filePath = Path.Combine(testAsset.Path, testProject.Name, "obj", "Debug", targetFramework, "ref", $"{testProject.Name}.dll");
41+
File.Exists(filePath).Should().Be(expectedExists);
42+
}
43+
}
44+
}

0 commit comments

Comments
 (0)