Beispiel #1
0
        public string GetWebApplicationPath(string machineName, string fullWebAppName)
        {
            if (string.IsNullOrEmpty(machineName))
            {
                throw new ArgumentException("Argument can't be null nor empty.", "machineName");
            }

            if (string.IsNullOrEmpty(fullWebAppName))
            {
                throw new ArgumentException("Argument can't be null nor empty.", "fullWebAppName");
            }

            var msDeployArgs =
                new[]
            {
                "-verb:dump",
                string.Format("-source:appHostConfig=\"{0}\",computerName=\"{1}\"", fullWebAppName, machineName),
                "-xml"
            };

            try
            {
                string stdout;

                _msDeploy.Run(msDeployArgs, out stdout);

                XAttribute attribute =
                    XDocument.Parse(stdout)
                    .Descendants("virtualDirectory")
                    .Single()
                    .Descendants("dirPath")
                    .Single()
                    .Attribute("path");

                if (attribute == null)
                {
                    throw new InternalException("Couldn't get 'path' attribute.");
                }

                return(attribute.Value);
            }
            catch (MsDeployException e)
            {
                if (!string.IsNullOrEmpty(e.ConsoleError) && _SiteDoesNotExistRegex.IsMatch(e.ConsoleError))
                {
                    return(null);
                }

                throw;
            }
        }
        protected override void DoExecute()
        {
            // TODO IMM HI: dependency
            var msDeployArgs =
                new[]
            {
                "-verb:sync",
                string.Format("-source:package=\"{0}\"", _packageFilePathProvider.Value),
                string.Format("-dest:auto,computerName=\"{0}\"", _webServerMachineName),
            };

            string consoleOutput;

            _msDeploy.Run(msDeployArgs, out consoleOutput);
        }
Beispiel #3
0
        protected override void DoExecute()
        {
            if (!Path.IsPathRooted(_webAppBinariesDirPathProvider.Value))
            {
                throw new ArgumentException(string.Format("Given web app binaries dir path ('{0}') is not an absolute path.", _webAppBinariesDirPathProvider.Value));
            }

            string iisAppPath = _webAppBinariesDirPathProvider.Value;
            string webDeployManifestFilePath = Path.Combine(_webAppBinariesParentDirPath, _WebDeployManifestFileName);

            try
            {
                _msDeploy.CreateIisAppManifestFile(iisAppPath, webDeployManifestFilePath);

                string paramMatchValue =
                    string.Format(
                        "^{0}$",
                        _webAppBinariesDirPathProvider.Value
                        .Replace("\\", "\\\\")
                        .Replace(".", "\\."));

                var msDeployArgs =
                    new[]
                {
                    "-verb:sync",
                    string.Format("-source:manifest=\"{0}\"", webDeployManifestFilePath),
                    string.Format("-dest:package=\"{0}\"", _packageFilePath),
                    string.Format("-declareParam:name=IIS Web Application Name,defaultValue=\"{0}\",tags=iisApp", _fullWebAppName),
                    string.Format("-declareParam:name=IIS Web Application Name,kind=ProviderPath,scope=iisApp,match=\"{0}\"", paramMatchValue),
                    string.Format("-declareParam:name=IIS Web Application Name,kind=ProviderPath,scope=setAcl,match=\"{0}\"", paramMatchValue),
                };

                string consoleOutput;

                _msDeploy.Run(msDeployArgs, out consoleOutput);
            }
            finally
            {
                if (File.Exists(webDeployManifestFilePath))
                {
                    File.Delete(webDeployManifestFilePath);
                }
            }
        }