1+ use namespace="System.IO"
2+ use namespace="System.IO.Compression"
3+ use namespace="System.Linq"
14
5+ default CONFIGURATION_LOCAL='${E("Configuration")}'
6+ default BASE_DIR_LOCAL='${Directory.GetCurrentDirectory()}'
7+ default BUILD_DIR_LOCAL='${Path.Combine(BASE_DIR_LOCAL, "artifacts", "build")}'
8+ default TOOL_PROJECT_NAME='Microsoft.AspNetCore.Razor.Tools'
9+ default TOOL_EXE_NAME='dotnet-razor-tooling.exe'
210var VERSION='0.1'
311var FULL_VERSION='0.1'
412var AUTHORS='Microsoft Open Technologies, Inc.'
513-BuildQuality = "preview2";
614
715use-standard-lifecycle
8- k-standard-goals
16+ k-standard-goals
17+
18+ #repack-x86 target='compile'
19+ @{
20+ if (string.IsNullOrEmpty(CONFIGURATION_LOCAL))
21+ {
22+ CONFIGURATION_LOCAL = "Debug";
23+ }
24+
25+ // Forcing to lower to match the entry in the sources project.json.
26+ var configurationX86 = CONFIGURATION_LOCAL.ToLower() + "_x86";
27+
28+ var projectNupkg = Files
29+ .Include(Path.Combine(BUILD_DIR_LOCAL, TOOL_PROJECT_NAME + ".1.*.nupkg")) // Assuming the package version starts with 1.
30+ .Where(path => !path.EndsWith(".symbols.nupkg", StringComparison.OrdinalIgnoreCase))
31+ .OrderByDescending(f => f) // On local builds multiple nupkgs are generated.
32+ .First();
33+
34+ Log.Info("Repacking Nupkg: " + projectNupkg);
35+
36+ var extractToDirectory = projectNupkg + "-temp";
37+ ZipFile.ExtractToDirectory(projectNupkg, extractToDirectory);
38+
39+ var projectDirectory = Path.Combine(BASE_DIR_LOCAL, "src", TOOL_PROJECT_NAME);
40+ var projectFilePath = Path.Combine(projectDirectory, "project.json");
41+ var projectFile = Files.Include(projectFilePath).Single();
42+
43+ // Generate the x86 exe variation for the nupkg.
44+ DotnetBuild(projectFile, configurationX86, "net451");
45+
46+ var runtimesDirectory = Path.Combine(extractToDirectory, "runtimes");
47+ var win7x86Directory = Path.Combine(runtimesDirectory, "win7-x86", "lib", "net451");
48+ var win7x64Directory = Path.Combine(runtimesDirectory, "win7-x64", "lib", "net451");
49+ Directory.CreateDirectory(win7x86Directory);
50+ Directory.CreateDirectory(win7x64Directory);
51+
52+ var binDirectory = Path.Combine(projectDirectory, "bin");
53+ var x86OutputPath = Path.Combine(binDirectory, configurationX86, "net451");
54+ var x86ExePath = Path.Combine(x86OutputPath, TOOL_EXE_NAME);
55+ var x86ExeDestinationPath = Path.Combine(win7x86Directory, TOOL_EXE_NAME);
56+ File.Copy(x86ExePath, x86ExeDestinationPath);
57+
58+ var x64OutputPath = Path.Combine(binDirectory, CONFIGURATION_LOCAL, "net451");
59+ var x64ExePath = Path.Combine(x64OutputPath, TOOL_EXE_NAME);
60+ var x64ExeDestinationPath = Path.Combine(win7x64Directory, TOOL_EXE_NAME);
61+ File.Copy(x64ExePath, x64ExeDestinationPath);
62+
63+ var nugetExePath = Path.Combine(BASE_DIR_LOCAL, ".build", "nuget.exe");
64+ var nuspecPath = Path.Combine(extractToDirectory, TOOL_PROJECT_NAME + ".nuspec");
65+ ExecClr(nugetExePath, "pack " + nuspecPath + " -OutputDirectory " + BUILD_DIR_LOCAL);
66+
67+ try
68+ {
69+ // Delete temporary directory we used to repack.
70+ Directory.Delete(extractToDirectory, true);
71+ }
72+ catch
73+ {
74+ // Don't care if we couldn't delete the temp directory.
75+ }
76+ }
0 commit comments