-
Notifications
You must be signed in to change notification settings - Fork 553
[One .NET] temporary Windows & macOS installers for .NET 6 #5225
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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; | ||
} | ||
} | ||
} |
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 (); | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -103,8 +103,8 @@ stages: | |
displayName: make jenkins | ||
|
||
- script: > | ||
echo "make create-installers V=1 CONFIGURATION=$(XA.Build.Configuration)" && | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't we want to continue calling There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. …or do we not want to create a Workload installer for the OSS pipeline? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We would have to add commands to create the I thought it was simpler to not create these installers on the OSS pipeline for now. But if we have a need, we could? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
We don't have a Windows stage OSS build (but perhaps we should?), so I don't think this would be needed. I'm largely "just pondering" the community engagement angle. Is there a reason to not provide "OSS-blessed" packages, and/or ensure that the OSS tree can produce the That said, it might very well fail now, as the |
||
make create-installers V=1 CONFIGURATION=$(XA.Build.Configuration) | ||
echo "make create-pkg create-vsix V=1 CONFIGURATION=$(XA.Build.Configuration)" && | ||
make create-pkg create-vsix V=1 CONFIGURATION=$(XA.Build.Configuration) | ||
workingDirectory: $(Build.SourcesDirectory) | ||
displayName: create installers | ||
|
||
|
Uh oh!
There was an error while loading. Please reload this page.