public async Task StartIIS(Uri uri, string contentRoot)
        {
            // Backup currently deployed apphost.config file
            using (_logger.BeginScope("StartIIS"))
            {
                var port = uri.Port;
                if (port == 0)
                {
                    throw new NotSupportedException("Cannot set port 0 for IIS.");
                }
                AddTemporaryAppHostConfig();

                ConfigureAppPool(contentRoot);

                ConfigureSite(contentRoot, port);

                ConfigureAppHostConfig(contentRoot);

                if (_deploymentParameters.ApplicationType == ApplicationType.Portable)
                {
                    ModifyAspNetCoreSectionInWebConfig("processPath", DotNetCommands.GetDotNetExecutable(_deploymentParameters.RuntimeArchitecture));
                }

                _serverManager.CommitChanges();

                await WaitUntilSiteStarted();
            }
        }
示例#2
0
        protected string GetDotNetExeForArchitecture()
        {
            var executableName = DotnetCommandName;

            // We expect x64 dotnet.exe to be on the path but we have to go searching for the x86 version.
            if (DotNetCommands.IsRunningX86OnX64(DeploymentParameters.RuntimeArchitecture))
            {
                executableName = DotNetCommands.GetDotNetExecutable(DeploymentParameters.RuntimeArchitecture);
                if (!File.Exists(executableName))
                {
                    throw new Exception($"Unable to find '{executableName}'.'");
                }
            }

            return(executableName);
        }
示例#3
0
 private void ModifyDotNetExePathInWebConfig()
 {
     // We assume the x64 dotnet.exe is on the path so we need to provide an absolute path for x86 scenarios.
     // Only do it for scenarios that rely on dotnet.exe (Core, portable, etc.).
     if (DeploymentParameters.RuntimeFlavor == RuntimeFlavor.CoreClr &&
         DeploymentParameters.ApplicationType == ApplicationType.Portable &&
         DotNetCommands.IsRunningX86OnX64(DeploymentParameters.RuntimeArchitecture))
     {
         var executableName = DotNetCommands.GetDotNetExecutable(DeploymentParameters.RuntimeArchitecture);
         if (!File.Exists(executableName))
         {
             throw new Exception($"Unable to find '{executableName}'.'");
         }
         ModifyAspNetCoreSectionInWebConfig("processPath", executableName);
     }
 }
示例#4
0
        private string GetIISExpressPath()
        {
            var programFiles = "Program Files";

            if (DotNetCommands.IsRunningX86OnX64(DeploymentParameters.RuntimeArchitecture))
            {
                programFiles = "Program Files (x86)";
            }

            // Get path to program files
            var iisExpressPath = Path.Combine(Environment.GetEnvironmentVariable("SystemDrive") + "\\", programFiles, "IIS Express", "iisexpress.exe");

            if (!File.Exists(iisExpressPath))
            {
                throw new Exception("Unable to find IISExpress on the machine: " + iisExpressPath);
            }

            return(iisExpressPath);
        }