diff --git a/src/Tasks/Microsoft.NET.Build.Tasks/ClsidMap.cs b/src/Tasks/Microsoft.NET.Build.Tasks/ClsidMap.cs index 8075190cf419..141d0d3134f4 100644 --- a/src/Tasks/Microsoft.NET.Build.Tasks/ClsidMap.cs +++ b/src/Tasks/Microsoft.NET.Build.Tasks/ClsidMap.cs @@ -39,7 +39,7 @@ public static void Create(MetadataReader metadataReader, string clsidMapPath) // Only public COM-visible classes can be exposed via the COM host. if (TypeIsPublic(metadataReader, definition) && TypeIsClass(metadataReader, definition) && IsComVisible(metadataReader, definition, isAssemblyComVisible)) { - string guid = GetTypeGuid(metadataReader, definition); + string guid = GetTypeGuid(metadataReader, definition).ToString("B"); if (clsidMap.ContainsKey(guid)) { @@ -177,7 +177,7 @@ private static CustomAttributeHandle GetComVisibleAttribute(MetadataReader reade return new CustomAttributeHandle(); } - private static string GetTypeGuid(MetadataReader reader, TypeDefinition type) + private static Guid GetTypeGuid(MetadataReader reader, TypeDefinition type) { // Find the class' GUID by reading the GuidAttribute value. // We do not support implicit runtime-generated GUIDs for the .NET Core COM host. @@ -189,7 +189,7 @@ private static string GetTypeGuid(MetadataReader reader, TypeDefinition type) if (reader.StringComparer.Equals(attributeType.Namespace, "System.Runtime.InteropServices") && reader.StringComparer.Equals(attributeType.Name, "GuidAttribute")) { CustomAttributeValue data = attribute.DecodeValue(new TypeResolver()); - return (string)data.FixedArguments[0].Value; + return Guid.Parse((string)data.FixedArguments[0].Value); } } throw new BuildErrorException(Strings.ClsidMapExportedTypesRequireExplicitGuid, GetTypeName(reader, type)); diff --git a/src/Tasks/Microsoft.NET.Build.Tasks/RegFreeComManifest.cs b/src/Tasks/Microsoft.NET.Build.Tasks/RegFreeComManifest.cs index 65bec4e7f946..8e2b8ff2e4bb 100644 --- a/src/Tasks/Microsoft.NET.Build.Tasks/RegFreeComManifest.cs +++ b/src/Tasks/Microsoft.NET.Build.Tasks/RegFreeComManifest.cs @@ -20,13 +20,13 @@ internal static class RegFreeComManifest /// The name of the assembly. /// The name of the comhost library. /// The version of the assembly. - /// The path to the clasidmap file. + /// The path to the clsidmap file. /// The path to which to write the manifest. public static void CreateManifestFromClsidmap(string assemblyName, string comHostName, string assemblyVersion, string clsidMapPath, string comManifestPath) { - XNamespace ns = "urn:shemas-microsoft-com:asm.v1"; + XNamespace ns = "urn:schemas-microsoft-com:asm.v1"; - XElement manifest = new XElement(ns + "assembly", new XAttribute("mainfestVersion", "1.0")); + XElement manifest = new XElement(ns + "assembly", new XAttribute("manifestVersion", "1.0")); manifest.Add(new XElement(ns + "assemblyIdentity", new XAttribute("type", "win32"), new XAttribute("name", $"{assemblyName}.X"), @@ -44,14 +44,19 @@ public static void CreateManifestFromClsidmap(string assemblyName, string comHos foreach (JProperty property in clsidMap.Properties()) { - string guid = property.Name; - fileElement.Add(new XElement(ns + "comClass", new XAttribute("clsid", guid), new XAttribute("threadingModel", "Both"))); + string guidMaybe = property.Name; + Guid guid = Guid.Parse(guidMaybe); + fileElement.Add(new XElement(ns + "comClass", new XAttribute("clsid", guid.ToString("B")), new XAttribute("threadingModel", "Both"))); } manifest.Add(fileElement); XDocument manifestDocument = new XDocument(new XDeclaration("1.0", "UTF-8", "yes"), manifest); - using (XmlWriter manifestWriter = XmlWriter.Create(comManifestPath)) + XmlWriterSettings settings = new XmlWriterSettings() + { + Encoding = new UTF8Encoding(encoderShouldEmitUTF8Identifier: false) + }; + using (XmlWriter manifestWriter = XmlWriter.Create(comManifestPath, settings)) { manifestDocument.WriteTo(manifestWriter); }