12
12
using Cake . Common . Tools . DotNet . Build ;
13
13
using Cake . Common . Tools . DotNet . Publish ;
14
14
using System . Collections . Generic ;
15
+ using Cake . Common . Tools . DotNet . Test ;
16
+ using System . Net ;
15
17
16
18
public static class Program
17
19
{
@@ -29,8 +31,7 @@ public class BuildContext : FrostingContext
29
31
public string BuildConfiguration { get ; }
30
32
public string SrcDirectoryPath { get ; }
31
33
public string BuildArtifactsPath { get ; }
32
- public WebsitePaths WebClientPaths { get ; }
33
- public FeedbackFunctionsProjectPaths AzFunctionsPaths { get ; }
34
+ public AppPaths AppPaths { get ; }
34
35
35
36
public BuildContext ( ICakeContext context )
36
37
: base ( context )
@@ -40,8 +41,7 @@ public BuildContext(ICakeContext context)
40
41
SrcDirectoryPath = context . Argument < string > ( "srcDirectoryPath" ) ;
41
42
BuildArtifactsPath = context . Argument < string > ( "buildArtifactsPath" ) ;
42
43
43
- WebClientPaths = WebsitePaths . LoadFromContext ( context , BuildConfiguration , SrcDirectoryPath , BuildArtifactsPath ) ;
44
- AzFunctionsPaths = FeedbackFunctionsProjectPaths . LoadFromContext ( context , BuildConfiguration , SrcDirectoryPath , BuildArtifactsPath ) ;
44
+ AppPaths = AppPaths . LoadFromContext ( context , BuildConfiguration , SrcDirectoryPath , BuildArtifactsPath ) ;
45
45
}
46
46
}
47
47
@@ -63,7 +63,8 @@ public sealed class CleanTask : FrostingTask<BuildContext>
63
63
{
64
64
public override void Run ( BuildContext context )
65
65
{
66
- context . CleanDirectory ( context . WebClientPaths . OutDir ) ;
66
+ context . CleanDirectory ( context . AppPaths . AzFunctionsProject . OutDir ) ;
67
+ context . CleanDirectory ( context . AppPaths . WebClientProject . OutDir ) ;
67
68
}
68
69
}
69
70
@@ -75,8 +76,8 @@ public override void Run(BuildContext context)
75
76
{
76
77
var buildFuncs = new [ ]
77
78
{
78
- ( ) => BuildDotnetApp ( context , context . WebClientPaths . CsprojFile ) ,
79
- ( ) => BuildDotnetApp ( context , context . AzFunctionsPaths . CsprojFile ) ,
79
+ ( ) => BuildDotnetApp ( context , context . AppPaths . AzFunctionsProject . CsprojFile ) ,
80
+ ( ) => BuildDotnetApp ( context , context . AppPaths . WebClientProject . CsprojFile ) ,
80
81
} ;
81
82
82
83
var runner = Parallel . ForEach ( buildFuncs , func => func ( ) ) ;
@@ -104,24 +105,23 @@ public sealed class RunUnitTestsTask : FrostingTask<BuildContext>
104
105
{
105
106
public override void Run ( BuildContext context )
106
107
{
107
- //TODO: Add some tests
108
- //var testSettings = new DotNetTestSettings()
109
- //{
110
- // Configuration = context.BuildConfiguration,
111
- // NoBuild = true,
112
- // ArgumentCustomization = (args) => args.Append("/p:CollectCoverage=true /p:CoverletOutputFormat=cobertura --logger trx")
113
- //};
114
-
115
- //var runTestsFuncs = new[]
116
- //{
117
- // () => context.DotNetTest(context.WebClientPaths.UnitTestProj, testSettings),
118
- //};
119
-
120
- //var runner = Parallel.ForEach(runTestsFuncs, func => func());
121
- //while (!runner.IsCompleted)
122
- //{
123
- // Thread.Sleep(100);
124
- //}
108
+ var testSettings = new DotNetTestSettings ( )
109
+ {
110
+ Configuration = context . BuildConfiguration ,
111
+ NoBuild = true ,
112
+ ArgumentCustomization = ( args ) => args . Append ( "/p:CollectCoverage=true /p:CoverletOutputFormat=cobertura --logger trx" )
113
+ } ;
114
+
115
+ var runTestsFuncs = new [ ]
116
+ {
117
+ ( ) => context . DotNetTest ( context . AppPaths . UnitTestsCsProj , testSettings ) ,
118
+ } ;
119
+
120
+ var runner = Parallel . ForEach ( runTestsFuncs , func => func ( ) ) ;
121
+ while ( ! runner . IsCompleted )
122
+ {
123
+ Thread . Sleep ( 100 ) ;
124
+ }
125
125
}
126
126
}
127
127
@@ -133,8 +133,8 @@ public override void Run(BuildContext context)
133
133
{
134
134
var buildFuncs = new List < Action >
135
135
{
136
- ( ) => PublishWebClient ( context ) ,
137
- ( ) => PublishAzureFunctionsProject ( context , context . AzFunctionsPaths ) ,
136
+ ( ) => PublishWebClient ( context , context . AppPaths . WebClientProject ) ,
137
+ ( ) => PublishAzureFunctionsProject ( context , context . AppPaths . AzFunctionsProject ) ,
138
138
} ;
139
139
140
140
var runner = Parallel . ForEach ( buildFuncs , func => func ( ) ) ;
@@ -144,59 +144,59 @@ public override void Run(BuildContext context)
144
144
}
145
145
}
146
146
147
- private void PublishWebClient ( BuildContext context )
147
+ private void PublishWebClient ( BuildContext context , AppPaths . DotNetProject webClient )
148
148
{
149
149
var settings = new DotNetPublishSettings ( )
150
150
{
151
151
NoRestore = true ,
152
152
NoBuild = true ,
153
153
Configuration = context . BuildConfiguration ,
154
- OutputDirectory = context . WebClientPaths . OutDir ,
154
+ OutputDirectory = webClient . OutDir ,
155
155
} ;
156
156
157
- context . DotNetPublish ( context . WebClientPaths . CsprojFile , settings ) ;
157
+ context . DotNetPublish ( webClient . CsprojFile , settings ) ;
158
158
159
159
//Now that the code is published, create the compressed folder
160
- if ( ! Directory . Exists ( context . WebClientPaths . ZipOutDir ) )
160
+ if ( ! Directory . Exists ( webClient . ZipOutDir ) )
161
161
{
162
- _ = Directory . CreateDirectory ( context . WebClientPaths . ZipOutDir ) ;
162
+ _ = Directory . CreateDirectory ( webClient . ZipOutDir ) ;
163
163
}
164
164
165
- if ( File . Exists ( context . WebClientPaths . ZipOutFilePath ) )
165
+ if ( File . Exists ( webClient . ZipOutFilePath ) )
166
166
{
167
- File . Delete ( context . WebClientPaths . ZipOutFilePath ) ;
167
+ File . Delete ( webClient . ZipOutFilePath ) ;
168
168
}
169
169
170
- ZipFile . CreateFromDirectory ( context . WebClientPaths . OutDir , context . WebClientPaths . ZipOutFilePath ) ;
171
- context . Log . Information ( $ "Output web app zip file to: { context . WebClientPaths . ZipOutFilePath } ") ;
170
+ ZipFile . CreateFromDirectory ( webClient . OutDir , webClient . ZipOutFilePath ) ;
171
+ context . Log . Information ( $ "Output web app zip file to: { webClient . ZipOutFilePath } ") ;
172
172
}
173
173
174
- private void PublishAzureFunctionsProject ( BuildContext context , FeedbackFunctionsProjectPaths apiPaths )
174
+ private void PublishAzureFunctionsProject ( BuildContext context , AppPaths . DotNetProject funcsProj )
175
175
{
176
176
var settings = new DotNetPublishSettings ( )
177
177
{
178
178
NoRestore = false ,
179
179
NoBuild = false ,
180
180
Configuration = context . BuildConfiguration ,
181
- OutputDirectory = apiPaths . OutDir ,
181
+ OutputDirectory = funcsProj . OutDir ,
182
182
Runtime = "linux-x64" ,
183
183
} ;
184
184
185
- context . DotNetPublish ( apiPaths . CsprojFile , settings ) ;
185
+ context . DotNetPublish ( funcsProj . CsprojFile , settings ) ;
186
186
187
187
//Now that the code is published, create the compressed folder
188
- if ( ! Directory . Exists ( apiPaths . ZipOutDir ) )
188
+ if ( ! Directory . Exists ( funcsProj . ZipOutDir ) )
189
189
{
190
- _ = Directory . CreateDirectory ( apiPaths . ZipOutDir ) ;
190
+ _ = Directory . CreateDirectory ( funcsProj . ZipOutDir ) ;
191
191
}
192
192
193
- if ( File . Exists ( apiPaths . ZipOutPath ) )
193
+ if ( File . Exists ( funcsProj . ZipOutFilePath ) )
194
194
{
195
- File . Delete ( apiPaths . ZipOutPath ) ;
195
+ File . Delete ( funcsProj . ZipOutFilePath ) ;
196
196
}
197
197
198
- ZipFile . CreateFromDirectory ( apiPaths . OutDir , apiPaths . ZipOutPath ) ;
199
- context . Log . Information ( $ "Output functions zip file to: { apiPaths . ZipOutPath } ") ;
198
+ ZipFile . CreateFromDirectory ( funcsProj . OutDir , funcsProj . ZipOutFilePath ) ;
199
+ context . Log . Information ( $ "Output functions zip file to: { funcsProj . ZipOutFilePath } ") ;
200
200
}
201
201
}
202
202
0 commit comments