RazorTooling/makefile.shade

103 строки
4.5 KiB
Plaintext

use namespace="System.IO"
use namespace="System.IO.Compression"
use namespace="System.Linq"
default BASE_DIR_LOCAL='${Directory.GetCurrentDirectory()}'
default BUILD_DIR_LOCAL='${Path.Combine(BASE_DIR_LOCAL, "artifacts", "build")}'
default TOOL_PROJECT_NAME='Microsoft.AspNetCore.Razor.Design'
default TOOL_EXE_NAME='Microsoft.AspNetCore.Razor.Design.exe'
default TEST_PROJECT_PACKAGE_NAME='RazorToolingTestApp.LibraryPackage'
default TEST_ARTIFACTS_DIR='${Path.Combine(BASE_DIR_LOCAL, "testartifacts")}'
default TEST_ARTIFACTS_INITIAL_PACKAGE_DIR='${Path.Combine(TEST_ARTIFACTS_DIR, "initialpackages")}'
var VERSION='0.1'
var FULL_VERSION='0.1'
var AUTHORS='Microsoft Open Technologies, Inc.'
-BuildQuality = "preview4";
use-standard-lifecycle
k-standard-goals
default CONFIGURATION_LOCAL='${E("Configuration")}'
#repo-initialize target='initialize'
use-volatile-feed
rimraf rimrafDir='${TEST_ARTIFACTS_INITIAL_PACKAGE_DIR}' if='Directory.Exists(TEST_ARTIFACTS_INITIAL_PACKAGE_DIR)'
@{
Directory.CreateDirectory(TEST_ARTIFACTS_INITIAL_PACKAGE_DIR);
var srcDirectory = Path.Combine(BASE_DIR_LOCAL, "src");
Dotnet("restore " + srcDirectory);
foreach (var directory in Directory.EnumerateDirectories(srcDirectory))
{
Dotnet("pack " + directory + " -o " + TEST_ARTIFACTS_INITIAL_PACKAGE_DIR);
}
// Restore testapps folder locally to ensure all dynamically generated packages have been cached.
var testProjectDirectory = Path.Combine(BASE_DIR_LOCAL, "testapps");
Dotnet("restore " + BASE_DIR_LOCAL + " -f " + TEST_ARTIFACTS_INITIAL_PACKAGE_DIR);
}
#repack-x86 target='compile' if='Directory.Exists("src")'
@{
// Forcing to lower to match the entry in the sources project.json.
var configurationX86 = CONFIGURATION_LOCAL.ToLower() + "_x86";
var projectNupkg = Files
.Include(Path.Combine(BUILD_DIR_LOCAL, TOOL_PROJECT_NAME + ".1.*.nupkg")) // Assuming the package version starts with 1.
.Where(path => !path.EndsWith(".symbols.nupkg", StringComparison.OrdinalIgnoreCase))
.OrderByDescending(f => f) // On local builds multiple nupkgs are generated.
.First();
Log.Info("Repacking Nupkg: " + projectNupkg);
var extractToDirectory = projectNupkg + "-temp";
ZipFile.ExtractToDirectory(projectNupkg, extractToDirectory);
var projectDirectory = Path.Combine(BASE_DIR_LOCAL, "src", TOOL_PROJECT_NAME);
var projectFilePath = Path.Combine(projectDirectory, "project.json");
var projectFile = Files.Include(projectFilePath).Single();
// Generate the x86 exe variation for the nupkg.
DotnetBuild(projectFile, configurationX86, "net451");
var runtimesDirectory = Path.Combine(extractToDirectory, "runtimes");
var win7x86Directory = Path.Combine(runtimesDirectory, "win7-x86", "lib", "net451");
var win7x64Directory = Path.Combine(runtimesDirectory, "win7-x64", "lib", "net451");
Directory.CreateDirectory(win7x86Directory);
Directory.CreateDirectory(win7x64Directory);
var binDirectory = Path.Combine(projectDirectory, "bin");
var x86OutputPath = Path.Combine(binDirectory, configurationX86, "net451");
var x86ExePath = Path.Combine(x86OutputPath, TOOL_EXE_NAME);
var x86ExeDestinationPath = Path.Combine(win7x86Directory, TOOL_EXE_NAME);
File.Copy(x86ExePath, x86ExeDestinationPath);
var x64OutputPath = Path.Combine(binDirectory, CONFIGURATION_LOCAL, "net451");
var x64ExePath = Path.Combine(x64OutputPath, TOOL_EXE_NAME);
var x64ExeDestinationPath = Path.Combine(win7x64Directory, TOOL_EXE_NAME);
File.Copy(x64ExePath, x64ExeDestinationPath);
var nugetExePath = Environment.GetEnvironmentVariable("KOREBUILD_NUGET_EXE");
if (string.IsNullOrEmpty(nugetExePath))
{
nugetExePath = Path.Combine(BASE_DIR_LOCAL, ".build", "nuget.exe");
}
var nuspecPath = Path.Combine(extractToDirectory, TOOL_PROJECT_NAME + ".nuspec");
ExecClr(nugetExePath, "pack " + nuspecPath + " -OutputDirectory " + BUILD_DIR_LOCAL);
try
{
// Delete temporary directory we used to repack.
Directory.Delete(extractToDirectory, true);
}
catch
{
// Don't care if we couldn't delete the temp directory.
}
}
macro name="DotnetRestore" restoreDir='string'
dotnet-restore