Merge pull request #2437 from dotnet/pakrym/publish-base-path
Fix publish when build was ran using build-base-path
This commit is contained in:
commit
6184943910
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
|
||||
var exporter = context.CreateExporter(configuration);
|
||||
var exporter = context.CreateExporter(configuration, buildBasePath);
|
||||
|
||||
var isPortable = string.IsNullOrEmpty(context.RuntimeIdentifier);
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
|
|||
private Project _project;
|
||||
private readonly string _projectPath;
|
||||
private readonly string _outputDirectory;
|
||||
private readonly string _buidBasePathDirectory;
|
||||
private readonly string _buildBasePathDirectory;
|
||||
private readonly string _configuration;
|
||||
private readonly string _framework;
|
||||
private readonly string _versionSuffix;
|
||||
|
@ -44,9 +44,9 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
|
|||
{
|
||||
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(
|
||||
string projectPath,
|
||||
string output="",
|
||||
string buidBasePath="",
|
||||
string buildBasePath = "",
|
||||
string configuration="",
|
||||
string framework="",
|
||||
string runtime="",
|
||||
|
@ -224,7 +224,7 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
|
|||
_project = ProjectReader.GetProject(projectPath);
|
||||
|
||||
_outputDirectory = output;
|
||||
_buidBasePathDirectory = buidBasePath;
|
||||
_buildBasePathDirectory = buildBasePath;
|
||||
_configuration = configuration;
|
||||
_versionSuffix = versionSuffix;
|
||||
_framework = framework;
|
||||
|
|
|
@ -21,8 +21,15 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
|
|||
private readonly string _config;
|
||||
private readonly bool _noBuild;
|
||||
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")
|
||||
{
|
||||
_path = projectPath;
|
||||
|
@ -32,6 +39,7 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
|
|||
_output = output;
|
||||
_config = config;
|
||||
_noBuild = noBuild;
|
||||
_buidBasePathDirectory = buildBasePath;
|
||||
}
|
||||
|
||||
public override CommandResult Execute(string args = "")
|
||||
|
@ -93,7 +101,7 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
|
|||
|
||||
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}";
|
||||
|
@ -101,5 +109,6 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
|
|||
private string OutputOption => string.IsNullOrEmpty(_output) ? "" : $"-o \"{_output}\"";
|
||||
private string ConfigOption => string.IsNullOrEmpty(_config) ? "" : $"-c {_output}";
|
||||
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),
|
||||
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)
|
||||
.ExecuteWithCapturedOutput().Should().Pass();
|
||||
|
||||
|
|
|
@ -132,6 +132,21 @@ namespace Microsoft.DotNet.Tools.Publish.Tests
|
|||
}
|
||||
}
|
||||
|
||||
[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]
|
||||
public void LibraryPublishTest()
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue