Make dotnet cli portable
This commit is contained in:
parent
8df6f5405d
commit
18436e325e
38 changed files with 194 additions and 71 deletions
|
@ -237,6 +237,7 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
|
||||
// We publish to a sub folder of the PublishRoot so tools like heat and zip can generate folder structures easier.
|
||||
string SharedFrameworkNameAndVersionRoot = Path.Combine(outputDir, "shared", SharedFrameworkName, SharedFrameworkNugetVersion);
|
||||
c.BuildContext["SharedFrameworkPath"] = SharedFrameworkNameAndVersionRoot;
|
||||
|
||||
if (Directory.Exists(SharedFrameworkNameAndVersionRoot))
|
||||
{
|
||||
|
@ -261,9 +262,7 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
SharedFrameworkSourceRoot).Execute().EnsureSuccessful();
|
||||
|
||||
// Clean up artifacts that dotnet-publish generates which we don't need
|
||||
File.Delete(Path.Combine(SharedFrameworkNameAndVersionRoot, $"framework{Constants.ExeSuffix}"));
|
||||
File.Delete(Path.Combine(SharedFrameworkNameAndVersionRoot, "framework.dll"));
|
||||
File.Delete(Path.Combine(SharedFrameworkNameAndVersionRoot, "framework.pdb"));
|
||||
DeleteMainPublishOutput(SharedFrameworkNameAndVersionRoot, "framework");
|
||||
File.Delete(Path.Combine(SharedFrameworkNameAndVersionRoot, "framework.runtimeconfig.json"));
|
||||
|
||||
// Rename the .deps file
|
||||
|
@ -309,6 +308,9 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
File.Copy(
|
||||
Path.Combine(Dirs.Corehost, CoreHostBaseName),
|
||||
Path.Combine(SharedFrameworkNameAndVersionRoot, $"dotnet{Constants.ExeSuffix}"), true);
|
||||
File.Copy(
|
||||
Path.Combine(Dirs.Corehost, CoreHostBaseName),
|
||||
Path.Combine(SharedFrameworkNameAndVersionRoot, CoreHostBaseName), true);
|
||||
File.Copy(
|
||||
Path.Combine(Dirs.Corehost, HostPolicyBaseName),
|
||||
Path.Combine(SharedFrameworkNameAndVersionRoot, HostPolicyBaseName), true);
|
||||
|
@ -355,20 +357,34 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
|
||||
FixModeFlags(outputDir);
|
||||
|
||||
string compilersProject = Path.Combine(Dirs.RepoRoot, "src", "compilers");
|
||||
dotnet.Publish(compilersProject,
|
||||
"--output",
|
||||
outputDir,
|
||||
"--framework",
|
||||
"netstandard1.5")
|
||||
.Execute()
|
||||
.EnsureSuccessful();
|
||||
|
||||
var compilersDeps = Path.Combine(outputDir, "compilers.deps.json");
|
||||
var compilersRuntimeConfig = Path.Combine(outputDir, "compilers.runtimeconfig.json");
|
||||
|
||||
// Copy corehost
|
||||
File.Copy(Path.Combine(Dirs.Corehost, $"corehost{Constants.ExeSuffix}"), Path.Combine(outputDir, $"corehost{Constants.ExeSuffix}"), overwrite: true);
|
||||
File.Copy(Path.Combine(Dirs.Corehost, $"{Constants.DynamicLibPrefix}hostpolicy{Constants.DynamicLibSuffix}"), Path.Combine(outputDir, $"{Constants.DynamicLibPrefix}hostpolicy{Constants.DynamicLibSuffix}"), overwrite: true);
|
||||
File.Copy(Path.Combine(Dirs.Corehost, $"{Constants.DynamicLibPrefix}hostfxr{Constants.DynamicLibSuffix}"), Path.Combine(outputDir, $"{Constants.DynamicLibPrefix}hostfxr{Constants.DynamicLibSuffix}"), overwrite: true);
|
||||
|
||||
var binaryToCorehostifyOutDir = Path.Combine(outputDir, "runtimes", "any", "native");
|
||||
// Corehostify binaries
|
||||
foreach (var binaryToCorehostify in BinariesForCoreHost)
|
||||
{
|
||||
try
|
||||
{
|
||||
// Yes, it is .exe even on Linux. This is the managed exe we're working with
|
||||
File.Copy(Path.Combine(outputDir, $"{binaryToCorehostify}.exe"), Path.Combine(outputDir, $"{binaryToCorehostify}.dll"));
|
||||
File.Delete(Path.Combine(outputDir, $"{binaryToCorehostify}.exe"));
|
||||
File.Copy(Path.Combine(outputDir, $"corehost{Constants.ExeSuffix}"), Path.Combine(outputDir, binaryToCorehostify + Constants.ExeSuffix));
|
||||
File.Copy(Path.Combine(binaryToCorehostifyOutDir, $"{binaryToCorehostify}.exe"), Path.Combine(outputDir, $"{binaryToCorehostify}.dll"));
|
||||
File.Delete(Path.Combine(binaryToCorehostifyOutDir, $"{binaryToCorehostify}.exe"));
|
||||
File.Copy(compilersDeps, Path.Combine(outputDir, binaryToCorehostify + ".deps.json"));
|
||||
File.Copy(compilersRuntimeConfig, Path.Combine(outputDir, binaryToCorehostify + ".runtimeconfig.json"));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
@ -376,9 +392,10 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
}
|
||||
}
|
||||
|
||||
// dotnet.exe is from stage0. But we must be using the newly built corehost in stage1
|
||||
File.Delete(Path.Combine(outputDir, $"dotnet{Constants.ExeSuffix}"));
|
||||
File.Copy(Path.Combine(outputDir, $"corehost{Constants.ExeSuffix}"), Path.Combine(outputDir, $"dotnet{Constants.ExeSuffix}"));
|
||||
// cleanup compilers project output we don't need
|
||||
DeleteMainPublishOutput(outputDir, "compilers");
|
||||
File.Delete(compilersDeps);
|
||||
File.Delete(compilersRuntimeConfig);
|
||||
|
||||
// Crossgen Roslyn
|
||||
var result = CrossgenCliSdk(c, outputDir);
|
||||
|
@ -480,7 +497,13 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
foreach (var assemblyToCrossgen in AssembliesToCrossGen)
|
||||
{
|
||||
c.Info($"Crossgenning {assemblyToCrossgen}");
|
||||
ExecInSilent(outputDir, crossgen, "-readytorun", "-nologo", "-platform_assemblies_paths", outputDir, assemblyToCrossgen);
|
||||
ExecInSilent(outputDir,
|
||||
crossgen,
|
||||
"-readytorun",
|
||||
"-nologo",
|
||||
"-platform_assemblies_paths",
|
||||
$"{outputDir}{Path.PathSeparator}{c.BuildContext["SharedFrameworkPath"]}",
|
||||
assemblyToCrossgen);
|
||||
}
|
||||
|
||||
c.Info("Crossgen complete");
|
||||
|
@ -534,6 +557,13 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
return c.Success();
|
||||
}
|
||||
|
||||
private static void DeleteMainPublishOutput(string path, string name)
|
||||
{
|
||||
File.Delete(Path.Combine(path, $"{name}{Constants.ExeSuffix}"));
|
||||
File.Delete(Path.Combine(path, $"{name}.dll"));
|
||||
File.Delete(Path.Combine(path, $"{name}.pdb"));
|
||||
}
|
||||
|
||||
private static bool HasMetadata(string pathToFile)
|
||||
{
|
||||
try
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue