Пример #1
0
        public void MsDeployProfile_ReturnsCorrectMsDeployPublishProfile()
        {
            MSDeployPublishProfile msDeployProfile = new MSDeployPublishProfile()
            {
                SiteUrlToLaunchAfterPublish = "https://webappwithdb.azurewebsites.net",
                LaunchSiteAfterPublish      = true,
                MSDeployServiceURL          = "webappwithdb.scm.azurewebsites.net:443",
                DeployIisAppPath            = "webappwithdb",
                UserName = "******"
            };

            Assert.Equal(TestResources.MSDeployPublishProfile, msDeployProfile.ToString());
        }
Пример #2
0
        public static KeyValuePair <string, string> CreateMSDeployPublishProfileFromPublishSettings(string publishSettingsContents)
        {
            using (XmlTextReader reader = new XmlTextReader(new StringReader(publishSettingsContents)))
            {
                XmlDocument xmldoc = new XmlDocument();
                xmldoc.Load(reader);

                XmlNode root        = xmldoc.DocumentElement;
                XmlNode profileNode = root.FirstChild;
                for (; profileNode != null; profileNode = profileNode.NextSibling)
                {
                    XmlAttribute publishMethodAttr = null;
                    if (profileNode.Attributes != null)
                    {
                        publishMethodAttr = profileNode.Attributes["publishMethod"];
                    }

                    if (publishMethodAttr != null && !string.IsNullOrEmpty(publishMethodAttr.Value) && string.Equals(publishMethodAttr.Value, MSDeployPublishProfile.PublishMethod, StringComparison.Ordinal))
                    {
                        IPublishProfile msDeployPublishProfile = new MSDeployPublishProfile()
                        {
                            MSDeployServiceURL          = profileNode.Attributes["publishUrl"]?.Value,
                            DeployIisAppPath            = profileNode.Attributes["msdeploySite"]?.Value,
                            SiteUrlToLaunchAfterPublish = profileNode.Attributes["destinationAppUrl"]?.Value,
                            LaunchSiteAfterPublish      = true,
                            UserName = profileNode.Attributes["userName"]?.Value
                        };

                        string profileName = profileNode.Attributes["profileName"]?.Value ?? "msDeployProfile";
                        return(new KeyValuePair <string, string>(profileName, msDeployPublishProfile.ToString()));
                    }
                }
            }

            return(new KeyValuePair <string, string>());
        }