public override void PostSync(DeploymentSyncContext syncContext) { var provider = syncContext.DestinationObject; if (provider.Name == "MSDeploy." + ServicePathProvider.ObjectName && !ServicePathHelper.IsAbsolutePhysicalPath(provider.ProviderContext.Path)) { var serviceName = ServicePathHelper.GetServiceName(provider.ProviderContext.Path); var serviceController = new ServiceController(serviceName); if (serviceController.Status == ServiceControllerStatus.Stopped) { syncContext.SourceObject.BaseContext.RaiseEvent(new WindowsServiceTraceEvent(TraceLevel.Info, Resources.StartingServiceEvent, serviceName)); if (!syncContext.WhatIf) { serviceController.Start(); } } if (!syncContext.WhatIf) { int serviceTimeoutSeconds = provider.ProviderContext.ProviderOptions.ProviderSettings.GetValueOrDefault("serviceTimeout", 20); serviceController.WaitForStatus(ServiceControllerStatus.Running, TimeSpan.FromSeconds(serviceTimeoutSeconds)); } } base.PostSync(syncContext); }
public override IEnumerable <DeploymentObjectProvider> GetChildProviders() { string physicalPath = ServicePathHelper.GetPhysicalPath(providerContext.Path); string childProviderName = _isDirectory ? "dirPath" : "filePath"; yield return(CreateProvider(childProviderName, physicalPath, Name)); }
DeploymentObjectProvider CreateDirPathProvider() { var providerOptions = new DeploymentProviderOptions("dirPath"); providerOptions.Path = ServicePathHelper.GetPhysicalPath(Path); DeploymentObjectProvider provider = CreateProvider(providerOptions, ObjectName + LibFolderName); return(provider); }
public override IEnumerable <DeploymentObjectProvider> GetChildProviders() { if (_isDirectory) { yield return(CreateDirPathProvider()); } else { string physicalPath = ServicePathHelper.GetPhysicalPath(Path); yield return(CreateProvider("filePath", physicalPath, Name)); } }
public override void Add(DeploymentObject source, bool whatIf) { ServicePathHelper.GetPhysicalPath(providerContext.Path); foreach (var deploymentObject in source.GetChildren()) { if (deploymentObject.Name == "dirPath") { _isDirectory = true; break; } } }
public override DeploymentObjectProvider AddChild(DeploymentObject source, int position, bool whatIf) { string physicalPath = ServicePathHelper.GetPhysicalPath(Path); if (source.Name == "contentPathLib") { return(CreateProvider("contentPathLib", Path, "ContentPathLib")); } if (source.Name == "dirPath" && !_isDirectory) { throw new DeploymentException(Resources.FileAlreadyExists, physicalPath); } throw new DeploymentException(Resources.DirectoryAlreadyExists, physicalPath); }
void StopService(DeploymentSyncContext syncContext) { if (_hasStoppedService) { return; } _hasStoppedService = true; var provider = syncContext.DestinationObject; if (provider.Name == "MSDeploy." + ServicePathProvider.ObjectName && !ServicePathHelper.IsAbsolutePhysicalPath(provider.ProviderContext.Path)) { var serviceName = ServicePathHelper.GetServiceName(provider.ProviderContext.Path); var serviceController = new ServiceController(serviceName); if (serviceController.Status == ServiceControllerStatus.Running || serviceController.Status == ServiceControllerStatus.Paused) { syncContext.SourceObject.BaseContext.RaiseEvent(new WindowsServiceTraceEvent(TraceLevel.Info, Resources.StoppingServiceEvent, serviceName)); if (!syncContext.WhatIf) { serviceController.Stop(); } } if (!syncContext.WhatIf) { int serviceTimeoutSeconds = provider.ProviderContext.ProviderOptions.ProviderSettings.GetValueOrDefault("serviceTimeout", 20); serviceController.WaitForStatus(ServiceControllerStatus.Stopped, TimeSpan.FromSeconds(serviceTimeoutSeconds)); } // TODO: Info, service already stopped // TODO: Invalid service name // TODO: Can't stop service (perms) // TODO: Can't stop service (timeout) } base.PreSync(syncContext); }
internal void EnsureNodeExists(out bool isDirectory) { isDirectory = false; EnsureNodeExists(ServicePathHelper.GetPhysicalPath(Path), out isDirectory); }
public override void GetAttributes(DeploymentAddAttributeContext addContext) { EnsureNodeExists(ServicePathHelper.GetPhysicalPath(Path), out _isDirectory); }