@@ -9,8 +9,8 @@ var configuration = Argument<string>("configuration", "Release");
9
9
// EXTERNAL NUGET TOOLS
10
10
//////////////////////////////////////////////////////////////////////
11
11
12
- #Tool "xunit.runner.console&version=2.4.1"
13
12
#Tool "GitVersion.CommandLine&version=5.8.1"
13
+ #Tool "xunit.runner.console&version=2.4.1"
14
14
15
15
//////////////////////////////////////////////////////////////////////
16
16
// EXTERNAL NUGET LIBRARIES
@@ -32,15 +32,15 @@ var solutionPaths = solutions.Select(solution => solution.GetDirectory());
32
32
33
33
var srcDir = Directory( "./src" ) ;
34
34
var artifactsDir = Directory( "./artifacts" ) ;
35
- var testResultsDir = artifactsDir + Directory ( "test-results" ) ;
35
+ var testResultsDir = System . IO . Path . Combine ( artifactsDir , Directory ( "test-results" ) ) ;
36
36
37
37
// NuGet
38
- var nupkgDestDir = artifactsDir + Directory ( "nuget-package" ) ;
38
+ var nupkgDestDir = System . IO . Path . Combine ( artifactsDir , Directory ( "nuget-package" ) ) ;
39
39
40
- // Gitversion
40
+ // GitVersion
41
41
var gitVersionPath = ToolsExePath( "GitVersion.exe" ) ;
42
- Dictionary < string , object > gitVersionOutput ;
43
42
var gitVersionConfigFilePath = "./GitVersionConfig.yaml" ;
43
+ Dictionary < string , object > gitVersionOutput;
44
44
45
45
// Versioning
46
46
string nugetVersion;
@@ -82,7 +82,8 @@ Teardown(_ =>
82
82
Task( "__Clean" )
83
83
. Does ( ( ) =>
84
84
{
85
- DirectoryPath [ ] cleanDirectories = new DirectoryPath [ ] {
85
+ DirectoryPath [ ] cleanDirectories = new DirectoryPath [ ]
86
+ {
86
87
testResultsDir ,
87
88
nupkgDestDir ,
88
89
artifactsDir
@@ -99,7 +100,7 @@ Task("__Clean")
99
100
}
100
101
} ) ;
101
102
102
- Task( "__RestoreNugetPackages " )
103
+ Task( "__RestoreNuGetPackages " )
103
104
. Does ( ( ) =>
104
105
{
105
106
foreach ( var solution in solutions )
@@ -115,7 +116,8 @@ Task("__UpdateAssemblyVersionInformation")
115
116
var gitVersionSettings = new ProcessSettings ( )
116
117
. SetRedirectStandardOutput ( true ) ;
117
118
118
- try {
119
+ try
120
+ {
119
121
IEnumerable < string > outputLines ;
120
122
StartProcess ( gitVersionPath , gitVersionSettings , out outputLines ) ;
121
123
@@ -130,13 +132,13 @@ Task("__UpdateAssemblyVersionInformation")
130
132
GitVersionConfigYaml deserialized = DeserializeYaml < GitVersionConfigYaml > ( gitVersionYamlString . Replace ( "next-version" , "NextVersion" ) ) ;
131
133
string gitVersionConfig = deserialized . NextVersion ;
132
134
133
- gitVersionOutput = new Dictionary < string , object > {
135
+ gitVersionOutput = new Dictionary < string , object >
136
+ {
134
137
{ "NuGetVersion" , gitVersionConfig + "-NotFromGitRepo" } ,
135
138
{ "FullSemVer" , gitVersionConfig } ,
136
139
{ "AssemblySemVer" , gitVersionConfig } ,
137
140
{ "Major" , gitVersionConfig . Split ( '.' ) [ 0 ] } ,
138
141
} ;
139
-
140
142
}
141
143
142
144
Information ( "" ) ;
@@ -152,19 +154,21 @@ Task("__UpdateAssemblyVersionInformation")
152
154
153
155
Information ( "" ) ;
154
156
Information ( "Mapping versioning information to:" ) ;
155
- Information ( "Appveyor build number -> {0}" , appveyorBuildNumber ) ;
156
- Information ( "Nuget package version -> {0}" , nugetVersion ) ;
157
+ Information ( "AppVeyor build number -> {0}" , appveyorBuildNumber ) ;
158
+ Information ( "NuGet package version -> {0}" , nugetVersion ) ;
157
159
Information ( "AssemblyVersion -> {0}" , assemblyVersion ) ;
158
160
Information ( "AssemblyFileVersion -> {0}" , assemblySemver ) ;
159
161
Information ( "AssemblyInformationalVersion -> {0}" , assemblySemver ) ;
160
162
} ) ;
161
163
162
164
Task( "__UpdateDotNetStandardAssemblyVersionNumber" )
165
+ . WithCriteria ( ( ) => AppVeyor . IsRunningOnAppVeyor )
163
166
. Does ( ( ) =>
164
167
{
165
168
Information ( "Updating Assembly Version Information" ) ;
166
169
167
- var attributeToValueMap = new Dictionary < string , string > ( ) {
170
+ var attributeToValueMap = new Dictionary < string , string > ( )
171
+ {
168
172
{ "AssemblyVersion" , assemblyVersion } ,
169
173
{ "FileVersion" , assemblySemver } ,
170
174
{ "InformationalVersion" , assemblySemver } ,
@@ -175,7 +179,8 @@ Task("__UpdateDotNetStandardAssemblyVersionNumber")
175
179
176
180
var csproj = File ( "./src/" + projectName + "/" + projectName + ".csproj" ) ;
177
181
178
- foreach ( var attributeMap in attributeToValueMap ) {
182
+ foreach ( var attributeMap in attributeToValueMap )
183
+ {
179
184
var attribute = attributeMap . Key ;
180
185
var value = attributeMap . Value ;
181
186
@@ -185,7 +190,6 @@ Task("__UpdateDotNetStandardAssemblyVersionNumber")
185
190
throw new Exception ( $ "{ attribute } version could not be updated in { csproj } .") ;
186
191
}
187
192
}
188
-
189
193
} ) ;
190
194
191
195
Task( "__UpdateAppVeyorBuildNumber" )
@@ -202,11 +206,12 @@ Task("__BuildSolutions")
202
206
{
203
207
Information ( "Building {0}" , solution ) ;
204
208
205
- var dotNetCoreBuildSettings = new DotNetBuildSettings {
206
- Configuration = configuration ,
207
- Verbosity = DotNetCoreVerbosity . Minimal ,
208
- NoRestore = true ,
209
- MSBuildSettings = new DotNetMSBuildSettings { TreatAllWarningsAs = MSBuildTreatAllWarningsAs . Error }
209
+ var dotNetCoreBuildSettings = new DotNetBuildSettings
210
+ {
211
+ Configuration = configuration ,
212
+ Verbosity = DotNetCoreVerbosity . Minimal ,
213
+ NoRestore = true ,
214
+ MSBuildSettings = new DotNetMSBuildSettings { TreatAllWarningsAs = MSBuildTreatAllWarningsAs . Error } ,
210
215
} ;
211
216
212
217
DotNetBuild ( solution . ToString ( ) , dotNetCoreBuildSettings ) ;
@@ -216,28 +221,31 @@ Task("__BuildSolutions")
216
221
Task( "__RunTests" )
217
222
. Does ( ( ) =>
218
223
{
219
- foreach ( var specsProj in GetFiles ( "./src/**/*.Specs.csproj" ) ) {
220
- DotNetTest ( specsProj . FullPath , new DotNetTestSettings {
224
+ foreach ( var specsProj in GetFiles ( "./src/**/*.Specs.csproj" ) )
225
+ {
226
+ DotNetTest ( specsProj . FullPath , new DotNetTestSettings
227
+ {
221
228
Configuration = configuration ,
222
- NoBuild = true
229
+ NoBuild = true ,
223
230
} ) ;
224
231
}
225
232
} ) ;
226
233
227
- Task( "__CreateSignedNugetPackage " )
234
+ Task( "__CreateSignedNuGetPackage " )
228
235
. Does ( ( ) =>
229
236
{
230
237
var packageName = projectName ;
231
238
232
239
Information ( "Building {0}.{1}.nupkg" , packageName , nugetVersion ) ;
233
240
234
- var dotNetCorePackSettings = new DotNetPackSettings {
241
+ var dotNetCorePackSettings = new DotNetPackSettings
242
+ {
235
243
Configuration = configuration ,
236
244
NoBuild = true ,
237
- OutputDirectory = nupkgDestDir
245
+ OutputDirectory = nupkgDestDir ,
238
246
} ;
239
247
240
- DotNetPack ( $@ " { srcDir } \ { projectName } .sln", dotNetCorePackSettings ) ;
248
+ DotNetPack ( System . IO . Path . Combine ( srcDir , projectName + " .sln") , dotNetCorePackSettings ) ;
241
249
} ) ;
242
250
243
251
//////////////////////////////////////////////////////////////////////
@@ -246,13 +254,13 @@ Task("__CreateSignedNugetPackage")
246
254
247
255
Task( "Build" )
248
256
. IsDependentOn ( "__Clean" )
249
- . IsDependentOn ( "__RestoreNugetPackages " )
257
+ . IsDependentOn ( "__RestoreNuGetPackages " )
250
258
. IsDependentOn ( "__UpdateAssemblyVersionInformation" )
251
259
. IsDependentOn ( "__UpdateDotNetStandardAssemblyVersionNumber" )
252
260
. IsDependentOn ( "__UpdateAppVeyorBuildNumber" )
253
261
. IsDependentOn ( "__BuildSolutions" )
254
262
. IsDependentOn ( "__RunTests" )
255
- . IsDependentOn ( "__CreateSignedNugetPackage " ) ;
263
+ . IsDependentOn ( "__CreateSignedNuGetPackage " ) ;
256
264
257
265
///////////////////////////////////////////////////////////////////////////////
258
266
// PRIMARY TARGETS
@@ -272,6 +280,6 @@ RunTarget(target);
272
280
//////////////////////////////////////////////////////////////////////
273
281
274
282
string ToolsExePath( string exeFileName ) {
275
- var exePath = System. IO . Directory . GetFiles ( @ "./tools", exeFileName , SearchOption . AllDirectories ) . FirstOrDefault ( ) ;
283
+ var exePath = System. IO . Directory . GetFiles ( "./tools" , exeFileName , SearchOption . AllDirectories ) . FirstOrDefault ( ) ;
276
284
return exePath;
277
- }
285
+ }
0 commit comments