@@ -4,18 +4,14 @@ namespace Skyline.DataMiner.Sdk.Tasks
4
4
{
5
5
using System ;
6
6
using System . Diagnostics ;
7
- using System . IO . Compression ;
8
7
using System . Threading ;
9
8
10
9
using Microsoft . Build . Framework ;
11
10
using Microsoft . Extensions . Configuration ;
12
- using Microsoft . Extensions . Configuration . EnvironmentVariables ;
13
- using Microsoft . Extensions . Configuration . UserSecrets ;
14
11
15
12
using Nito . AsyncEx . Synchronous ;
16
13
17
14
using Skyline . DataMiner . CICD . FileSystem ;
18
- using Skyline . DataMiner . Net . SLConfiguration ;
19
15
using Skyline . DataMiner . Sdk . CatalogService ;
20
16
21
17
using static Skyline . DataMiner . Sdk . CatalogService . HttpCatalogService ;
@@ -30,6 +26,8 @@ public class PublishToCatalog : Task, ICancelableTask
30
26
31
27
public string BaseOutputPath { get ; set ; }
32
28
29
+ public string CatalogPublishKeyName { get ; set ; }
30
+
33
31
public string Configuration { get ; set ; }
34
32
35
33
public string PackageId { get ; set ; }
@@ -38,12 +36,10 @@ public class PublishToCatalog : Task, ICancelableTask
38
36
39
37
public string ProjectDirectory { get ; set ; }
40
38
41
- public string VersionComment { get ; set ; }
42
-
43
- public string CatalogPublishKeyName { get ; set ; }
44
-
45
39
public string UserSecretsId { get ; set ; }
46
40
41
+ public string VersionComment { get ; set ; }
42
+
47
43
#endregion Properties set from targets file
48
44
49
45
/// <summary>
@@ -82,7 +78,6 @@ public override bool Execute()
82
78
Log . LogMessage ( MessageImportance . High , $ "Found Package: { packagePath } .") ;
83
79
Log . LogMessage ( MessageImportance . High , $ "Found Catalog Information: { catalogInfoPath } .") ;
84
80
85
-
86
81
var builder = new ConfigurationBuilder ( ) ;
87
82
88
83
if ( ! String . IsNullOrWhiteSpace ( UserSecretsId ) )
@@ -115,25 +110,26 @@ public override bool Execute()
115
110
// Request if Version already exists? If not, then release a new version?
116
111
// If Version already exists, update the ReadMe & Images.
117
112
118
- var cts = new CancellationTokenSource ( ) ;
119
- var catalogService = CatalogServiceFactory . CreateWithHttp ( new System . Net . Http . HttpClient ( ) ) ;
120
- byte [ ] catalogData = fs . File . ReadAllBytes ( catalogInfoPath ) ;
121
- Log . LogMessage ( MessageImportance . High , $ "Registering Catalog Metadata...") ;
122
- var catalogResult = catalogService . RegisterCatalogAsync ( catalogData , organizationKey , cts . Token ) . WaitAndUnwrapException ( ) ;
123
- Log . LogMessage ( MessageImportance . High , $ "Done") ;
124
-
125
- try
113
+ using ( var cts = new CancellationTokenSource ( ) )
126
114
{
127
- Log . LogMessage ( MessageImportance . High , $ "Uploading new version to { catalogResult . ArtifactId } ...") ;
128
- byte [ ] packageData = fs . File . ReadAllBytes ( packagePath ) ;
129
- catalogService . UploadVersionAsync ( packageData , fs . Path . GetFileName ( packagePath ) , organizationKey , catalogResult . ArtifactId , PackageVersion , VersionComment , cts . Token ) . WaitAndUnwrapException ( ) ;
115
+ var catalogService = CatalogServiceFactory . CreateWithHttp ( new System . Net . Http . HttpClient ( ) ) ;
116
+ byte [ ] catalogData = fs . File . ReadAllBytes ( catalogInfoPath ) ;
117
+ Log . LogMessage ( MessageImportance . High , $ "Registering Catalog Metadata...") ;
118
+ var catalogResult = catalogService . RegisterCatalogAsync ( catalogData , organizationKey , cts . Token ) . WaitAndUnwrapException ( ) ;
130
119
Log . LogMessage ( MessageImportance . High , $ "Done") ;
131
- }
132
- catch ( VersionAlreadyExistsException )
133
- {
134
- Log . LogWarning ( "Version already exists! Only catalog details were updated." ) ;
135
- }
136
120
121
+ try
122
+ {
123
+ Log . LogMessage ( MessageImportance . High , $ "Uploading new version to { catalogResult . ArtifactId } ...") ;
124
+ byte [ ] packageData = fs . File . ReadAllBytes ( packagePath ) ;
125
+ catalogService . UploadVersionAsync ( packageData , fs . Path . GetFileName ( packagePath ) , organizationKey , catalogResult . ArtifactId , PackageVersion , VersionComment , cts . Token ) . WaitAndUnwrapException ( ) ;
126
+ Log . LogMessage ( MessageImportance . High , $ "Done") ;
127
+ }
128
+ catch ( VersionAlreadyExistsException )
129
+ {
130
+ Log . LogWarning ( "Version already exists! Only catalog details were updated." ) ;
131
+ }
132
+ }
137
133
if ( cancel )
138
134
{
139
135
return false ;
0 commit comments