77using System . IO ;
88using System . Threading ;
99using System . Threading . Tasks ;
10+ using Photon . Framework . Extensions ;
1011
1112namespace Jenkins . NET . Publishing . Scripts
1213{
@@ -17,7 +18,7 @@ public class Package : IBuildTask
1718
1819 public async Task RunAsync ( CancellationToken token )
1920 {
20- var packageDir = Path . Combine ( Context . WorkDirectory , "Packages " ) ;
21+ var packageDir = Path . Combine ( Context . ContentDirectory , "PublishPackages " ) ;
2122
2223 await BuildTools . BuildSolution ( Context , token ) ;
2324 await TestTools . UnitTest ( Context , token ) ;
@@ -38,22 +39,46 @@ private async Task CreateProjectPackage(CancellationToken token)
3839 Script = "Publish" ,
3940 Files = {
4041 new PackageFileDefinition {
41- Path = "Packages " ,
42+ Path = "Jenkins.Net.Publishing \\ bin \\ Debug \\ ** " ,
4243 Destination = "" ,
44+ } ,
45+ new PackageFileDefinition {
46+ Path = "PublishPackages" ,
47+ Destination = "PublishPackages" ,
4348 }
4449 }
4550 } ;
4651
4752 var version = Context . BuildNumber . ToString ( ) ;
48- var output = Path . Combine ( Context . BinDirectory , "Jenkins.Net.zip" ) ;
53+ var output = Path . Combine ( Context . ContentDirectory , "PublishPackages" , "Jenkins.Net.zip" ) ;
54+
55+ try {
56+ Context . WriteTagLine ( "Creating project package..." , ConsoleColor . White ) ;
57+
58+ await ProjectPackageTools . CreatePackage (
59+ definition : def ,
60+ rootPath : Context . ContentDirectory ,
61+ version : version ,
62+ outputFilename : output ) ;
63+
64+ Context . WriteTagLine ( "Created project package successfully." , ConsoleColor . White ) ;
65+ }
66+ catch ( Exception error ) {
67+ Context . WriteErrorBlock ( "Failed to create project package!" , error . UnfoldMessages ( ) ) ;
68+ throw ;
69+ }
70+
71+ try {
72+ Context . WriteTagLine ( "Publishing project package..." , ConsoleColor . White ) ;
4973
50- await ProjectPackageTools . CreatePackage (
51- definition : def ,
52- rootPath : Context . WorkDirectory ,
53- version : version ,
54- outputFilename : output ) ;
74+ await Context . Packages . PushProjectPackageAsync ( output , token ) ;
5575
56- await Context . Packages . PushProjectPackageAsync ( output , token ) ;
76+ Context . WriteTagLine ( "Published project package successfully." , ConsoleColor . White ) ;
77+ }
78+ catch ( Exception error ) {
79+ Context . WriteErrorBlock ( "Failed to publish project package!" , error . UnfoldMessages ( ) ) ;
80+ throw ;
81+ }
5782 }
5883
5984 private async Task CreateNugetPackage ( string packageDir , CancellationToken token )
0 commit comments