From 46285253018e1086cf4e9ba272c0efb86120c486 Mon Sep 17 00:00:00 2001 From: Pavel Krymets Date: Thu, 9 Aug 2018 17:30:26 -0700 Subject: [PATCH] Start W3SVC if it is stopped (#1197) --- .vsts-pipelines/templates/build-steps.yml | 2 +- build/dependencies.props | 3 ++- .../IISDeployer.cs | 14 ++++++++++++++ ...AspNetCore.Server.IntegrationTesting.IIS.csproj | 3 ++- 4 files changed, 19 insertions(+), 3 deletions(-) diff --git a/.vsts-pipelines/templates/build-steps.yml b/.vsts-pipelines/templates/build-steps.yml index a5983be46b..dbc03620b5 100644 --- a/.vsts-pipelines/templates/build-steps.yml +++ b/.vsts-pipelines/templates/build-steps.yml @@ -3,7 +3,7 @@ phases: parameters: agentOs: Windows beforeBuild: - - powershell: "& ./tools/UpdateIISExpressCertificate.ps1; & ./tools/update_schema.ps1; Restart-Service w3svc" + - powershell: "& ./tools/UpdateIISExpressCertificate.ps1; & ./tools/update_schema.ps1" displayName: Prepare repo afterBuild: - task: PublishBuildArtifacts@1 diff --git a/build/dependencies.props b/build/dependencies.props index 38a8c11d2e..92fd8c35be 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -1,4 +1,4 @@ - + $(MSBuildAllProjects);$(MSBuildThisFileFullPath) @@ -47,6 +47,7 @@ 4.5.0 4.5.1 4.5.0 + 4.5.0 9.0.1 2.3.1 2.4.0 diff --git a/src/Microsoft.AspNetCore.Server.IntegrationTesting.IIS/IISDeployer.cs b/src/Microsoft.AspNetCore.Server.IntegrationTesting.IIS/IISDeployer.cs index f677632485..583eb23d38 100644 --- a/src/Microsoft.AspNetCore.Server.IntegrationTesting.IIS/IISDeployer.cs +++ b/src/Microsoft.AspNetCore.Server.IntegrationTesting.IIS/IISDeployer.cs @@ -6,12 +6,14 @@ using System.Diagnostics; using System.IO; using System.Linq; using System.Runtime.InteropServices; +using System.ServiceProcess; using System.Threading; using System.Threading.Tasks; using System.Xml.Linq; using Microsoft.AspNetCore.Server.IntegrationTesting.Common; using Microsoft.Extensions.Logging; using Microsoft.Web.Administration; +using TimeoutException = System.TimeoutException; namespace Microsoft.AspNetCore.Server.IntegrationTesting.IIS { @@ -164,6 +166,18 @@ namespace Microsoft.AspNetCore.Server.IntegrationTesting.IIS private async Task WaitUntilSiteStarted() { + ServiceController serviceController = new ServiceController("w3svc"); + Logger.LogInformation("W3SVC status " + serviceController.Status); + + if (serviceController.Status != ServiceControllerStatus.Running && + serviceController.Status != ServiceControllerStatus.StartPending) + { + Logger.LogInformation("Starting W3SVC"); + + serviceController.Start(); + serviceController.WaitForStatus(ServiceControllerStatus.Running, _timeout); + } + var sw = Stopwatch.StartNew(); while (sw.Elapsed < _timeout) diff --git a/src/Microsoft.AspNetCore.Server.IntegrationTesting.IIS/Microsoft.AspNetCore.Server.IntegrationTesting.IIS.csproj b/src/Microsoft.AspNetCore.Server.IntegrationTesting.IIS/Microsoft.AspNetCore.Server.IntegrationTesting.IIS.csproj index 3678730c7e..d91d5c5a04 100644 --- a/src/Microsoft.AspNetCore.Server.IntegrationTesting.IIS/Microsoft.AspNetCore.Server.IntegrationTesting.IIS.csproj +++ b/src/Microsoft.AspNetCore.Server.IntegrationTesting.IIS/Microsoft.AspNetCore.Server.IntegrationTesting.IIS.csproj @@ -1,4 +1,4 @@ - + netstandard2.0 @@ -20,6 +20,7 @@ +