@@ -13,7 +13,7 @@ public class PublishChocolatey : FrostingTask<BuildContext>
13
13
14
14
[ TaskName ( nameof ( PublishChocolateyInternal ) ) ]
15
15
[ TaskDescription ( "Publish chocolatey packages" ) ]
16
- public class PublishChocolateyInternal : FrostingTask < BuildContext >
16
+ public class PublishChocolateyInternal : AsyncFrostingTask < BuildContext >
17
17
{
18
18
public override bool ShouldRun ( BuildContext context )
19
19
{
@@ -25,7 +25,7 @@ public override bool ShouldRun(BuildContext context)
25
25
return shouldRun ;
26
26
}
27
27
28
- public override void Run ( BuildContext context )
28
+ public override async Task RunAsync ( BuildContext context )
29
29
{
30
30
var apiKey = context . Credentials ? . Chocolatey ? . ApiKey ;
31
31
if ( string . IsNullOrEmpty ( apiKey ) )
@@ -34,26 +34,30 @@ public override void Run(BuildContext context)
34
34
}
35
35
36
36
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 )
38
41
{
39
- if ( ! IsPackagePublished ( context , packageName , nugetVersion ) )
42
+ if ( IsPackagePublished ( context , packageName , nugetVersion ) ) continue ;
43
+ try
40
44
{
41
- try
45
+ context . Information ( $ "Package { packageName } , version { nugetVersion } is being published.") ;
46
+ context . ChocolateyPush ( filePath . FullPath , new ChocolateyPushSettings
42
47
{
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
56
57
}
58
+
59
+ // wait 5 seconds to avoid the meta-package to be published before the other packages
60
+ await Task . Delay ( TimeSpan . FromSeconds ( 5 ) ) ;
57
61
}
58
62
}
59
63
0 commit comments