Skip to content

Commit

Permalink
Add support to set created mpak file name from CLI
Browse files Browse the repository at this point in the history
There is an existsing -n opti0on that sets the property MpakPath. This value needs to be passed into the method creating the mpak. Default value to null which will t hen automatically assign file name using DateTime.
  • Loading branch information
doingnz committed Feb 10, 2024
1 parent 6c523d6 commit 6c16788
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ protected override async ValueTask ExecuteCommand()
var postlinkDir = Path.Combine(file.Directory?.FullName ?? string.Empty, PackageManager.PostLinkDirectoryName);

Logger?.LogInformation($"Assembling the MPAK...");
var packagePath = await _packageManager.AssemblePackage(postlinkDir, packageDir, osVersion, Filter, true, CancellationToken);
var packagePath = await _packageManager.AssemblePackage(postlinkDir, packageDir, osVersion, MpakName, Filter, true, CancellationToken);

if (packagePath != null)
{
Expand Down
4 changes: 2 additions & 2 deletions Source/v2/Meadow.Package/IPackageManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ Task TrimApplication(
IList<string>? noLink = null,
CancellationToken? cancellationToken = null);

Task<string> AssemblePackage(
string contentSourceFolder,
Task<string> AssemblePackage(string contentSourceFolder,
string outputFolder,
string osVersion,
string? mpakName = null,
string filter = "*",
bool overwrite = false,
CancellationToken? cancellationToken = null);
Expand Down
7 changes: 4 additions & 3 deletions Source/v2/Meadow.Package/PackageManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,10 @@ public Task TrimApplication(

public const string PackageMetadataFileName = "info.json";

public Task<string> AssemblePackage(
string contentSourceFolder,
public Task<string> AssemblePackage(string contentSourceFolder,
string outputFolder,
string osVersion,
string? mpakName = null,
string filter = "*",
bool overwrite = false,
CancellationToken? cancellationToken = null)
Expand All @@ -177,7 +177,8 @@ public Task<string> AssemblePackage(
di.Create();
}

var mpakName = Path.Combine(outputFolder, $"{DateTime.UtcNow:yyyyMMddff}.mpak");
// uncomment to force ".mpak" extension. mpakName = Path.ChangeExtension(mpakName, ".mpak");
mpakName = Path.Combine(outputFolder, string.IsNullOrWhiteSpace(mpakName) ? $"{DateTime.UtcNow:yyyyMMddff}.mpak" : mpakName);

if (File.Exists(mpakName))
{
Expand Down

0 comments on commit 6c16788

Please sign in to comment.