Skip to content

Commit 33a21e5

Browse files
authored
Merge pull request #3455 from dsplaisted/referencebydefault
Don't reference assemblies from targeting pack with ReferencedByDefault="false"
2 parents 5b5d4ee + a846e62 commit 33a21e5

File tree

6 files changed

+22
-8
lines changed

6 files changed

+22
-8
lines changed

eng/restore-toolset.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ function InitializeCustomSDKToolset {
1818
InstallDotNetSharedFramework "1.0.5"
1919
InstallDotNetSharedFramework "1.1.2"
2020
InstallDotNetSharedFramework "2.1.0"
21-
InstallDotNetSharedFramework "2.2.5"
21+
InstallDotNetSharedFramework "2.2.6"
2222

2323
CreateBuildEnvScript
2424
InstallNuget

eng/restore-toolset.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ function InitializeCustomSDKToolset {
1313
InstallDotNetSharedFramework "1.0.5"
1414
InstallDotNetSharedFramework "1.1.2"
1515
InstallDotNetSharedFramework "2.1.0"
16-
InstallDotNetSharedFramework "2.2.5"
16+
InstallDotNetSharedFramework "2.2.6"
1717
}
1818

1919
# Installs additional shared frameworks for testing purposes

global.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"tools": {
3-
"dotnet": "3.0.100-preview8-012830",
3+
"dotnet": "3.0.100-preview8-013410",
44
"vs-opt": {
55
"version": "15.9"
66
}

src/Tasks/Microsoft.NET.Build.Tasks/ResolveTargetingPackAssets.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,14 @@ private void AddReferencesFromFrameworkList(string frameworkListPath, string tar
192192
}
193193
}
194194

195+
string referencedByDefaultAttributeValue = fileElement.Attribute("ReferencedByDefault")?.Value;
196+
if (referencedByDefaultAttributeValue != null &&
197+
referencedByDefaultAttributeValue.Equals("false", StringComparison.OrdinalIgnoreCase))
198+
{
199+
// Don't automatically reference this assembly if it has ReferencedByDefault="false"
200+
continue;
201+
}
202+
195203
var dllPath = Path.Combine(targetingPackDllFolder, assemblyName + ".dll");
196204
var referenceItem = CreateReferenceItem(dllPath, targetingPack);
197205

src/Tests/Microsoft.NET.Build.Tests/GivenFrameworkReferences.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -792,7 +792,7 @@ public void WindowsFormsFrameworkReference(bool selfContained)
792792
TestFrameworkReferenceProfiles(
793793
frameworkReferences: new [] { "Microsoft.WindowsDesktop.App.WindowsForms" },
794794
expectedReferenceNames: new[] { "Microsoft.Win32.Registry", "System.Windows.Forms" },
795-
notExpectedReferenceNames: new[] { "System.Windows.Presentation", "WindowsFormsIntegration" },
795+
notExpectedReferenceNames: new[] { "System.Windows.Presentation", "WindowsFormsIntegration", "PresentationFramework.Aero" },
796796
selfContained);
797797
}
798798

@@ -804,7 +804,7 @@ public void WPFFrameworkReference(bool selfContained)
804804
TestFrameworkReferenceProfiles(
805805
frameworkReferences: new[] { "Microsoft.WindowsDesktop.App.WPF" },
806806
expectedReferenceNames: new[] { "Microsoft.Win32.Registry", "System.Windows.Presentation" },
807-
notExpectedReferenceNames: new[] { "System.Windows.Forms", "WindowsFormsIntegration" },
807+
notExpectedReferenceNames: new[] { "System.Windows.Forms", "WindowsFormsIntegration", "PresentationFramework.Aero" },
808808
selfContained);
809809
}
810810

@@ -816,7 +816,7 @@ public void WindowsFormAndWPFFrameworkReference(bool selfContained)
816816
TestFrameworkReferenceProfiles(
817817
frameworkReferences: new[] { "Microsoft.WindowsDesktop.App.WindowsForms", "Microsoft.WindowsDesktop.App.WPF" },
818818
expectedReferenceNames: new[] { "Microsoft.Win32.Registry", "System.Windows.Forms", "System.Windows.Presentation" },
819-
notExpectedReferenceNames: new[] { "WindowsFormsIntegration" },
819+
notExpectedReferenceNames: new[] { "WindowsFormsIntegration", "PresentationFramework.Aero" },
820820
selfContained);
821821
}
822822

@@ -829,7 +829,7 @@ public void WindowsDesktopFrameworkReference(bool selfContained)
829829
frameworkReferences: new[] { "Microsoft.WindowsDesktop.App" },
830830
expectedReferenceNames: new[] { "Microsoft.Win32.Registry", "System.Windows.Forms",
831831
"System.Windows.Presentation", "WindowsFormsIntegration" },
832-
notExpectedReferenceNames: Enumerable.Empty<string>(),
832+
notExpectedReferenceNames: new[] { "PresentationFramework.Aero" },
833833
selfContained);
834834
}
835835

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,12 @@ public void It_publishes_the_project_with_a_refs_folder_and_correct_deps_file(st
7070
testAsset.Restore(Log, "TestApp");
7171

7272
var appProjectDirectory = Path.Combine(testAsset.TestRoot, "TestApp");
73+
74+
var getValuesCommand = new GetValuesCommand(Log, appProjectDirectory, testProject.TargetFrameworks, "LangVersion");
75+
getValuesCommand.Execute().Should().Pass();
76+
77+
var langVersion = getValuesCommand.GetValues().FirstOrDefault() ?? string.Empty;
78+
7379
var publishCommand = new PublishCommand(Log, appProjectDirectory);
7480

7581
publishCommand
@@ -114,7 +120,7 @@ public void It_publishes_the_project_with_a_refs_folder_and_correct_deps_file(st
114120
}
115121

116122
dependencyContext.CompilationOptions.Defines.Should().BeEquivalentTo(expectedDefines);
117-
dependencyContext.CompilationOptions.LanguageVersion.Should().BeOneOf("", "preview");
123+
dependencyContext.CompilationOptions.LanguageVersion.Should().Be(langVersion);
118124
dependencyContext.CompilationOptions.Platform.Should().Be("x86");
119125
dependencyContext.CompilationOptions.Optimize.Should().Be(false);
120126
dependencyContext.CompilationOptions.KeyFile.Should().Be("");

0 commit comments

Comments
 (0)