From 824d455249bf66557232f69c1328c098ecd13253 Mon Sep 17 00:00:00 2001
From: MSLukeWest <42553283+MSLukeWest@users.noreply.github.com>
Date: Wed, 3 Apr 2019 15:02:39 -0700
Subject: [PATCH 1/7] Adding NetCorePublishItemsOutputGroup to support VS
installer project scenarios
---
.../targets/Microsoft.NET.Publish.targets | 20 +++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Publish.targets b/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Publish.targets
index ebd375b337da..acf88e6d359e 100644
--- a/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Publish.targets
+++ b/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Publish.targets
@@ -841,6 +841,26 @@ Copyright (c) .NET Foundation. All rights reserved.
+
+
+
+ $(NetCorePublishItemsOutputGroupDependsOn);
+ ComputeFilesToPublish;
+
+
+
+
+
+
+
+
+
-
- $(NetCorePublishItemsOutputGroupDependsOn);
+
+ $(PublishItemsOutputGroupDependsOn);
ComputeFilesToPublish;
-
+
-
+
-
+
diff --git a/src/Tests/Microsoft.NET.Publish.Tests/NetCorePublishItemsOutputGroupTests.cs b/src/Tests/Microsoft.NET.Publish.Tests/PublishItemsOutputGroupTests.cs
similarity index 57%
rename from src/Tests/Microsoft.NET.Publish.Tests/NetCorePublishItemsOutputGroupTests.cs
rename to src/Tests/Microsoft.NET.Publish.Tests/PublishItemsOutputGroupTests.cs
index 888f1bba0f64..2ce5832c9a61 100644
--- a/src/Tests/Microsoft.NET.Publish.Tests/NetCorePublishItemsOutputGroupTests.cs
+++ b/src/Tests/Microsoft.NET.Publish.Tests/PublishItemsOutputGroupTests.cs
@@ -1,111 +1,106 @@
-using System.Collections.Generic;
-using System.IO;
-using FluentAssertions;
-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 NetCorePublishItemsOutputGroupTests : SdkTest
- {
- public NetCorePublishItemsOutputGroupTests(ITestOutputHelper log) : base(log)
- {
- }
-
- private static List FrameworkAssemblies = new List()
- {
- "api-ms-win-core-console-l1-1-0.dll",
- "System.Runtime.dll",
- "WindowsBase.dll",
- };
-
- [CoreMSBuildOnlyFact]
- public void GroupPopulatedWithRid()
- {
- var testProject = this.SetupProject();
- var testAsset = _testAssetsManager.CreateTestProject(testProject);
-
- var restoreCommand = new RestoreCommand(Log, testAsset.Path, testProject.Name);
- restoreCommand
- .Execute()
- .Should()
- .Pass();
-
- var buildCommand = new BuildCommand(Log, testAsset.Path, testProject.Name);
- buildCommand
- .Execute("/p:RuntimeIdentifier=win-x86", "/t:NetCorePublishItemsOutputGroup")
- .Should()
- .Pass();
-
- var testOutputDir = Path.Combine(testAsset.Path, testProject.Name, "TestOutput");
- Log.WriteLine("Contents of NetCorePublishItemsOutputGroup dumped to '{0}'.", testOutputDir);
-
- // Check for the existence of a few specific files that should be in the directory where the
- // contents of NetCorePublishItemsOutputGroup were dumped to make sure it's getting populated.
- Assert.True(File.Exists(Path.Combine(testOutputDir, $"{testProject.Name}.exe")), $"Assembly {testProject.Name}.exe is present in the output group.");
- foreach (var assem in FrameworkAssemblies)
- {
- Assert.True(File.Exists(Path.Combine(testOutputDir, assem)), $"Assembly {assem} is present in the output group.");
- }
- }
-
- [CoreMSBuildOnlyFact]
- public void GroupNotPopulatedWithoutRid()
- {
- var testProject = this.SetupProject();
- var testAsset = _testAssetsManager.CreateTestProject(testProject);
-
- var restoreCommand = new RestoreCommand(Log, testAsset.Path, testProject.Name);
- restoreCommand
- .Execute()
- .Should()
- .Pass();
-
- var buildCommand = new BuildCommand(Log, testAsset.Path, testProject.Name);
- buildCommand
- .Execute("/t:NetCorePublishItemsOutputGroup")
- .Should()
- .Pass();
-
- var testOutputDir = Path.Combine(testAsset.Path, testProject.Name, "TestOutput");
- Log.WriteLine("Contents of NetCorePublishItemsOutputGroup dumped to '{0}'.", testOutputDir);
-
- // Since no RID was specified the output group should only contain framework dependent output
- Assert.True(File.Exists(Path.Combine(testOutputDir, $"{testProject.Name}.exe")), $"Assembly {testProject.Name}.exe is present in the output group.");
- foreach (var assem in FrameworkAssemblies)
- {
- Assert.False(File.Exists(Path.Combine(testOutputDir, assem)), $"Assembly {assem} is not present in the output group.");
- }
- }
-
- private TestProject SetupProject()
- {
- var testProject = new TestProject()
- {
- Name = "TestPublishOutputGroup",
- TargetFrameworks = "netcoreapp3.0",
- IsSdkProject = true,
- IsExe = true
- };
-
- testProject.AdditionalProperties["RuntimeIdentifiers"] = "win-x86";
-
- // Use a test-specific packages folder
- testProject.AdditionalProperties["RestorePackagesPath"] = @"$(MSBuildProjectDirectory)\..\pkg";
-
- // Add a target that will dump the contents of the NetCorePublishItemsOutputGroup to
- // a test directory after building.
- testProject.CopyFilesTargets.Add(new CopyFilesTarget(
- "CopyNetCorePublishItemsOutputGroup",
- "NetCorePublishItemsOutputGroup",
- "@(NetCorePublishItemsOutputGroupOutputs)",
- "$(MSBuildProjectDirectory)\\TestOutput"));
-
- return testProject;
- }
- }
-}
+using System.Collections.Generic;
+using System.IO;
+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 PublishItemsOutputGroupTests : SdkTest
+ {
+ public PublishItemsOutputGroupTests(ITestOutputHelper log) : base(log)
+ {
+ }
+
+ private static List FrameworkAssemblies = new List()
+ {
+ "api-ms-win-core-console-l1-1-0.dll",
+ "System.Runtime.dll",
+ "WindowsBase.dll",
+ };
+
+ [Fact]
+ public void GroupPopulatedWithRid()
+ {
+ var testProject = this.SetupProject();
+ var testAsset = _testAssetsManager.CreateTestProject(testProject);
+
+ var restoreCommand = new RestoreCommand(Log, testAsset.Path, testProject.Name);
+ restoreCommand
+ .Execute()
+ .Should()
+ .Pass();
+
+ var buildCommand = new BuildCommand(Log, testAsset.Path, testProject.Name);
+ buildCommand
+ .Execute("/p:RuntimeIdentifier=win-x86", "/t:PublishItemsOutputGroup")
+ .Should()
+ .Pass();
+
+ var testOutputDir = new DirectoryInfo(Path.Combine(testAsset.Path, testProject.Name, "TestOutput"));
+ Log.WriteLine("Contents of PublishItemsOutputGroup dumped to '{0}'.", testOutputDir.FullName);
+
+ // Check for the existence of a few specific files that should be in the directory where the
+ // contents of PublishItemsOutputGroup were dumped to make sure it's getting populated.
+ testOutputDir.Should().HaveFile($"{testProject.Name}{Constants.ExeSuffix}");
+ testOutputDir.Should().HaveFiles(FrameworkAssemblies);
+ }
+
+ [Fact]
+ public void GroupNotPopulatedWithoutRid()
+ {
+ var testProject = this.SetupProject();
+ var testAsset = _testAssetsManager.CreateTestProject(testProject);
+
+ var restoreCommand = new RestoreCommand(Log, testAsset.Path, testProject.Name);
+ restoreCommand
+ .Execute()
+ .Should()
+ .Pass();
+
+ var buildCommand = new BuildCommand(Log, testAsset.Path, testProject.Name);
+ buildCommand
+ .Execute("/t:PublishItemsOutputGroup")
+ .Should()
+ .Pass();
+
+ var testOutputDir = new DirectoryInfo(Path.Combine(testAsset.Path, testProject.Name, "TestOutput"));
+ Log.WriteLine("Contents of PublishItemsOutputGroup dumped to '{0}'.", testOutputDir.FullName);
+
+ // Since no RID was specified the output group should only contain framework dependent output
+ testOutputDir.Should().HaveFile($"{testProject.Name}{Constants.ExeSuffix}");
+ testOutputDir.Should().NotHaveFiles(FrameworkAssemblies);
+ }
+
+ private TestProject SetupProject()
+ {
+ var testProject = new TestProject()
+ {
+ Name = "TestPublishOutputGroup",
+ TargetFrameworks = "netcoreapp3.0",
+ IsSdkProject = true,
+ IsExe = true
+ };
+
+ testProject.AdditionalProperties["RuntimeIdentifiers"] = "win-x86";
+
+ // Use a test-specific packages folder
+ testProject.AdditionalProperties["RestorePackagesPath"] = @"$(MSBuildProjectDirectory)\..\pkg";
+
+ // Add a target that will dump the contents of the PublishItemsOutputGroup to
+ // a test directory after building.
+ testProject.CopyFilesTargets.Add(new CopyFilesTarget(
+ "CopyPublishItemsOutputGroup",
+ "PublishItemsOutputGroup",
+ "@(PublishItemsOutputGroupOutputs)",
+ "$(MSBuildProjectDirectory)\\TestOutput"));
+
+ return testProject;
+ }
+ }
+}
diff --git a/src/Tests/Microsoft.NET.TestFramework/CopyFilesTarget.cs b/src/Tests/Microsoft.NET.TestFramework/CopyFilesTarget.cs
index 3e1532f78d00..5b0bd2556e93 100644
--- a/src/Tests/Microsoft.NET.TestFramework/CopyFilesTarget.cs
+++ b/src/Tests/Microsoft.NET.TestFramework/CopyFilesTarget.cs
@@ -1,25 +1,25 @@
-// 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.
-
-namespace Microsoft.NET.TestFramework
-{
- ///
- /// Represents a target that will copy some set of files to a given location after some other target completes.
- /// Useful for verifying the contents of an output group in a test.
- ///
- public class CopyFilesTarget
- {
- public CopyFilesTarget(string targetName, string targetToRunAfter, string sourceFiles, string destination)
- {
- TargetName = targetName;
- TargetToRunAfter = targetToRunAfter;
- SourceFiles = sourceFiles;
- Destination = destination;
- }
-
- public string TargetName { get; private set; }
- public string TargetToRunAfter { get; private set; }
- public string SourceFiles { get; private set; }
- public string Destination { get; private set; }
- }
-}
+// 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.
+
+namespace Microsoft.NET.TestFramework
+{
+ ///
+ /// Represents a target that will copy some set of files to a given location after some other target completes.
+ /// Useful for verifying the contents of an output group in a test.
+ ///
+ public class CopyFilesTarget
+ {
+ public CopyFilesTarget(string targetName, string targetToRunAfter, string sourceFiles, string destination)
+ {
+ TargetName = targetName;
+ TargetToRunAfter = targetToRunAfter;
+ SourceFiles = sourceFiles;
+ Destination = destination;
+ }
+
+ public string TargetName { get; private set; }
+ public string TargetToRunAfter { get; private set; }
+ public string SourceFiles { get; private set; }
+ public string Destination { get; private set; }
+ }
+}
From 8a48134f369ed780eb066bb457cb670b7dfe2c6c Mon Sep 17 00:00:00 2001
From: Luke Westendorf
Date: Fri, 5 Apr 2019 15:39:08 -0700
Subject: [PATCH 6/7] Addressing code review feedback
---
.../Microsoft.NET.Publish.Tests/PublishItemsOutputGroupTests.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/Tests/Microsoft.NET.Publish.Tests/PublishItemsOutputGroupTests.cs b/src/Tests/Microsoft.NET.Publish.Tests/PublishItemsOutputGroupTests.cs
index 2ce5832c9a61..1e90d2dcc334 100644
--- a/src/Tests/Microsoft.NET.Publish.Tests/PublishItemsOutputGroupTests.cs
+++ b/src/Tests/Microsoft.NET.Publish.Tests/PublishItemsOutputGroupTests.cs
@@ -17,7 +17,7 @@ public PublishItemsOutputGroupTests(ITestOutputHelper log) : base(log)
{
}
- private static List FrameworkAssemblies = new List()
+ private readonly static List FrameworkAssemblies = new List()
{
"api-ms-win-core-console-l1-1-0.dll",
"System.Runtime.dll",
From b0857023ef0292b1aa4675ca71d958c2b913adc6 Mon Sep 17 00:00:00 2001
From: Luke Westendorf
Date: Fri, 5 Apr 2019 19:08:01 -0700
Subject: [PATCH 7/7] Fixing test
---
.../Microsoft.NET.Publish.Tests/PublishItemsOutputGroupTests.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/Tests/Microsoft.NET.Publish.Tests/PublishItemsOutputGroupTests.cs b/src/Tests/Microsoft.NET.Publish.Tests/PublishItemsOutputGroupTests.cs
index 1e90d2dcc334..e101cbc29eda 100644
--- a/src/Tests/Microsoft.NET.Publish.Tests/PublishItemsOutputGroupTests.cs
+++ b/src/Tests/Microsoft.NET.Publish.Tests/PublishItemsOutputGroupTests.cs
@@ -47,7 +47,7 @@ public void GroupPopulatedWithRid()
// Check for the existence of a few specific files that should be in the directory where the
// contents of PublishItemsOutputGroup were dumped to make sure it's getting populated.
- testOutputDir.Should().HaveFile($"{testProject.Name}{Constants.ExeSuffix}");
+ testOutputDir.Should().HaveFile($"{testProject.Name}.exe");
testOutputDir.Should().HaveFiles(FrameworkAssemblies);
}