// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; using System.Collections.Generic; using System.IO; namespace Microsoft.AspNetCore.Server.Testing { /// /// Parameters to control application deployment. /// public class DeploymentParameters { /// /// Creates an instance of . /// /// Source code location of the target location to be deployed. /// Where to be deployed on. /// Flavor of the clr to run against. /// Architecture of the runtime to be used. public DeploymentParameters( string applicationPath, ServerType serverType, RuntimeFlavor runtimeFlavor, RuntimeArchitecture runtimeArchitecture) { if (string.IsNullOrEmpty(applicationPath)) { throw new ArgumentException("Value cannot be null.", nameof(applicationPath)); } if (!Directory.Exists(applicationPath)) { throw new DirectoryNotFoundException(string.Format("Application path {0} does not exist.", applicationPath)); } if (runtimeArchitecture == RuntimeArchitecture.x86) { throw new NotSupportedException("32 bit compilation is not yet supported. Don't remove the tests, just disable them for now."); } ApplicationPath = applicationPath; ServerType = serverType; RuntimeFlavor = runtimeFlavor; EnvironmentVariables.Add(new KeyValuePair("ASPNETCORE_DETAILEDERRORS", "true")); } public ServerType ServerType { get; } public RuntimeFlavor RuntimeFlavor { get; } public RuntimeArchitecture RuntimeArchitecture { get; } = RuntimeArchitecture.x64; /// /// Suggested base url for the deployed application. The final deployed url could be /// different than this. Use for the /// deployed url. /// public string ApplicationBaseUriHint { get; set; } public string EnvironmentName { get; set; } public string ServerConfigTemplateContent { get; set; } public string ServerConfigLocation { get; set; } public string SiteName { get; set; } public string ApplicationPath { get; set; } public string TargetFramework { get; set; } /// /// To publish the application before deployment. /// public bool PublishApplicationBeforeDeployment { get; set; } public ApplicationType ApplicationType { get; set; } public string PublishedApplicationRootPath { get; set; } /// /// Environment variables to be set before starting the host. /// Not applicable for IIS Scenarios. /// public List> EnvironmentVariables { get; private set; } = new List>(); /// /// For any application level cleanup to be invoked after performing host cleanup. /// public Action UserAdditionalCleanup { get; set; } public override string ToString() { return string.Format( "[Variation] :: ServerType={0}, Runtime={1}, Arch={2}, BaseUrlHint={3}, Publish={4}", ServerType, RuntimeFlavor, RuntimeArchitecture, ApplicationBaseUriHint, PublishApplicationBeforeDeployment); } } }