Fix publish when build was ran using build-base-path
This commit is contained in:
parent
1a0b9bba98
commit
cf0673333d
5 changed files with 33 additions and 9 deletions
|
@ -126,7 +126,7 @@ namespace Microsoft.DotNet.Tools.Publish
|
||||||
}
|
}
|
||||||
|
|
||||||
// Use a library exporter to collect publish assets
|
// Use a library exporter to collect publish assets
|
||||||
var exporter = context.CreateExporter(configuration);
|
var exporter = context.CreateExporter(configuration, buildBasePath);
|
||||||
|
|
||||||
var isPortable = string.IsNullOrEmpty(context.RuntimeIdentifier);
|
var isPortable = string.IsNullOrEmpty(context.RuntimeIdentifier);
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
|
||||||
private Project _project;
|
private Project _project;
|
||||||
private readonly string _projectPath;
|
private readonly string _projectPath;
|
||||||
private readonly string _outputDirectory;
|
private readonly string _outputDirectory;
|
||||||
private readonly string _buidBasePathDirectory;
|
private readonly string _buildBasePathDirectory;
|
||||||
private readonly string _configuration;
|
private readonly string _configuration;
|
||||||
private readonly string _framework;
|
private readonly string _framework;
|
||||||
private readonly string _versionSuffix;
|
private readonly string _versionSuffix;
|
||||||
|
@ -44,9 +44,9 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return _buidBasePathDirectory == string.Empty ?
|
return _buildBasePathDirectory == string.Empty ?
|
||||||
"" :
|
"" :
|
||||||
$"-b {_buidBasePathDirectory}";
|
$"-b {_buildBasePathDirectory}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -202,7 +202,7 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
|
||||||
public BuildCommand(
|
public BuildCommand(
|
||||||
string projectPath,
|
string projectPath,
|
||||||
string output="",
|
string output="",
|
||||||
string buidBasePath="",
|
string buildBasePath = "",
|
||||||
string configuration="",
|
string configuration="",
|
||||||
string framework="",
|
string framework="",
|
||||||
string runtime="",
|
string runtime="",
|
||||||
|
@ -224,7 +224,7 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
|
||||||
_project = ProjectReader.GetProject(projectPath);
|
_project = ProjectReader.GetProject(projectPath);
|
||||||
|
|
||||||
_outputDirectory = output;
|
_outputDirectory = output;
|
||||||
_buidBasePathDirectory = buidBasePath;
|
_buildBasePathDirectory = buildBasePath;
|
||||||
_configuration = configuration;
|
_configuration = configuration;
|
||||||
_versionSuffix = versionSuffix;
|
_versionSuffix = versionSuffix;
|
||||||
_framework = framework;
|
_framework = framework;
|
||||||
|
|
|
@ -21,8 +21,15 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
|
||||||
private readonly string _config;
|
private readonly string _config;
|
||||||
private readonly bool _noBuild;
|
private readonly bool _noBuild;
|
||||||
private readonly string _output;
|
private readonly string _output;
|
||||||
|
private readonly string _buidBasePathDirectory;
|
||||||
|
|
||||||
public PublishCommand(string projectPath, string framework = "", string runtime = "", string output = "", string config = "", bool forcePortable = false, bool noBuild = false)
|
public PublishCommand(string projectPath,
|
||||||
|
string framework = "",
|
||||||
|
string runtime = "",
|
||||||
|
string output = "",
|
||||||
|
string config = "",
|
||||||
|
bool noBuild = false,
|
||||||
|
string buildBasePath = "")
|
||||||
: base("dotnet")
|
: base("dotnet")
|
||||||
{
|
{
|
||||||
_path = projectPath;
|
_path = projectPath;
|
||||||
|
@ -32,6 +39,7 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
|
||||||
_output = output;
|
_output = output;
|
||||||
_config = config;
|
_config = config;
|
||||||
_noBuild = noBuild;
|
_noBuild = noBuild;
|
||||||
|
_buidBasePathDirectory = buildBasePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override CommandResult Execute(string args = "")
|
public override CommandResult Execute(string args = "")
|
||||||
|
@ -93,7 +101,7 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
|
||||||
|
|
||||||
private string BuildArgs()
|
private string BuildArgs()
|
||||||
{
|
{
|
||||||
return $"{_path} {FrameworkOption} {RuntimeOption} {OutputOption} {ConfigOption} {NoBuildFlag}";
|
return $"{_path} {FrameworkOption} {RuntimeOption} {OutputOption} {ConfigOption} {NoBuildFlag} {BuildBasePathOption}";
|
||||||
}
|
}
|
||||||
|
|
||||||
private string FrameworkOption => string.IsNullOrEmpty(_framework) ? "" : $"-f {_framework}";
|
private string FrameworkOption => string.IsNullOrEmpty(_framework) ? "" : $"-f {_framework}";
|
||||||
|
@ -101,5 +109,6 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
|
||||||
private string OutputOption => string.IsNullOrEmpty(_output) ? "" : $"-o \"{_output}\"";
|
private string OutputOption => string.IsNullOrEmpty(_output) ? "" : $"-o \"{_output}\"";
|
||||||
private string ConfigOption => string.IsNullOrEmpty(_config) ? "" : $"-c {_output}";
|
private string ConfigOption => string.IsNullOrEmpty(_config) ? "" : $"-c {_output}";
|
||||||
private string NoBuildFlag => _noBuild ? "--no-build" :"";
|
private string NoBuildFlag => _noBuild ? "--no-build" :"";
|
||||||
|
private string BuildBasePathOption => string.IsNullOrEmpty(_buidBasePathDirectory) ? "" : $"-b {_buidBasePathDirectory}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -79,7 +79,7 @@ namespace Microsoft.DotNet.Tools.Builder.Tests
|
||||||
|
|
||||||
new BuildCommand(GetProjectPath(_testAppDirDirInfo),
|
new BuildCommand(GetProjectPath(_testAppDirDirInfo),
|
||||||
output: outputValue != null ? Path.Combine(_testProjectsRoot, outputValue) : string.Empty,
|
output: outputValue != null ? Path.Combine(_testProjectsRoot, outputValue) : string.Empty,
|
||||||
buidBasePath: baseValue != null ? Path.Combine(_testProjectsRoot, baseValue) : string.Empty,
|
buildBasePath: baseValue != null ? Path.Combine(_testProjectsRoot, baseValue) : string.Empty,
|
||||||
framework: DefaultFramework)
|
framework: DefaultFramework)
|
||||||
.ExecuteWithCapturedOutput().Should().Pass();
|
.ExecuteWithCapturedOutput().Should().Pass();
|
||||||
|
|
||||||
|
|
|
@ -92,6 +92,21 @@ namespace Microsoft.DotNet.Tools.Publish.Tests
|
||||||
publishCommand.Execute().Should().Fail();
|
publishCommand.Execute().Should().Fail();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void PublishesWhenPrebuildWithBuildBasePath()
|
||||||
|
{
|
||||||
|
TestInstance instance = TestAssetsManager.CreateTestInstance("TestAppWithLibrary")
|
||||||
|
.WithLockFiles();
|
||||||
|
|
||||||
|
string basePath = Path.Combine(instance.TestRoot, "build");
|
||||||
|
string testProject = _getProjectJson(instance.TestRoot, "TestApp");
|
||||||
|
var buildCommand = new BuildCommand(testProject, buildBasePath: basePath);
|
||||||
|
buildCommand.Execute().Should().Pass();
|
||||||
|
|
||||||
|
var publishCommand = new PublishCommand(testProject, buildBasePath: basePath, noBuild: true);
|
||||||
|
publishCommand.Execute().Should().Pass();
|
||||||
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void LibraryPublishTest()
|
public void LibraryPublishTest()
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue