Skip to content
This repository was archived by the owner on Feb 23, 2021. It is now read-only.

Commit c998cee

Browse files
author
N. Taylor Mullen
committed
Add bit to repack desktop dependency to enable x86 scenarios.
- Prior to this change we'd only ever pack the x64 variation of `dotnet-razor-tooling.exe`. - Left the lib directory in touch for unit testing purposes. #72
1 parent 9a13614 commit c998cee

2 files changed

Lines changed: 82 additions & 2 deletions

File tree

makefile.shade

Lines changed: 69 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,76 @@
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'
210
var VERSION='0.1'
311
var FULL_VERSION='0.1'
412
var AUTHORS='Microsoft Open Technologies, Inc.'
513
-BuildQuality = "preview2";
614

715
use-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+
}

src/Microsoft.AspNetCore.Razor.Tools/project.json

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,18 @@
1717
],
1818
"xmlDoc": true
1919
},
20+
"configurations": {
21+
"debug_x86": {
22+
"buildOptions": {
23+
"platform": "anycpu32bitpreferred"
24+
}
25+
},
26+
"release_x86": {
27+
"buildOptions": {
28+
"platform": "anycpu32bitpreferred"
29+
}
30+
}
31+
},
2032
"dependencies": {
2133
"Microsoft.AspNetCore.Razor.Runtime": "1.0.0-*",
2234
"Microsoft.DotNet.Cli.Utils": "1.0.0-*",
@@ -43,6 +55,6 @@
4355
"dnxcore50"
4456
]
4557
},
46-
"net451": {}
58+
"net451": { }
4759
}
4860
}

0 commit comments

Comments
 (0)