Add Shared Host MSI Authoring

Ideally in the project.json for the shared host we would just list the
actual package that holds the shared host, instead of all of
NetStandard.Library, but doing some leads to compliation errors, since
publish wants to include a compile step that has a generated
AssemblyAttributes file which references types like System.String.
This commit is contained in:
Matt Ellis 2016-03-08 15:22:33 -08:00
parent 29bc612565
commit 04d21e6693
9 changed files with 299 additions and 3 deletions

View file

@ -0,0 +1,46 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.IO.Compression;
using System.Runtime.InteropServices;
using Microsoft.DotNet.Cli.Build.Framework;
using Microsoft.Extensions.PlatformAbstractions;
using static Microsoft.DotNet.Cli.Build.Framework.BuildHelpers;
namespace Microsoft.DotNet.Cli.Build
{
public class SharedFrameworkTargets
{
private const string CoreHostBaseName = "corehost";
[Target]
public static BuildTargetResult PublishSharedHost(BuildTargetContext c)
{
string SharedHostPublishRoot = Path.Combine(Dirs.Output, "obj", "sharedhost");
if (Directory.Exists(SharedHostPublishRoot))
{
Directory.Delete(SharedHostPublishRoot, true);
}
DotNetCli.Stage0.Publish("--output", SharedHostPublishRoot, Path.Combine(Dirs.RepoRoot, "src", "sharedframework", "host")).Execute().EnsureSuccessful();
// For the shared host, we only want corerun and not any of the other artifacts in the package (like the hostpolicy)
foreach (var filePath in Directory.GetFiles(SharedHostPublishRoot))
{
if (Path.GetFileName(filePath) != $"{CoreHostBaseName}{Constants.ExeSuffix}")
{
File.Delete(filePath);
}
}
// corehost will be renamed to dotnet at some point and then this can be removed.
File.Move(Path.Combine(SharedHostPublishRoot, $"{CoreHostBaseName}{Constants.ExeSuffix}"), Path.Combine(SharedHostPublishRoot, $"dotnet{Constants.ExeSuffix}"));
c.BuildContext["SharedHostPublishRoot"] = SharedHostPublishRoot;
return c.Success();
}
}
}