Fix dontet pack with buildbasepath
This commit is contained in:
parent
7407a898e0
commit
0037e0aba9
5 changed files with 35 additions and 15 deletions
|
@ -12,24 +12,19 @@ namespace Microsoft.DotNet.Tools.Pack
|
||||||
internal class BuildProjectCommand
|
internal class BuildProjectCommand
|
||||||
{
|
{
|
||||||
private readonly Project _project;
|
private readonly Project _project;
|
||||||
private readonly ArtifactPathsCalculator _artifactPathsCalculator;
|
|
||||||
|
|
||||||
private readonly string _buildBasePath;
|
private readonly string _buildBasePath;
|
||||||
private readonly string _configuration;
|
private readonly string _configuration;
|
||||||
|
|
||||||
private readonly string _versionSuffix;
|
private readonly string _versionSuffix;
|
||||||
|
|
||||||
private bool SkipBuild => _artifactPathsCalculator.CompiledArtifactsPathSet;
|
|
||||||
|
|
||||||
public BuildProjectCommand(
|
public BuildProjectCommand(
|
||||||
Project project,
|
Project project,
|
||||||
ArtifactPathsCalculator artifactPathsCalculator,
|
|
||||||
string buildBasePath,
|
string buildBasePath,
|
||||||
string configuration,
|
string configuration,
|
||||||
string versionSuffix)
|
string versionSuffix)
|
||||||
{
|
{
|
||||||
_project = project;
|
_project = project;
|
||||||
_artifactPathsCalculator = artifactPathsCalculator;
|
|
||||||
_buildBasePath = buildBasePath;
|
_buildBasePath = buildBasePath;
|
||||||
_configuration = configuration;
|
_configuration = configuration;
|
||||||
_versionSuffix = versionSuffix;
|
_versionSuffix = versionSuffix;
|
||||||
|
@ -37,11 +32,6 @@ namespace Microsoft.DotNet.Tools.Pack
|
||||||
|
|
||||||
public int Execute()
|
public int Execute()
|
||||||
{
|
{
|
||||||
if (SkipBuild)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_project.Files.SourceFiles.Any())
|
if (_project.Files.SourceFiles.Any())
|
||||||
{
|
{
|
||||||
var argsBuilder = new List<string>();
|
var argsBuilder = new List<string>();
|
||||||
|
|
|
@ -72,7 +72,7 @@ namespace Microsoft.DotNet.Tools.Compiler
|
||||||
int buildResult = 0;
|
int buildResult = 0;
|
||||||
if (!noBuild.HasValue())
|
if (!noBuild.HasValue())
|
||||||
{
|
{
|
||||||
var buildProjectCommand = new BuildProjectCommand(project, artifactPathsCalculator, buildBasePathValue, configValue, versionSuffixValue);
|
var buildProjectCommand = new BuildProjectCommand(project, buildBasePathValue, configValue, versionSuffixValue);
|
||||||
buildResult = buildProjectCommand.Execute();
|
buildResult = buildProjectCommand.Execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,7 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
|
||||||
{
|
{
|
||||||
private string _projectPath;
|
private string _projectPath;
|
||||||
private string _outputDirectory;
|
private string _outputDirectory;
|
||||||
|
private string _buildBasePath;
|
||||||
private string _tempOutputDirectory;
|
private string _tempOutputDirectory;
|
||||||
private string _configuration;
|
private string _configuration;
|
||||||
private string _versionSuffix;
|
private string _versionSuffix;
|
||||||
|
@ -23,6 +24,15 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
|
||||||
$"-o \"{_outputDirectory}\"";
|
$"-o \"{_outputDirectory}\"";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
private string BuildBasePathOption
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _buildBasePath == string.Empty ?
|
||||||
|
"" :
|
||||||
|
$"-b \"{_buildBasePath}\"";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private string TempOutputOption
|
private string TempOutputOption
|
||||||
{
|
{
|
||||||
|
@ -56,7 +66,8 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
|
||||||
|
|
||||||
public PackCommand(
|
public PackCommand(
|
||||||
string projectPath,
|
string projectPath,
|
||||||
string output="",
|
string output = "",
|
||||||
|
string buildBasePath = "",
|
||||||
string tempOutput="",
|
string tempOutput="",
|
||||||
string configuration="",
|
string configuration="",
|
||||||
string versionSuffix="")
|
string versionSuffix="")
|
||||||
|
@ -64,6 +75,7 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
|
||||||
{
|
{
|
||||||
_projectPath = projectPath;
|
_projectPath = projectPath;
|
||||||
_outputDirectory = output;
|
_outputDirectory = output;
|
||||||
|
_buildBasePath = buildBasePath;
|
||||||
_tempOutputDirectory = tempOutput;
|
_tempOutputDirectory = tempOutput;
|
||||||
_configuration = configuration;
|
_configuration = configuration;
|
||||||
_versionSuffix = versionSuffix;
|
_versionSuffix = versionSuffix;
|
||||||
|
@ -77,7 +89,7 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
|
||||||
|
|
||||||
private string BuildArgs()
|
private string BuildArgs()
|
||||||
{
|
{
|
||||||
return $"{_projectPath} {OutputOption} {TempOutputOption} {ConfigurationOption} {VersionSuffixOption}";
|
return $"{_projectPath} {OutputOption} {BuildBasePathOption} {TempOutputOption} {ConfigurationOption} {VersionSuffixOption}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.IO.Compression;
|
||||||
using FluentAssertions;
|
using FluentAssertions;
|
||||||
using Microsoft.DotNet.ProjectModel;
|
using Microsoft.DotNet.ProjectModel;
|
||||||
using Microsoft.DotNet.Tools.Test.Utilities;
|
using Microsoft.DotNet.Tools.Test.Utilities;
|
||||||
|
@ -78,6 +79,22 @@ namespace Microsoft.DotNet.Tools.Compiler.Tests
|
||||||
File.Exists(outputPackage).Should().BeTrue(outputPackage);
|
File.Exists(outputPackage).Should().BeTrue(outputPackage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void HasBuildOutputWhenUsingBuildBasePath()
|
||||||
|
{
|
||||||
|
var testInstance = TestAssetsManager.CreateTestInstance("TestLibraryWithConfiguration")
|
||||||
|
.WithLockFiles();
|
||||||
|
|
||||||
|
var cmd = new PackCommand(Path.Combine(testInstance.TestRoot, Project.FileName), buildBasePath: "buildBase");
|
||||||
|
cmd.Execute().Should().Pass();
|
||||||
|
|
||||||
|
var outputPackage = Path.Combine(testInstance.TestRoot, "bin", "Debug", "TestLibraryWithConfiguration.1.0.0.nupkg");
|
||||||
|
File.Exists(outputPackage).Should().BeTrue(outputPackage);
|
||||||
|
|
||||||
|
var zip = ZipFile.Open(outputPackage, ZipArchiveMode.Read);
|
||||||
|
zip.Entries.Should().Contain(e => e.FullName == "lib/dnxcore50/TestLibraryWithConfiguration.dll");
|
||||||
|
}
|
||||||
|
|
||||||
private void CopyProjectToTempDir(string projectDir, TempDirectory tempDir)
|
private void CopyProjectToTempDir(string projectDir, TempDirectory tempDir)
|
||||||
{
|
{
|
||||||
// copy all the files to temp dir
|
// copy all the files to temp dir
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"NETStandard.Library": "1.0.0-rc2-23811",
|
"NETStandard.Library": "1.0.0-rc2-23811",
|
||||||
|
"System.IO.Compression.ZipFile": "4.0.1-rc2-23811",
|
||||||
|
|
||||||
"Microsoft.DotNet.Tools.Tests.Utilities": { "target": "project" },
|
"Microsoft.DotNet.Tools.Tests.Utilities": { "target": "project" },
|
||||||
"Microsoft.DotNet.Cli.Utils": {
|
"Microsoft.DotNet.Cli.Utils": {
|
||||||
|
|
Loading…
Add table
Reference in a new issue