Esempio n. 1
0
        /// <summary>
        /// Load content of SDKManifest.xml
        /// </summary>
        private void LoadManifestFile()
        {
            /*
             * Extension SDK Manifest:
             * <FileList
             *      TargetPlatform="UAP"
             *      TargetPlatformMinVersion="1.0.0.0"
             *      TargetPlatformVersion="1.0.0.0"
             *      SDKType = "Platform" | "Framework" | "External"
             *      DisplayName = ""My SDK""
             *      ProductFamilyName = ""UnitTest SDKs""
             *      FrameworkIdentity-Debug = ""Name=MySDK.10.Debug, MinVersion=1.0.0.0""
             *      FrameworkIdentity-Retail = ""Name=MySDK.10, MinVersion=1.0.0.0""
             *      TargetFramework = "".NETCore, version=v4.5; .NETFramework, version=v4.5""
             *      MinVSVersion = ""11.0""
             *      AppliesTo = ""WindowsAppContainer + WindowsXAML""
             *      SupportPrefer32Bit = ""True""
             *      SupportedArchitectures = ""x86;x64;ARM""
             *      SupportsMultipleVersions = ""Error""
             *      AppX-Debug-x86 = "".\AppX\Debug\x86\Microsoft.MySDK.x86.Debug.1.0.appx""
             *      AppX-Debug-x64 = "".\AppX\Debug\x64\Microsoft.MySDK.x64.Debug.1.0.appx""
             *      AppX-Debug-ARM = "".\AppX\Debug\ARM\Microsoft.MySDK.ARM.Debug.1.0.appx""
             *      AppX-Retail-x86 = "".\AppX\Retail\x86\Microsoft.MySDK.x86.1.0.appx""
             *      AppX-Retail-x64 = "".\AppX\Retail\x64\Microsoft.MySDK.x64.1.0.appx""
             *      AppX-Retail-ARM = "".\AppX\Retail\ARM\Microsoft.MySDK.ARM.1.0.appx""
             *      CopyRedistToSubDirectory = "".""
             *      DependsOn = ""SDKB, version=2.0""
             *      MoreInfo = ""http://msdn.microsoft.com/MySDK""
             *      MaxPlatformVersion = ""8.0""
             *      MinOSVersion = ""6.2.1""
             *      MaxOSVersionTested = ""6.2.1"">
             *
             *      <!-- New Style -->
             *      <ContainedApiContracts>
             *          <ApiContract name="UAP" version="1.0.0.0" />
             *      </ContainedApiContracts>
             *
             *      <File Reference = ""MySDK.Sprint.winmd"" Implementation = ""XNASprintImpl.dll"">
             *          <Registration Type = ""Flipper"" Implementation = ""XNASprintFlipperImpl.dll"" />
             *          <Registration Type = ""Flexer"" Implementation = ""XNASprintFlexerImpl.dll"" />
             *          <ToolboxItems VSCategory = ""Toolbox.Default"" />
             *      </File>
             *  </FileList>
             *
             * Platform SDK Manifest:
             *  <FileList
             *      DisplayName = ""Windows""
             *      PlatformIdentity = ""Windows, version=8.0""
             *      TargetFramework = "".NETCore, version=v4.5; .NETFramework, version=v4.5""
             *      MinVSVersion = ""11.0""
             *      MinOSVersion = ""6.2.1""
             *      MaxOSVersionTested = ""6.2.1""
             *      UnsupportedDowntarget = ""Windows, version=8.0"">
             *
             *  <File Reference = ""Windows"">
             *      <ToolboxItems VSCategory = ""Toolbox.Default""/>
             *  </File>
             *  </FileList>
             */
            string sdkManifestPath = Path.Combine(_pathToSdk, "SDKManifest.xml");

            try
            {
                if (File.Exists(sdkManifestPath))
                {
                    XmlDocument       doc            = new XmlDocument();
                    XmlReaderSettings readerSettings = new XmlReaderSettings {
                        DtdProcessing = DtdProcessing.Ignore
                    };

                    using (XmlReader xmlReader = XmlReader.Create(sdkManifestPath, readerSettings))
                    {
                        doc.Load(xmlReader);
                    }

                    XmlElement rootElement = null;

                    foreach (XmlNode childNode in doc.ChildNodes)
                    {
                        if (childNode.NodeType == XmlNodeType.Element &&
                            string.Equals(childNode.Name, Elements.FileList, StringComparison.Ordinal))
                        {
                            rootElement = (XmlElement)childNode;
                            break;
                        }
                    }

                    if (rootElement != null)
                    {
                        ReadFileListAttributes(rootElement.Attributes);
                        foreach (XmlNode childNode in rootElement.ChildNodes)
                        {
                            XmlElement childElement = childNode as XmlElement;
                            if (childElement == null)
                            {
                                continue;
                            }

                            if (ApiContract.IsContainedApiContractsElement(childElement.Name))
                            {
                                ApiContracts = new List <ApiContract>();
                                ApiContract.ReadContractsElement(childElement, ApiContracts);
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                if (ExceptionHandling.IsCriticalException(e))
                {
                    throw;
                }

                ReadError        = true;
                ReadErrorMessage = e.Message;
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Load content of Platform.xml
        /// </summary>
        private void LoadManifestFile()
        {
            /*
             * Platform.xml format:
             *
             * <ApplicationPlatform name="UAP" friendlyName="Universal Application Platform" version="1.0.0.0">
             *    <DependentPlatform name="UAP" version="1.0.0.0" />
             *    <ContainedApiContracts>
             *       <ApiContract name="UAP" version="1.0.0.0" />
             *    </ContainedApiContracts>
             * </ApplicationPlatform>
             */
            try
            {
                string platformManifestPath = Path.Combine(_pathToManifest, "Platform.xml");

                if (File.Exists(platformManifestPath))
                {
                    XmlDocument       doc            = new XmlDocument();
                    XmlReaderSettings readerSettings = new XmlReaderSettings {
                        DtdProcessing = DtdProcessing.Ignore
                    };

                    using (XmlReader xmlReader = XmlReader.Create(platformManifestPath, readerSettings))
                    {
                        doc.Load(xmlReader);
                    }

                    XmlElement rootElement = null;

                    foreach (XmlNode childNode in doc.ChildNodes)
                    {
                        if (childNode.NodeType == XmlNodeType.Element &&
                            string.Equals(childNode.Name, Elements.ApplicationPlatform, StringComparison.Ordinal))
                        {
                            rootElement = (XmlElement)childNode;
                            break;
                        }
                    }

                    DependentPlatforms = new List <DependentPlatform>();
                    ApiContracts       = new List <ApiContract>();

                    if (rootElement != null)
                    {
                        Name            = rootElement.GetAttribute(Attributes.Name);
                        FriendlyName    = rootElement.GetAttribute(Attributes.FriendlyName);
                        PlatformVersion = rootElement.GetAttribute(Attributes.Version);

                        foreach (XmlNode childNode in rootElement.ChildNodes)
                        {
                            if (!(childNode is XmlElement childElement))
                            {
                                continue;
                            }

                            if (ApiContract.IsContainedApiContractsElement(childElement.Name))
                            {
                                ApiContract.ReadContractsElement(childElement, ApiContracts);
                            }
                            else if (ApiContract.IsVersionedContentElement(childElement.Name))
                            {
                                bool.TryParse(childElement.InnerText, out bool versionedContent);
                                VersionedContent = versionedContent;
                            }
                            else if (string.Equals(childElement.Name, Elements.DependentPlatform, StringComparison.Ordinal))
                            {
                                DependentPlatforms.Add(new DependentPlatform(childElement.GetAttribute(Attributes.Name), childElement.GetAttribute(Attributes.Version)));
                            }
                        }
                    }
                }
                else
                {
                    ReadErrorMessage = ResourceUtilities.FormatResourceString("PlatformManifest.MissingPlatformXml", platformManifestPath);
                }
            }
            catch (Exception e)
            {
                if (ExceptionHandling.IsCriticalException(e))
                {
                    throw;
                }

                ReadErrorMessage = e.Message;
            }
        }