diff --git a/TestAssets/TestProjects/TestLibraryWithConfiguration/Helper.cs b/TestAssets/TestProjects/TestLibraryWithConfiguration/Helper.cs
new file mode 100644
index 000000000..8c643796b
--- /dev/null
+++ b/TestAssets/TestProjects/TestLibraryWithConfiguration/Helper.cs
@@ -0,0 +1,24 @@
+// 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;
+
+namespace TestLibrary
+{
+ public static class Helper
+ {
+ ///
+ /// Gets the message from the helper. This comment is here to help test XML documentation file generation, please do not remove it.
+ ///
+ /// A message
+ public static string GetMessage()
+ {
+ return "This string came from the test library!";
+ }
+
+ public static void SayHi()
+ {
+ Console.WriteLine("Hello there!");
+ }
+ }
+}
diff --git a/TestAssets/TestProjects/TestLibraryWithConfiguration/project.json b/TestAssets/TestProjects/TestLibraryWithConfiguration/project.json
new file mode 100644
index 000000000..b15199995
--- /dev/null
+++ b/TestAssets/TestProjects/TestLibraryWithConfiguration/project.json
@@ -0,0 +1,19 @@
+{
+ "version": "1.0.0-*",
+ "compilationOptions": {
+ "nowarn": [ "CS1591" ],
+ "xmlDoc": true,
+ "additionalArguments": [ "-highentropyva+" ]
+ },
+ "dependencies": {
+ "NETStandard.Library": "1.0.0-rc2-23811"
+ },
+ "configurations": {
+ "Test": {
+
+ }
+ },
+ "frameworks": {
+ "dnxcore50": { }
+ }
+}
diff --git a/scripts/dotnet-cli-build/TestTargets.cs b/scripts/dotnet-cli-build/TestTargets.cs
index 6e28d2c0b..cb40c935b 100644
--- a/scripts/dotnet-cli-build/TestTargets.cs
+++ b/scripts/dotnet-cli-build/TestTargets.cs
@@ -26,6 +26,7 @@ namespace Microsoft.DotNet.Cli.Build
"dotnet-compile.Tests",
"dotnet-compile.UnitTests",
"dotnet-build.Tests",
+ "dotnet-pack.Tests",
"Microsoft.DotNet.Cli.Utils.Tests",
"Microsoft.DotNet.Compiler.Common.Tests",
"ArgumentForwardingTests"
diff --git a/src/dotnet/commands/dotnet-pack/ArtifactPathsCalculator.cs b/src/dotnet/commands/dotnet-pack/ArtifactPathsCalculator.cs
index 7ad828377..1cd19120e 100644
--- a/src/dotnet/commands/dotnet-pack/ArtifactPathsCalculator.cs
+++ b/src/dotnet/commands/dotnet-pack/ArtifactPathsCalculator.cs
@@ -36,7 +36,8 @@ namespace Microsoft.DotNet.Tools.Pack
var outputPath = Path.Combine(
_project.ProjectDirectory,
- Constants.BinDirectoryName);
+ Constants.BinDirectoryName,
+ _configuration);
return outputPath;
}
diff --git a/test/dotnet-pack.Tests/PackTests.cs b/test/dotnet-pack.Tests/PackTests.cs
new file mode 100644
index 000000000..a0735d1fe
--- /dev/null
+++ b/test/dotnet-pack.Tests/PackTests.cs
@@ -0,0 +1,74 @@
+// 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.IO;
+using Microsoft.DotNet.Tools.Test.Utilities;
+using Xunit;
+
+namespace Microsoft.DotNet.Tools.Compiler.Tests
+{
+ public class PackTests : TestBase
+ {
+ private readonly string _testProjectsRoot;
+
+ public PackTests()
+ {
+ _testProjectsRoot = Path.Combine(AppContext.BaseDirectory, "TestAssets", "TestProjects");
+ }
+
+ [Fact]
+ public void OutputsPackagesToConfigurationSubdirWhenOutputParameterIsNotPassed()
+ {
+ var root = Temp.CreateDirectory();
+
+ var testLibDir = root.CreateDirectory("TestLibrary");
+ var sourceTestLibDir = Path.Combine(_testProjectsRoot, "TestLibraryWithConfiguration");
+
+ CopyProjectToTempDir(sourceTestLibDir, testLibDir);
+
+ var testProject = GetProjectPath(testLibDir);
+ var buildCommand = new PackCommand(testProject, configuration: "Test");
+ var result = buildCommand.Execute();
+ result.Should().Pass();
+
+ var outputDir = new DirectoryInfo(Path.Combine(testLibDir.Path, "bin", "Test"));
+ outputDir.Should().Exist();
+ outputDir.Should().HaveFiles(new [] { "TestLibrary.1.0.0.nupkg" , "TestLibrary.1.0.0.symbols.nupkg" });
+ }
+
+ [Fact]
+ public void OutputsPackagesFlatIntoOutputDirWhenOutputParameterIsPassed()
+ {
+ var root = Temp.CreateDirectory();
+
+ var testLibDir = root.CreateDirectory("TestLibrary");
+ var sourceTestLibDir = Path.Combine(_testProjectsRoot, "TestLibraryWithConfiguration");
+
+ CopyProjectToTempDir(sourceTestLibDir, testLibDir);
+
+ var outputDir = new DirectoryInfo(Path.Combine(testLibDir.Path, "bin2"));
+ var testProject = GetProjectPath(testLibDir);
+ var buildCommand = new PackCommand(testProject, output: outputDir.FullName);
+ var result = buildCommand.Execute();
+ result.Should().Pass();
+
+ outputDir.Should().Exist();
+ outputDir.Should().HaveFiles(new[] { "TestLibrary.1.0.0.nupkg", "TestLibrary.1.0.0.symbols.nupkg" });
+ }
+
+ private void CopyProjectToTempDir(string projectDir, TempDirectory tempDir)
+ {
+ // copy all the files to temp dir
+ foreach (var file in Directory.EnumerateFiles(projectDir))
+ {
+ tempDir.CopyFile(file);
+ }
+ }
+
+ private string GetProjectPath(TempDirectory projectDir)
+ {
+ return Path.Combine(projectDir.Path, "project.json");
+ }
+ }
+}
diff --git a/test/dotnet-pack.Tests/dotnet-pack.Tests.xproj b/test/dotnet-pack.Tests/dotnet-pack.Tests.xproj
new file mode 100644
index 000000000..961c2bf36
--- /dev/null
+++ b/test/dotnet-pack.Tests/dotnet-pack.Tests.xproj
@@ -0,0 +1,19 @@
+
+
+
+ 14.0.24720
+ $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)
+
+
+
+ 5fda6d37-3a3e-4333-ba5c-f0b28be316f4
+ dotnet-pack.Tests
+ ..\..\artifacts\obj\$(MSBuildProjectName)
+ ..\..\artifacts\bin\$(MSBuildProjectName)\
+
+
+
+ 2.0
+
+
+
\ No newline at end of file
diff --git a/test/dotnet-pack.Tests/project.json b/test/dotnet-pack.Tests/project.json
new file mode 100644
index 000000000..7ea509721
--- /dev/null
+++ b/test/dotnet-pack.Tests/project.json
@@ -0,0 +1,27 @@
+{
+ "version": "1.0.0-*",
+
+ "dependencies": {
+ "NETStandard.Library": "1.0.0-rc2-23811",
+
+ "Microsoft.DotNet.Tools.Tests.Utilities": { "target": "project" },
+ "Microsoft.DotNet.Cli.Utils": {
+ "target": "project"
+ },
+
+ "xunit": "2.1.0",
+ "dotnet-test-xunit": "1.0.0-dev-48273-16"
+ },
+
+ "frameworks": {
+ "dnxcore50": {
+ "imports": "portable-net451+win8"
+ }
+ },
+
+ "content": [
+ "../../TestAssets/TestProjects/TestLibraryWithConfiguration/*"
+ ],
+
+ "testRunner": "xunit"
+}