Skip to content

Commit 5ac47d5

Browse files
committed
Make sure the Chocolatey meta-package is published after the portable package
1 parent bb071c0 commit 5ac47d5

File tree

1 file changed

+22
-18
lines changed

1 file changed

+22
-18
lines changed

build/publish/Tasks/PublishChocolatey.cs

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public class PublishChocolatey : FrostingTask<BuildContext>
1313

1414
[TaskName(nameof(PublishChocolateyInternal))]
1515
[TaskDescription("Publish chocolatey packages")]
16-
public class PublishChocolateyInternal : FrostingTask<BuildContext>
16+
public class PublishChocolateyInternal : AsyncFrostingTask<BuildContext>
1717
{
1818
public override bool ShouldRun(BuildContext context)
1919
{
@@ -25,7 +25,7 @@ public override bool ShouldRun(BuildContext context)
2525
return shouldRun;
2626
}
2727

28-
public override void Run(BuildContext context)
28+
public override async Task RunAsync(BuildContext context)
2929
{
3030
var apiKey = context.Credentials?.Chocolatey?.ApiKey;
3131
if (string.IsNullOrEmpty(apiKey))
@@ -34,26 +34,30 @@ public override void Run(BuildContext context)
3434
}
3535

3636
var nugetVersion = context.Version!.NugetVersion;
37-
foreach (var (packageName, filePath, _) in context.Packages.Where(x => x.IsChocoPackage))
37+
var packages = context.Packages
38+
.Where(x => x.IsChocoPackage)
39+
.OrderByDescending(x => x.PackageName);
40+
foreach (var (packageName, filePath, _) in packages)
3841
{
39-
if (!IsPackagePublished(context, packageName, nugetVersion))
42+
if (IsPackagePublished(context, packageName, nugetVersion)) continue;
43+
try
4044
{
41-
try
45+
context.Information($"Package {packageName}, version {nugetVersion} is being published.");
46+
context.ChocolateyPush(filePath.FullPath, new ChocolateyPushSettings
4247
{
43-
context.Information($"Package {packageName}, version {nugetVersion} is being published.");
44-
context.ChocolateyPush(filePath.FullPath, new ChocolateyPushSettings
45-
{
46-
ApiKey = apiKey,
47-
Source = Constants.ChocolateyUrl,
48-
Force = true
49-
});
50-
}
51-
catch (Exception)
52-
{
53-
context.Warning($"There is an exception publishing the Package {packageName}.");
54-
// chocolatey sometimes fails with an error, even if the package gets pushed
55-
}
48+
ApiKey = apiKey,
49+
Source = Constants.ChocolateyUrl,
50+
Force = true
51+
});
52+
}
53+
catch (Exception)
54+
{
55+
context.Warning($"There is an exception publishing the Package {packageName}.");
56+
// chocolatey sometimes fails with an error, even if the package gets pushed
5657
}
58+
59+
// wait 5 seconds to avoid the meta-package to be published before the other packages
60+
await Task.Delay(TimeSpan.FromSeconds(5));
5761
}
5862
}
5963

0 commit comments

Comments
 (0)