forked from aspnet/dnx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmakefile.shade
634 lines (512 loc) · 26.2 KB
/
makefile.shade
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
use assembly="System.Xml.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
use assembly="System.IO.Compression.FileSystem, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
use import="Environment"
var PRODUCT_VERSION = '1.0.0'
var AUTHORS='Microsoft Open Technologies, Inc.'
use-standard-lifecycle
k-standard-goals
var Configuration2='${E("Configuration")}'
var ROOT = '${Directory.GetCurrentDirectory()}'
var SCRIPTS_DIR = '${Path.Combine(ROOT, "scripts")}'
var ARTIFACTS_DIR = '${Path.Combine(ROOT, "artifacts")}'
var BUILD_DIR2 = '${Path.Combine(ROOT, "artifacts", "build")}'
var NUSPEC_ROOT = '${Path.Combine(ROOT, "nuspec")}'
var PACKAGES_DIR = '${Path.Combine(ROOT, "packages")}'
var TEST_RESULTS = '${Path.Combine(ROOT, "artifacts", "TestResults")}'
var SAMPLES_DIR = '${Path.Combine(ROOT, "samples")}'
var FULL_VERSION = '${PRODUCT_VERSION + "-" + E("K_BUILD_VERSION")}'
var CORECLR_TARGET_PATH = '${Path.Combine(BUILD_DIR2, "CoreCLR")}'
var KRE_MONO_BIN='${Path.Combine(BUILD_DIR2, "KRE-Mono", "bin")}'
var KRE_CLR_x86_BIN='${Path.Combine(BUILD_DIR2, "KRE-CLR-x86", "bin")}'
var KRE_CLR_amd64_BIN='${Path.Combine(BUILD_DIR2, "KRE-CLR-amd64", "bin")}'
var KRE_CORECLR_x86_BIN='${Path.Combine(BUILD_DIR2, "KRE-CoreCLR-x86", "bin")}'
var KRE_CORECLR_amd64_BIN='${Path.Combine(BUILD_DIR2, "KRE-CoreCLR-amd64", "bin")}'
var KRE_CLR_TARGETS = '${new [] {KRE_MONO_BIN, KRE_CLR_x86_BIN, KRE_CLR_amd64_BIN}}'
var KRE_CORECLR_TARGETS = '${new [] {KRE_CORECLR_x86_BIN, KRE_CORECLR_amd64_BIN}}'
var ALL_TARGETS = '${KRE_CLR_TARGETS.Concat(KRE_CORECLR_TARGETS)}'
var NEW_RUNTIME = '${E("NEW_RUNTIME") == "1"}'
var CORE_CLR_VERSION = '${E("CORE_CLR_VERSION")}'
var PROGRAM_FILES_X86 = '${Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86)}'
var MSBUILD = '${Path.Combine(PROGRAM_FILES_X86, "MSBuild", "14.0", "Bin", "MSBuild.exe")}'
#package-runtime .clean-sdk-dir .copy-bits .tweak-scripts .copy-package-dependencies .copy-coreclr-kpm-dependencies .copy-coreclr .nuget-pack-runtime target='package'
#rebuild-package .build-mono-entrypoint .build-compile .native-compile .package-runtime .xunit-test
#native-compile target='compile' if='!IsMono'
var nativeProjects ='${Files.Include(Path.Combine(ROOT, "src", "**", "*.vcxproj"))}'
@{
if (nativeProjects.Any())
{
if (!IsMsbuildInstalled(MSBUILD))
{
Environment.Exit(1);
}
else
{
foreach (var project in nativeProjects)
{
//Skip redefined targets (compile-klr, compile-klrcore45)
if (project.Contains("klr.vcxproj") || project.Contains("klr.core45.vcxproj"))
{
continue;
}
Exec(MSBUILD, project + " /p:Configuration=" + Configuration2 + ";Platform=Win32");
Exec(MSBUILD, project + " /p:Configuration=" + Configuration2 + ";Platform=x64");
}
}
}
}
copy sourceDir='${Path.GetDirectoryName(project)}' include='bin/**/' outputDir='${Path.Combine(BUILD_DIR2, Path.GetFileNameWithoutExtension(project))}' overwrite='${true}' each='var project in nativeProjects'
#compile-klr target='native-compile' if='!IsMono'
var klrProj = '${Path.Combine(ROOT, "src", "klr", "klr.vcxproj")}'
@{
if (!IsMsbuildInstalled(MSBUILD))
{
Environment.Exit(1);
}
else
{
var environmentKreTargetOS = Environment.GetEnvironmentVariable("KRE_TARGET_OS");
var configKreTargetOS = "";
Exec(MSBUILD, klrProj + " /p:Configuration=" + Configuration2 + ";Platform=Win32;TargetFramework=net45");
Exec(MSBUILD, klrProj + " /p:Configuration=" + Configuration2 + ";Platform=x64;TargetFramework=net45");
if (environmentKreTargetOS == "WIN7_PLUS_CORESYSTEM")
{
configKreTargetOS = ";KreTargetOS=WIN7_PLUS_CORESYSTEM";
}
Exec(MSBUILD, klrProj + " /p:Configuration=" + Configuration2 + ";Platform=Win32;TargetFramework=aspnetcore50" + configKreTargetOS);
Exec(MSBUILD, klrProj + " /p:Configuration=" + Configuration2 + ";Platform=x64;TargetFramework=aspnetcore50" + configKreTargetOS);
}
}
directory delete='${Path.Combine(BUILD_DIR2, "klr")}'
copy sourceDir='${Path.Combine(ROOT, "src", "klr")}' include='bin/**/' outputDir='${Path.Combine(BUILD_DIR2, "klr")}' overwrite='${true}'
#compile-klrcore45 target='native-compile' if='!IsMono'
var klrCore45Proj = '${Path.Combine(ROOT, "src", "klr.core45", "klr.core45.vcxproj")}'
@{
if (!IsMsbuildInstalled(MSBUILD))
{
Environment.Exit(1);
}
else
{
var environmentKreTargetOS = Environment.GetEnvironmentVariable("KRE_TARGET_OS");
var configKreTargetOS = "";
if (environmentKreTargetOS == "WIN7_PLUS_CORESYSTEM")
{
configKreTargetOS = ";KreTargetOS=WIN7_PLUS_CORESYSTEM";
}
Exec(MSBUILD, klrCore45Proj + " /p:Configuration=" + Configuration2 + ";Platform=Win32" + configKreTargetOS);
Exec(MSBUILD, klrCore45Proj + " /p:Configuration=" + Configuration2 + ";Platform=x64" + configKreTargetOS);
}
}
directory delete='${Path.Combine(BUILD_DIR2, "klr.core45")}'
copy sourceDir='${Path.Combine(ROOT, "src", "klr.core45")}' include='bin/**/' outputDir='${Path.Combine(BUILD_DIR2, "klr.core45")}' overwrite='${true}'
#build-mono-entrypoint target='compile' if='!IsMono'
directory create='artifacts/build/klr.mono.managed'
@{
var cscPath = Path.Combine(Environment.GetEnvironmentVariable("WINDIR"), "Microsoft.NET", "Framework", "v4.0.30319", "csc.exe");
Log.Info("Using csc path:" + cscPath);
Exec(cscPath, @"/target:exe /nologo /unsafe /out:artifacts\build\klr.mono.managed\klr.mono.managed.dll /define:NET45 src\klr.mono.managed\EntryPoint.cs src\klr.hosting.shared\RuntimeBootstrapper.cs src\klr.hosting.shared\LoaderEngine.cs src\Microsoft.Framework.CommandLineUtils\CommandLine\CommandArgument.cs src\Microsoft.Framework.CommandLineUtils\CommandLine\CommandLineApplication.cs src\Microsoft.Framework.CommandLineUtils\CommandLine\CommandOption.cs src\Microsoft.Framework.CommandLineUtils\CommandLine\CommandOptionType.cs");
}
#xunit-test target='test' if='Directory.Exists("test")'
k-test each='var projectFile in Files.Include("test/**/project.json")' if='NEW_RUNTIME'
#test-package
var helloWorld = '${Path.Combine(SAMPLES_DIR, "HelloWorld")}'
var kcmd = '${Path.Combine(TEST_RESULTS, "KRE", "tools", "k.cmd")}'
var aspnetCore50Tools = '${Path.Combine(TEST_RESULTS, "KRE", "tools", "aspnetcore50")}'
var nupkgPaths = '${new string[] {
Files.Include(Path.Combine(BUILD_DIR2, "KRE-CLR-x86.*.nupkg")).Single(),
Files.Include(Path.Combine(BUILD_DIR2, "KRE-CLR-amd64.*.nupkg")).Single(),
Files.Include(Path.Combine(BUILD_DIR2, "KRE-CoreCLR-x86.*.nupkg")).Single(),
Files.Include(Path.Combine(BUILD_DIR2, "KRE-CoreCLR-amd64.*.nupkg")).Single(),
}}'
for each='var nupkgPath in nupkgPaths'
@{
var kreName = Path.GetFileNameWithoutExtension(nupkgPath);
var krePath = Path.Combine(TEST_RESULTS, "KRE", kreName);
Log.Info("Unpacking " + nupkgPath);
if (Directory.Exists(krePath)) {
Directory.Delete(krePath, recursive:true);
}
Directory.CreateDirectory(krePath);
System.IO.Compression.ZipFile.ExtractToDirectory(
nupkgPath,
krePath);
}
@{
Action<string> runWithFramework = nupkgPath => {
var envPath = Environment.GetEnvironmentVariable("PATH");
try
{
var kreName = Path.GetFileNameWithoutExtension(nupkgPath);
var krePath = Path.Combine(TEST_RESULTS, "KRE", kreName);
Environment.SetEnvironmentVariable("K_APPBASE", helloWorld);
var kPath = Path.Combine(krePath, "bin", "k");
var kpmPath = Path.Combine(krePath, "bin", "kpm");
Log.Info("kreName = " + kreName);
Log.Info("K_APPBASE = " + helloWorld);
Exec("cmd", "/C " + kPath + " run");
var commands = new [] { "build" };
foreach(var cmd in commands)
{
Exec("cmd", "/C " + kpmPath + " " + cmd + " " + helloWorld);
Directory.Delete(Path.Combine(helloWorld, "bin"), true);
}
}
finally
{
Environment.SetEnvironmentVariable("PATH", envPath);
Environment.SetEnvironmentVariable("K_APPBASE", null);
}
};
Action<string> crossGen = nupkgPath => {
var kreName = Path.GetFileNameWithoutExtension(nupkgPath);
var krePath = Path.Combine(TEST_RESULTS, "KRE", kreName);
var kPath = Path.Combine(krePath, "bin", "k");
var kTools = new[] {
Path.Combine(krePath, "bin", "lib", "Microsoft.Framework.Project"),
Path.Combine(krePath, "bin", "lib", "Microsoft.Framework.PackageManager"),
Path.Combine(krePath, "bin", "lib", "Microsoft.Framework.DesignTimeHost"),
};
Log.Info("kreName = " + kreName);
foreach(var kTool in kTools) {
Exec("cmd", string.Format("/C \"\"{0}\" crossgen --in \"{1}\"\"", kPath, kTool));
}
};
foreach(var nupkgPath in nupkgPaths) {
runWithFramework(nupkgPath);
}
/*
// Crossgen
crossGen(nupkgPaths[2]);
// SKIP amd64 for now to work around error
crossGen(nupkgPaths[3]);
foreach(var nupkgPath in nupkgPaths) {
runWithFramework(nupkgPath);
}
*/
}
#ensure-latest-package
@{
// We need to re-run the build using the current output
var nupkgPath = Files.Include(Path.Combine(BUILD_DIR2, "KRE-CLR-x86.*.nupkg")).Single();
Log.Info("Unpacking " + nupkgPath);
if (Directory.Exists(Path.Combine(PACKAGES_DIR, "KRE"))) {
Directory.Delete(Path.Combine(PACKAGES_DIR, "KRE"), recursive:true);
}
Directory.CreateDirectory(Path.Combine(PACKAGES_DIR, "KRE"));
System.IO.Compression.ZipFile.ExtractToDirectory(
Path.Combine(nupkgPath),
Path.Combine(PACKAGES_DIR, "KRE"));
// Delete the build dir
Directory.Delete(BUILD_DIR2, recursive: true);
var envPath = Environment.GetEnvironmentVariable("PATH");
try
{
Log.Info("Adding PATH " + Path.Combine(PACKAGES_DIR, "KRE", "bin"));
Environment.SetEnvironmentVariable("PATH", Path.Combine(PACKAGES_DIR, "KRE", "bin") + ";" + envPath);
Environment.SetEnvironmentVariable("NEW_RUNTIME", "1");
Log.Info("Rebuilding target default");
// TODO REMOVE after bootstrapping: We need to restore again because the location changes
Exec("build.cmd", "initialize");
Exec("build.cmd", "rebuild-package");
}
finally
{
Environment.SetEnvironmentVariable("PATH", envPath);
Environment.SetEnvironmentVariable("NEW_RUNTIME", null);
}
}
#verify-package .ensure-latest-package .test-package target='verify'
#clean-sdk-dir
directory each='var delete in ALL_TARGETS'
directory each='var create in ALL_TARGETS'
#copy-bits
var x86Target="x86"
var x64Target="amd64"
-// KRE-mono45-x86
copy sourceDir='${SCRIPTS_DIR}' include='*.sh' outputDir='${KRE_MONO_BIN}' overwrite='${true}'
copy sourceDir='${Path.Combine(BUILD_DIR2, "klr.mono.managed")}' outputDir='${KRE_MONO_BIN}' include='*.dll' overwrite='${true}'
@{
// Rename all .sh files to remove the sh
foreach (var shFile in Files.Include(Path.Combine(KRE_MONO_BIN, "*.sh")))
{
var targetShFile = Path.Combine(Path.GetDirectoryName(shFile),
Path.GetFileNameWithoutExtension(shFile));
if (File.Exists(targetShFile))
{
File.Delete(targetShFile);
}
// Make sure new lines are \n (\r\n messes up the bash script)
var script = File.ReadAllText(shFile).Replace('\r\n', '\n');
File.Move(shFile, targetShFile);
File.WriteAllText(targetShFile, script);
}
}
-// KRE-CLR-x86
copy sourceDir='${Path.Combine(BUILD_DIR2, "klr", "bin", "Win32", Configuration2, "net45")}' outputDir='${KRE_CLR_x86_BIN}' include='*.exe' overwrite='${true}'
copy sourceDir='${Path.Combine(BUILD_DIR2, "klr.net45", "bin", "Win32", Configuration2)}' outputDir='${KRE_CLR_x86_BIN}' include='*.dll' overwrite='${true}'
copy sourceDir='${Path.Combine(BUILD_DIR2, "klr.net45", "bin", "Win32", Configuration2)}' outputDir='${KRE_CLR_x86_BIN}' include='*.pdb' overwrite='${true}'
copy sourceDir='${Path.Combine(ROOT, "src", "klr.net45.managed")}' outputDir='${KRE_CLR_x86_BIN}' include='*.config' overwrite='${true}'
-// KRE-CLR-amd64
copy sourceDir='${Path.Combine(BUILD_DIR2, "klr", "bin", "x64", Configuration2, "net45")}' outputDir='${KRE_CLR_amd64_BIN}' include='*.exe' overwrite='${true}'
copy sourceDir='${Path.Combine(BUILD_DIR2, "klr.net45", "bin", "x64", Configuration2)}' outputDir='${KRE_CLR_amd64_BIN}' include='*.dll' overwrite='${true}'
copy sourceDir='${Path.Combine(BUILD_DIR2, "klr.net45", "bin", "x64", Configuration2)}' outputDir='${KRE_CLR_amd64_BIN}' include='*.pdb' overwrite='${true}'
copy sourceDir='${Path.Combine(ROOT, "src", "klr.net45.managed")}' outputDir='${KRE_CLR_amd64_BIN}' include='*.config' overwrite='${true}'
-// KRE-CoreCLR-x86
copy sourceDir='${Path.Combine(BUILD_DIR2, "klr", "bin", "Win32", Configuration2, "aspnetcore50")}' outputDir='${KRE_CORECLR_x86_BIN}' include='*.exe' overwrite='${true}'
copy sourceDir='${Path.Combine(BUILD_DIR2, "klr.core45", "bin", "Win32", Configuration2)}' outputDir='${KRE_CORECLR_x86_BIN}' include='*.dll' overwrite='${true}'
copy sourceDir='${Path.Combine(BUILD_DIR2, "klr.core45", "bin", "Win32", Configuration2)}' outputDir='${KRE_CORECLR_x86_BIN}' include='*.pdb' overwrite='${true}'
-// KRE-CoreCLR-amd64
copy sourceDir='${Path.Combine(BUILD_DIR2, "klr", "bin", "x64", Configuration2, "aspnetcore50")}' outputDir='${KRE_CORECLR_amd64_BIN}' include='*.exe' overwrite='${true}'
copy sourceDir='${Path.Combine(BUILD_DIR2, "klr.core45", "bin", "x64", Configuration2)}' outputDir='${KRE_CORECLR_amd64_BIN}' include='*.dll' overwrite='${true}'
copy sourceDir='${Path.Combine(BUILD_DIR2, "klr.core45", "bin", "x64", Configuration2)}' outputDir='${KRE_CORECLR_amd64_BIN}' include='*.pdb' overwrite='${true}'
copy sourceDir='${SCRIPTS_DIR}' include='*.cmd' overwrite='${true}' each='var outputDir in new[]{ KRE_CLR_x86_BIN, KRE_CLR_amd64_BIN, KRE_CORECLR_x86_BIN, KRE_CORECLR_amd64_BIN }'
@{
var hostAspNetCore50 = Path.Combine(BUILD_DIR2, "*", "aspnetcore50", "**.*");
var hostnet45 = Path.Combine(BUILD_DIR2, "*", "net45", "**.*");
var libPackages = new[] { "Microsoft.Framework.Project",
"Microsoft.Framework.PackageManager",
"Microsoft.Framework.DesignTimeHost" };
var sharedSourceAssemblies = new [] {
Path.Combine(BUILD_DIR2, "klr.hosting.shared/**/*.*"),
Path.Combine(BUILD_DIR2, "Microsoft.Framework.CommandLineUtils/**/*.*"),
Path.Combine(BUILD_DIR2, "Microsoft.Framework.Runtime.Common/**/*.*"),
Path.Combine(BUILD_DIR2, "Microsoft.Framework.Runtime.Interfaces/**/*.*")
};
foreach(var file in Files.Include(hostAspNetCore50).Exclude(sharedSourceAssemblies))
{
foreach(var aspNetCore50Target in KRE_CORECLR_TARGETS)
{
string dest = Path.Combine(aspNetCore50Target, Path.GetFileName(file));
File.Copy(file, dest, true);
}
}
foreach(var file in Files.Include(hostnet45).Exclude(sharedSourceAssemblies))
{
foreach(var net45Target in KRE_CLR_TARGETS)
{
string dest = Path.Combine(net45Target, Path.GetFileName(file));
File.Copy(file, dest, true);
}
}
// Clean up net45.managed from mono (it's never used)
File.Delete(Path.Combine(KRE_MONO_BIN, "klr.net45.managed.dll"));
// Remove k-crossgen.cmd from the net45 build
foreach (var net45Target in KRE_CLR_TARGETS)
{
var crossgen = Path.Combine(net45Target, "k-crossgen.cmd");
if(File.Exists(crossgen))
{
File.Delete(crossgen);
Log.Info("Deleting crossgen from " + crossgen);
}
}
Action<string, string, string> move = (binFolder, name, extension) =>
{
var libPath = Path.Combine(binFolder, "lib", name);
var source = Path.Combine(binFolder, name + extension);
var target = Path.Combine(libPath, name + extension);
if (File.Exists(source))
{
if (File.Exists(target))
{
File.Delete(target);
}
Directory.CreateDirectory(libPath);
File.Move(source, target);
Log.Info("Moving " + name + " to " + target);
}
else
{
Log.Warn(name + " does not exist in " + binFolder);
}
};
// Move some packages into the lib/ folder
foreach (var libPackage in libPackages)
{
foreach(var binFolder in ALL_TARGETS)
{
move(binFolder, libPackage, ".dll");
move(binFolder, libPackage, ".pdb");
}
}
}
#tweak-scripts
@{
foreach(var targetDir in new[] { KRE_CLR_x86_BIN, KRE_CLR_amd64_BIN, KRE_CORECLR_x86_BIN, KRE_CORECLR_amd64_BIN })
{
foreach(var file in Files.Include(Path.Combine(targetDir, "*.cmd")))
{
var script = File.ReadAllText(file);
script = Regex.Replace(script, @"REM \<dev\>(.*?)REM \<\/dev\>(\s*)", @"", RegexOptions.Singleline);
File.WriteAllText(file, script);
}
}
}
#copy-package-dependencies
@{
var targetFrameworks = new [] { "aspnetcore50", "net45" };
var packages = new[] { "Newtonsoft.Json",
"Microsoft.CodeAnalysis.Common",
"Microsoft.CodeAnalysis.CSharp",
"Microsoft.Bcl.Immutable",
"Microsoft.Bcl.Metadata" };
foreach (var framework in targetFrameworks)
{
foreach (var package in packages)
{
var packageDir = FindPackageDirectory(package);
if(packageDir == null)
{
Log.Warn("Unable to find " + package);
continue;
}
string[] candidates = null;
if (framework == "aspnetcore50")
{
candidates = new [] { framework, "netcore45", "win8", "k10" };
}
else
{
candidates = new [] { framework, "net40", "net35", "net20" };
}
var lib = new DirectoryInfo(Path.Combine(packageDir, "lib"));
var di = candidates.Select(fmk => lib.EnumerateDirectories("*" + fmk+ "*")
.OrderBy(d => d.Name.Length)
.FirstOrDefault())
.FirstOrDefault(d => d != null);
if(!di.Exists)
{
Log.Warn("Couldn't find version of " + package + " matching " + framework);
continue;
}
foreach(var fi in di.GetFiles("*.dll"))
{
string[] targetDirs = null;
if (framework == "aspnetcore50")
{
targetDirs = KRE_CORECLR_TARGETS;
}
else
{
targetDirs = KRE_CLR_TARGETS;
}
foreach(var targetDir in targetDirs)
{
string packageFileDest = Path.Combine(targetDir, fi.Name);
File.Copy(fi.FullName, packageFileDest, true);
Log.Info("Copying to " + packageFileDest);
}
}
}
}
}
#copy-coreclr-kpm-dependencies
@{
var packages = new[] { "Microsoft.Net.Http.Client",
"Microsoft.Net.Security" };
foreach (var package in packages)
{
var packageDir = FindPackageDirectory(package);
if(packageDir == null)
{
Log.Warn("Unable to find " + package);
continue;
}
string[] candidates = new [] { "aspnetcore50", "k10", "netcore45", "win8" };
var lib = new DirectoryInfo(Path.Combine(packageDir, "lib"));
var di = candidates.Select(fmk => lib.EnumerateDirectories("*" + fmk+ "*")
.OrderBy(d => d.Name.Length)
.FirstOrDefault())
.FirstOrDefault(d => d != null);
if(!di.Exists)
{
Log.Warn("Couldn't find version of " + package + " matching aspnetcore50");
continue;
}
foreach(var fi in di.GetFiles("*.dll"))
{
var targetDirs = KRE_CORECLR_TARGETS.Select(dir => Path.Combine(dir, "lib", "Microsoft.Framework.PackageManager"));
foreach(var targetDir in targetDirs)
{
string packageFileDest = Path.Combine(targetDir, fi.Name);
File.Copy(fi.FullName, packageFileDest, true);
Log.Info("Copying to " + packageFileDest);
}
}
}
}
#copy-coreclr
nuget-install package='CoreCLR' outputDir='packages' extra='-pre -nocache' once='CoreCLR' if='string.IsNullOrEmpty(CORE_CLR_VERSION)'
nuget-install package='CoreCLR' packageVersion='${CORE_CLR_VERSION}' outputDir='packages' extra='-pre -nocache' once='CoreCLR' if='!string.IsNullOrEmpty(CORE_CLR_VERSION)'
var CoreCLR_DIR='${""}'
@{
Func<string, long> getVersion = version => {
var dash = version.LastIndexOf('-');
if(dash != -1)
{
var lastToken = version.Substring(dash + 1);
if(lastToken.StartsWith("t"))
{
return Int64.Parse(lastToken.Substring(1));
}
return Int64.Parse(lastToken);
}
return Int64.MaxValue;
};
string packagesDir = Path.Combine(Directory.GetCurrentDirectory(), "packages");
CoreCLR_DIR = Directory.EnumerateDirectories(packagesDir, "CoreCLR*")
.OrderByDescending(getVersion)
.First();
Log.Info("Using " + CoreCLR_DIR);
}
-// Copy to target
copy sourceDir='${Path.Combine(CoreCLR_DIR, "Runtime")}' outputDir='${Path.Combine(CORECLR_TARGET_PATH, "Runtime")}' overwrite='${true}'
-// Copy the CoreCLR to the aspentcore50 builds
copy sourceDir='${Path.Combine(CORECLR_TARGET_PATH, "Runtime", "x86")}' outputDir='${KRE_CORECLR_x86_BIN}'
copy sourceDir='${Path.Combine(CORECLR_TARGET_PATH, "Runtime", "amd64")}' outputDir='${KRE_CORECLR_amd64_BIN}'
#nuget-pack-runtime
copy sourceDir='${NUSPEC_ROOT}' outputDir='${BUILD_DIR2}' include='*.nuspec' overwrite='${true}'
nuget-pack packageVersion='${FULL_VERSION}' outputDir='${BUILD_DIR2}' extra='-NoPackageAnalysis' each='var nuspecFile in Files.Include(Path.Combine(BUILD_DIR2, "*.nuspec"))'
#install-runtime target='install'
var matchVersion=''
for each='var pattern in new[]{ "CLR-x86", "CoreCLR-x86", "CLR-amd64", "CoreCLR-amd64" }'
for each='var runtime in Files.Include(Path.Combine(BUILD_DIR2, "KRE-" + pattern + ".*.nupkg"))'
exec program='cmd' commandline='/C kvm install ${runtime}' if='!IsMono'
var parts='${Path.GetFileNameWithoutExtension(runtime).Split(".".ToArray(), 2)}'
set matchVersion='${parts[1]}' if='matchVersion == ""'
exec program='cmd' commandline='/C kvm alias build ${matchVersion}' if='!IsMono && matchVersion != ""'
exec program='cmd' commandline='/C start cmd /K kvm use build' if='!IsMono && matchVersion != ""'
macro name='NuGetInstall' Package='string' OutputDir='string' Extra='string'
nuget-install package='${Package}' outputDir='${OutputDir}' extra='${Extra}'
functions @{
string FindPackageDirectory(string name)
{
var packagesDir = Environment.GetEnvironmentVariable("KRE_PACKAGES");
if (string.IsNullOrEmpty(packagesDir))
{
var profileDirectory = Environment.GetEnvironmentVariable("USERPROFILE");
if (string.IsNullOrEmpty(profileDirectory))
{
profileDirectory = Environment.GetEnvironmentVariable("HOME");
}
packagesDir = Path.Combine(profileDirectory, ".kpm", "packages");
}
var packageMetadataDir = Path.Combine(packagesDir, name);
if (!Directory.Exists(packageMetadataDir))
{
return null;
}
return Directory.GetDirectories(packageMetadataDir)
.OrderByDescending(d => d)
.FirstOrDefault();
}
bool IsMsbuildInstalled(string msBuildPath)
{
if (!File.Exists(msBuildPath))
{
Log.Warn("msbuild version 12 not found. Please ensure you have the VS 2013 C++ SDK installed.");
return false;
}
return true;
}
}