forked from dotnet/android
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[One .NET] temporary Windows & macOS installers for .NET 6
Depends on: dotnet#5195 For .NET 6 Preview 1, we will need to provide our own installers for the Android workload. This will also unblock the Xamarin.Forms / MAUI team as they build on top of the iOS and Android workloads for .NET 6. We will eventually do some kind of "insertion" process to provide our `.nupkg` files to the dotnet/installer repo, so these installers will go away completely at some point. For now, this creates two new installers: * Microsoft.Android.Workload.msi - installs to `C:\Program Files\dotnet\` * Microsoft.Android.Workload.pkg - installs to `/usr/local/share/dotnet/` Both installers have the following file structure underneath the root directory: * sdk\5.0.100-rtm.20509.5\EnableWorkloadResolver.sentinel * sdk-manifests\5.0.100\Microsoft.Android.Workload\** * packs\Microsoft.Android.Ref\** * packs\Microsoft.Android.Sdk\** The installers will have a hard dependency on .NET 5.0.100-rtm.20509.5, so we will need to have clear instructions for installing the correct version of .NET for the Android workload. The Windows installer is made using WIX, to mirror what dotnet/installer is using: * https://wixtoolset.org/ * https://github.com/dotnet/installer/blob/861a1dd12cb80bd834d0e51442d46ee7d1a4023f/src/redist/targets/GenerateMSIs.targets The `.msi` will need to be built on Windows and the `.pkg` will need to be built on macOS. `create-dotnet-msi.csproj` will download the WIX toolset to `~\android-toolchain\wix` and call `candle.exe` and `light.exe` appropriately. `create-dotnet-pkg.csproj` is based on `create-pkg.csproj`, and no additional tooling is needed. Changes to CI: * The `create-installers` make target now creates the .NET 6 `.pkg` installer. The `mac_build` stage creates one additional installer. * Any subsequent stages that download the `installers` artifact, now use a wildcard for the installer they need. This will improve some of the test stages that were downloading both the `.vsix` and `.pkg` installers before. * A `.NET 6 Preview Installers` Github status will appear that contains public download links for the new installers. * A `Build Results - .NET 6 Preview Installers` artifact will contain additional build logs.
- Loading branch information
1 parent
d60d160
commit c2c76cb
Showing
18 changed files
with
612 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
...in.Android.Tools.BootstrapTasks/Xamarin.Android.Tools.BootstrapTasks/ConvertToRichText.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
using System; | ||
using System.IO; | ||
using Microsoft.Build.Framework; | ||
using Microsoft.Build.Utilities; | ||
|
||
namespace Xamarin.Android.Tools.BootstrapTasks | ||
{ | ||
/// <summary> | ||
/// Used for converting plain text license files to .rtf format. | ||
/// Assumes the file is line wrapped with Environment.NewLine: | ||
/// * Double new lines are preserved. | ||
/// * Single new lines are replaced with spaces. | ||
/// | ||
/// For a Unicode escape the control word \u is used, followed by | ||
/// a 16-bit signed decimal integer giving the Unicode UTF-16 code | ||
/// unit number. More information under 'Character encoding' here: | ||
/// https://en.wikipedia.org/wiki/Rich_Text_Format | ||
/// </summary> | ||
public class ConvertToRichText : Task | ||
{ | ||
[Required] | ||
public string SourceFile { get; set; } | ||
|
||
[Required] | ||
public string DestinationFile { get; set; } | ||
|
||
public override bool Execute () | ||
{ | ||
var text = File.ReadAllText (SourceFile); | ||
|
||
text = text | ||
.Replace (@"\", @"\\") | ||
.Replace ("{", @"\{") | ||
.Replace ("}", @"\}") | ||
// Only want to keep "double" new lines | ||
.Replace (Environment.NewLine + Environment.NewLine, $@"\par{Environment.NewLine} \par{Environment.NewLine} ") | ||
.Replace (Environment.NewLine, " "); | ||
|
||
Directory.CreateDirectory (Path.GetDirectoryName (DestinationFile)); | ||
using (var writer = File.CreateText (DestinationFile)) { | ||
writer.Write (@"{\rtf1\ansi\ansicpg1250\deff0{\fonttbl\f0\fcharset0 Courier New;}\f0\pard "); | ||
foreach (char letter in text) { | ||
if (letter <= 0x7f) { | ||
writer.Write (letter); | ||
} else { | ||
writer.Write ("\\u"); | ||
writer.Write (Convert.ToUInt32 (letter)); | ||
writer.Write ("?"); | ||
} | ||
} | ||
writer.Write (" } "); | ||
} | ||
|
||
return !Log.HasLoggedErrors; | ||
} | ||
} | ||
} |
188 changes: 188 additions & 0 deletions
188
...arin.Android.Tools.BootstrapTasks/Xamarin.Android.Tools.BootstrapTasks/GenerateWixFile.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,188 @@ | ||
using System.IO; | ||
using System.Linq; | ||
using System.Security.Cryptography; | ||
using System.Text; | ||
using System.Xml; | ||
using Microsoft.Build.Framework; | ||
using Microsoft.Build.Utilities; | ||
|
||
namespace Xamarin.Android.Tools.BootstrapTasks | ||
{ | ||
/// <summary> | ||
/// Generates a .wix file for the contents of ~/android-toolchain/dotnet/packs | ||
/// The .wix file can be used to generate the .msi installer for Windows. | ||
/// </summary> | ||
public class GenerateWixFile : Task | ||
{ | ||
[Required] | ||
public string Template { get; set; } | ||
|
||
[Required] | ||
public string DestinationFile { get; set; } | ||
|
||
[Required] | ||
public string DotNetPath { get; set; } | ||
|
||
[Required] | ||
public string DotNetVersion { get; set; } | ||
|
||
[Required] | ||
public string MSIVersion { get; set; } | ||
|
||
public override bool Execute () | ||
{ | ||
var settings = new XmlWriterSettings { | ||
OmitXmlDeclaration = true, | ||
Indent = true, | ||
}; | ||
|
||
var directories = new StringBuilder (); | ||
var components = new StringBuilder (); | ||
using (var packWriter = XmlWriter.Create (directories, settings)) | ||
using (var componentWriter = XmlWriter.Create (components, settings)) { | ||
|
||
// Components | ||
componentWriter.WriteStartElement ("ComponentGroup"); | ||
componentWriter.WriteAttributeString ("Id", "ProductComponents"); | ||
componentWriter.WriteStartElement ("ComponentRef"); | ||
componentWriter.WriteAttributeString ("Id", "EnableWorkloadResolver"); | ||
componentWriter.WriteEndElement (); // </ComponentRef> | ||
|
||
// dotnet | ||
packWriter.WriteStartElement ("Directory"); | ||
packWriter.WriteAttributeString ("Id", "dotnet"); | ||
packWriter.WriteAttributeString ("Name", "dotnet"); | ||
|
||
// sdk | ||
packWriter.WriteStartElement ("Directory"); | ||
packWriter.WriteAttributeString ("Id", "sdk"); | ||
packWriter.WriteAttributeString ("Name", "sdk"); | ||
|
||
// DOTNETVERSION | ||
packWriter.WriteStartElement ("Directory"); | ||
packWriter.WriteAttributeString ("Id", "DOTNETVERSION"); | ||
packWriter.WriteAttributeString ("Name", DotNetVersion); | ||
packWriter.WriteAttributeString ("FileSource", Path.Combine (DotNetPath, "sdk", DotNetVersion)); | ||
|
||
// EnableWorkloadResolver | ||
packWriter.WriteStartElement ("Component"); | ||
packWriter.WriteAttributeString ("Id", "EnableWorkloadResolver"); | ||
packWriter.WriteStartElement ("File"); | ||
packWriter.WriteAttributeString ("Id", "EnableWorkloadResolver"); | ||
packWriter.WriteAttributeString ("Name", "EnableWorkloadResolver.sentinel"); | ||
packWriter.WriteAttributeString ("KeyPath", "yes"); | ||
packWriter.WriteEndElement (); // </File> | ||
packWriter.WriteEndElement (); // </Component> | ||
packWriter.WriteEndElement (); // </Directory> DOTNETVERSION | ||
packWriter.WriteEndElement (); // </Directory> sdk | ||
|
||
// sdk-manifests | ||
var sdk_manifests_root = Path.Combine (DotNetPath, "sdk-manifests"); | ||
packWriter.WriteStartElement ("Directory"); | ||
packWriter.WriteAttributeString ("Id", "sdk_manifests"); | ||
packWriter.WriteAttributeString ("Name", "sdk-manifests"); | ||
|
||
// 5.0.100 | ||
var sdk_manifests = Directory.EnumerateDirectories (sdk_manifests_root).FirstOrDefault (); | ||
if (string.IsNullOrEmpty (sdk_manifests)) { | ||
Log.LogError ($"Cannot find child directory of: {sdk_manifests_root}"); | ||
return false; | ||
} | ||
var version_band = Path.GetFileName (sdk_manifests); | ||
packWriter.WriteStartElement ("Directory"); | ||
packWriter.WriteAttributeString ("Id", "DOTNETVERSIONBAND"); | ||
packWriter.WriteAttributeString ("Name", version_band); | ||
packWriter.WriteAttributeString ("FileSource", sdk_manifests); | ||
var workload = Path.Combine (sdk_manifests, "Microsoft.NET.Workload.Android"); | ||
if (Directory.Exists (workload)) { | ||
RecurseDirectory (sdk_manifests, packWriter, componentWriter, workload); | ||
} else { | ||
Log.LogError ($"Cannot find directory: {workload}"); | ||
return false; | ||
} | ||
packWriter.WriteEndElement (); // </Directory> version_band | ||
packWriter.WriteEndElement (); // </Directory> sdk-manifests | ||
|
||
// packs | ||
var packs_dir = Path.Combine (DotNetPath, "packs"); | ||
packWriter.WriteStartElement ("Directory"); | ||
packWriter.WriteAttributeString ("Id", "packs"); | ||
packWriter.WriteAttributeString ("Name", "packs"); | ||
foreach (var directory in Directory.EnumerateDirectories (packs_dir, "Microsoft.Android.*")) { | ||
RecurseDirectory (packs_dir, packWriter, componentWriter, directory); | ||
} | ||
|
||
packWriter.WriteEndDocument (); // </Directory> | ||
componentWriter.WriteEndDocument (); // </ComponentGroup> | ||
} | ||
|
||
var template = File.ReadAllText (Template); | ||
var contents = template | ||
.Replace ("@MSIVERSION@", MSIVersion) | ||
.Replace ("@DIRECTORIES@", directories.ToString ()) | ||
.Replace ("@COMPONENTS@", components.ToString ()); | ||
|
||
Log.LogMessage (MessageImportance.Low, "Writing XML to {0}: {1}", DestinationFile, contents); | ||
File.WriteAllText (DestinationFile, contents); | ||
|
||
return !Log.HasLoggedErrors; | ||
} | ||
|
||
static void RecurseDirectory (string top_dir, XmlWriter packWriter, XmlWriter componentWriter, string directory) | ||
{ | ||
var directoryId = GetId (top_dir, directory); | ||
packWriter.WriteStartElement ("Directory"); | ||
packWriter.WriteAttributeString ("Id", directoryId); | ||
packWriter.WriteAttributeString ("Name", Path.GetFileName (directory)); | ||
packWriter.WriteAttributeString ("FileSource", directory); | ||
foreach (var child in Directory.EnumerateDirectories (directory)) { | ||
var directoryName = Path.GetFileName (child); | ||
if (directoryName.StartsWith (".") || directoryName.StartsWith ("_")) | ||
continue; | ||
RecurseDirectory (top_dir, packWriter, componentWriter, child); | ||
} | ||
foreach (var file in Directory.EnumerateFiles (directory)) { | ||
var fileName = Path.GetFileName (file); | ||
if (fileName.StartsWith (".") || fileName.StartsWith ("_")) | ||
continue; | ||
var componentId = GetId (top_dir, file); | ||
packWriter.WriteStartElement ("Component"); | ||
packWriter.WriteAttributeString ("Id", componentId); | ||
packWriter.WriteStartElement ("File"); | ||
packWriter.WriteAttributeString ("Id", componentId); | ||
packWriter.WriteAttributeString ("Name", Path.GetFileName (file)); | ||
packWriter.WriteAttributeString ("KeyPath", "yes"); | ||
packWriter.WriteEndElement (); // </File> | ||
packWriter.WriteEndElement (); // </Component> | ||
componentWriter.WriteStartElement ("ComponentRef"); | ||
componentWriter.WriteAttributeString ("Id", componentId); | ||
componentWriter.WriteEndElement (); // </ComponentRef> | ||
} | ||
packWriter.WriteEndElement (); // </Directory> | ||
} | ||
|
||
static string GetId (string top_dir, string path) | ||
{ | ||
if (string.IsNullOrEmpty (path)) | ||
return path; | ||
if (path.Length > top_dir.Length + 1) { | ||
path = path.Substring (top_dir.Length + 1); | ||
} | ||
return GetHashString (path); | ||
} | ||
|
||
static byte [] GetHash (string inputString) | ||
{ | ||
using (var algorithm = SHA256.Create ()) | ||
return algorithm.ComputeHash (Encoding.UTF8.GetBytes (inputString)); | ||
} | ||
|
||
static string GetHashString (string inputString) | ||
{ | ||
var sb = new StringBuilder ("S", 65); | ||
foreach (byte b in GetHash (inputString)) | ||
sb.Append (b.ToString ("X2")); | ||
return sb.ToString (); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.