Fix pack output location

This commit is contained in:
Pavel Krymets 2016-02-16 10:20:23 -08:00
parent 9c7ec89392
commit 4d4f5ad895
7 changed files with 166 additions and 1 deletions

View file

@ -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
{
/// <summary>
/// Gets the message from the helper. This comment is here to help test XML documentation file generation, please do not remove it.
/// </summary>
/// <returns>A message</returns>
public static string GetMessage()
{
return "This string came from the test library!";
}
public static void SayHi()
{
Console.WriteLine("Hello there!");
}
}
}

View file

@ -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": { }
}
}

View file

@ -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"

View file

@ -36,7 +36,8 @@ namespace Microsoft.DotNet.Tools.Pack
var outputPath = Path.Combine(
_project.ProjectDirectory,
Constants.BinDirectoryName);
Constants.BinDirectoryName,
_configuration);
return outputPath;
}

View file

@ -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");
}
}
}

View file

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0.24720" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0.24720</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
</PropertyGroup>
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.Props" Condition="'$(VSToolsPath)' != ''" />
<PropertyGroup Label="Globals">
<ProjectGuid>5fda6d37-3a3e-4333-ba5c-f0b28be316f4</ProjectGuid>
<RootNamespace>dotnet-pack.Tests</RootNamespace>
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">..\..\artifacts\obj\$(MSBuildProjectName)</BaseIntermediateOutputPath>
<OutputPath Condition="'$(OutputPath)'=='' ">..\..\artifacts\bin\$(MSBuildProjectName)\</OutputPath>
</PropertyGroup>
<PropertyGroup>
<SchemaVersion>2.0</SchemaVersion>
</PropertyGroup>
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.targets" Condition="'$(VSToolsPath)' != ''" />
</Project>

View file

@ -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"
}