public Project GetProject() { var solutions = VsHelper.GetSolutions(_root); return(new Project { ProjectFiles = (from s in solutions from p in s.Projects where p.IsWap || p.IsWebSite select MakeRelative(p.AbsolutePath)).ToList(), Files = GetFiles().ToList(), SolutionFiles = solutions.Select(s => MakeRelative(s.Path)).ToList() }); }
public ISiteBuilder CreateBuilder(ITracer tracer, ILogger logger, IDeploymentSettingsManager settings, IFileFinder fileFinder) { string repositoryRoot = _environment.RepositoryPath; // If there's a custom deployment file then let that take over. var command = settings.GetValue(SettingsKeys.Command); if (!String.IsNullOrEmpty(command)) { return(new CustomBuilder(_environment, settings, _propertyProvider, repositoryRoot, command)); } // If the repository has an explicit pointer to a project path to be deployed // then use it. string targetProjectPath = settings.GetValue(SettingsKeys.Project); if (!String.IsNullOrEmpty(targetProjectPath)) { tracer.Trace("Specific project was specified: " + targetProjectPath); targetProjectPath = Path.GetFullPath(Path.Combine(repositoryRoot, targetProjectPath.TrimStart('/', '\\'))); // Try to resolve the project return(ResolveProject(repositoryRoot, targetProjectPath, settings, fileFinder, tryWebSiteProject: true, searchOption: SearchOption.TopDirectoryOnly)); } // Get all solutions in the current repository path var solutions = VsHelper.GetSolutions(repositoryRoot, fileFinder).ToList(); if (!solutions.Any()) { return(ResolveProject(repositoryRoot, settings, fileFinder, searchOption: SearchOption.AllDirectories)); } // More than one solution is ambiguous if (solutions.Count > 1) { // TODO: Show relative paths in error messages ThrowAmbiguousSolutionsError(solutions); } // We have a solution VsSolution solution = solutions[0]; // We need to determine what project to deploy so get a list of all web projects and // figure out with some heuristic, which one to deploy. // TODO: Pick only 1 and throw if there's more than one VsSolutionProject project = solution.Projects.Where(p => p.IsWap || p.IsWebSite).FirstOrDefault(); if (project == null) { logger.Log(Resources.Log_NoDeployableProjects, solution.Path); return(ResolveNonAspProject(repositoryRoot, null, settings)); } if (project.IsWap) { return(new WapBuilder(_environment, settings, _propertyProvider, repositoryRoot, project.AbsolutePath, solution.Path)); } return(new WebSiteBuilder(_environment, settings, _propertyProvider, repositoryRoot, project.AbsolutePath, solution.Path)); }
public ISiteBuilder CreateBuilder(ITracer tracer, ILogger logger, IDeploymentSettingsManager settings, IRepository repository) { string repositoryRoot = repository.RepositoryPath; // Use the cached vs projects file finder for: a. better performance, b. ignoring solutions/projects under node_modules var fileFinder = new CachedVsProjectsFileFinder(repository); // If there's a custom deployment file then let that take over. var command = settings.GetValue(SettingsKeys.Command); if (!String.IsNullOrEmpty(command)) { return(new CustomBuilder(_environment, settings, _propertyProvider, repositoryRoot, command)); } // If the user provided specific generator arguments, that overrides any detection logic string scriptGeneratorArgs = settings.GetValue(SettingsKeys.ScriptGeneratorArgs); if (!String.IsNullOrEmpty(scriptGeneratorArgs)) { return(new CustomGeneratorCommandSiteBuilder(_environment, settings, _propertyProvider, repositoryRoot, scriptGeneratorArgs)); } // If the repository has an explicit pointer to a project path to be deployed // then use it. string targetProjectPath = settings.GetValue(SettingsKeys.Project); if (!String.IsNullOrEmpty(targetProjectPath)) { tracer.Trace("Specific project was specified: " + targetProjectPath); targetProjectPath = Path.GetFullPath(Path.Combine(repositoryRoot, targetProjectPath.TrimStart('/', '\\'))); } if (settings.RunFromLocalZip()) { return(new RunFromZipSiteBuilder()); } if (!settings.DoBuildDuringDeployment()) { var projectPath = !String.IsNullOrEmpty(targetProjectPath) ? targetProjectPath : repositoryRoot; return(new BasicBuilder(_environment, settings, _propertyProvider, repositoryRoot, projectPath)); } if (!String.IsNullOrEmpty(targetProjectPath)) { // Try to resolve the project return(ResolveProject(repositoryRoot, targetProjectPath, settings, fileFinder, tryWebSiteProject: true, searchOption: SearchOption.TopDirectoryOnly)); } // Get all solutions in the current repository path var solutions = VsHelper.GetSolutions(repositoryRoot, fileFinder).ToList(); if (!solutions.Any()) { return(ResolveProject(repositoryRoot, settings, fileFinder, searchOption: SearchOption.AllDirectories)); } // More than one solution is ambiguous if (solutions.Count > 1) { // TODO: Show relative paths in error messages ThrowAmbiguousSolutionsError(solutions); } // We have a solution VsSolution solution = solutions[0]; // We need to determine what project to deploy so get a list of all web projects and // figure out with some heuristic, which one to deploy. // TODO: Pick only 1 and throw if there's more than one // shunTODO need to implement this VsSolutionProject project = solution.Projects.Where(p => p.IsWap || p.IsWebSite || p.IsAspNetCore || p.IsFunctionApp).FirstOrDefault(); if (project == null) { // Try executable type project project = solution.Projects.Where(p => p.IsExecutable).FirstOrDefault(); if (project != null) { return(new DotNetConsoleBuilder(_environment, settings, _propertyProvider, repositoryRoot, project.AbsolutePath, solution.Path)); } logger.Log(Resources.Log_NoDeployableProjects, solution.Path); // we have a solution file, but no deployable project // shunTODO how often do we run into this return(ResolveNonAspProject(repositoryRoot, null, settings)); } if (project.IsWap) { return(new WapBuilder(_environment, settings, _propertyProvider, repositoryRoot, project.AbsolutePath, solution.Path)); } if (project.IsAspNetCore) { return(new AspNetCoreBuilder(_environment, settings, _propertyProvider, repositoryRoot, project.AbsolutePath, solution.Path)); } if (project.IsWebSite) { return(new WebSiteBuilder(_environment, settings, _propertyProvider, repositoryRoot, project.AbsolutePath, solution.Path)); } return(new FunctionMsbuildBuilder(_environment, settings, _propertyProvider, repositoryRoot, project.AbsolutePath, solution.Path)); }
public ISiteBuilder CreateBuilder(ITracer tracer, ILogger logger, IDeploymentSettingsManager settings, IRepository repository, DeploymentInfoBase deploymentInfo) { string repositoryRoot = repository.RepositoryPath; // Use the cached vs projects file finder for: a. better performance, b. ignoring solutions/projects under node_modules var fileFinder = new CachedVsProjectsFileFinder(repository); // If there's a custom deployment file then let that take over. var command = settings.GetValue(SettingsKeys.Command); if (!String.IsNullOrEmpty(command)) { return(new CustomBuilder(_environment, settings, _propertyProvider, repositoryRoot, command)); } // If the user provided specific generator arguments, that overrides any detection logic string scriptGeneratorArgs = settings.GetValue(SettingsKeys.ScriptGeneratorArgs); if (!String.IsNullOrEmpty(scriptGeneratorArgs)) { return(new CustomGeneratorCommandSiteBuilder(_environment, settings, _propertyProvider, repositoryRoot, scriptGeneratorArgs)); } // If the repository has an explicit pointer to a project path to be deployed // then use it. string targetProjectPath = settings.GetValue(SettingsKeys.Project); if (!String.IsNullOrEmpty(targetProjectPath)) { tracer.Trace("Specific project was specified: " + targetProjectPath); targetProjectPath = Path.GetFullPath(Path.Combine(repositoryRoot, targetProjectPath.TrimStart('/', '\\'))); } if (deploymentInfo != null && deploymentInfo.Deployer == Constants.OneDeploy) { var projectPath = !String.IsNullOrEmpty(targetProjectPath) ? targetProjectPath : repositoryRoot; return(new OneDeployBuilder(_environment, settings, _propertyProvider, repositoryRoot, projectPath, deploymentInfo)); } if (settings.RunFromLocalZip()) { return(new RunFromZipSiteBuilder()); } if (!settings.DoBuildDuringDeployment()) { var projectPath = !String.IsNullOrEmpty(targetProjectPath) ? targetProjectPath : repositoryRoot; return(new BasicBuilder(_environment, settings, _propertyProvider, repositoryRoot, projectPath)); } string msbuild16Log = String.Format("UseMSBuild16: {0}", VsHelper.UseMSBuild16().ToString()); tracer.Trace(msbuild16Log); KuduEventSource.Log.GenericEvent( ServerConfiguration.GetRuntimeSiteName(), msbuild16Log, string.Empty, string.Empty, string.Empty, string.Empty ); if (!String.IsNullOrEmpty(targetProjectPath)) { // Try to resolve the project return(ResolveProject(repositoryRoot, targetProjectPath, settings, fileFinder, tryWebSiteProject: true, searchOption: SearchOption.TopDirectoryOnly)); } // Get all solutions in the current repository path var solutions = VsHelper.GetSolutions(repositoryRoot, fileFinder).ToList(); if (!solutions.Any()) { return(ResolveProject(repositoryRoot, settings, fileFinder, searchOption: SearchOption.AllDirectories)); } // More than one solution is ambiguous if (solutions.Count > 1) { // TODO: Show relative paths in error messages ThrowAmbiguousSolutionsError(solutions); } // We have a solution VsSolution solution = solutions[0]; return(DetermineProjectFromSolution(logger, settings, repository, solution)); }
public ISiteBuilder CreateBuilder(ITracer tracer, ILogger logger, IDeploymentSettingsManager settings, IRepository repository, DeploymentInfoBase deploymentInfo) { string repositoryRoot = repository.RepositoryPath; // Use the cached vs projects file finder for: a. better performance, b. ignoring solutions/projects under node_modules var fileFinder = new CachedVsProjectsFileFinder(repository); // If there's a custom deployment file then let that take over. var command = settings.GetValue(SettingsKeys.Command); if (!String.IsNullOrEmpty(command)) { return(new CustomBuilder(_environment, settings, _propertyProvider, repositoryRoot, command)); } // If the user provided specific generator arguments, that overrides any detection logic string scriptGeneratorArgs = settings.GetValue(SettingsKeys.ScriptGeneratorArgs); if (!String.IsNullOrEmpty(scriptGeneratorArgs)) { return(new CustomGeneratorCommandSiteBuilder(_environment, settings, _propertyProvider, repositoryRoot, scriptGeneratorArgs)); } // If the repository has an explicit pointer to a project path to be deployed // then use it. string targetProjectPath = settings.GetValue(SettingsKeys.Project); if (!String.IsNullOrEmpty(targetProjectPath)) { tracer.Trace("Specific project was specified: " + targetProjectPath); targetProjectPath = Path.GetFullPath(Path.Combine(repositoryRoot, targetProjectPath.TrimStart('/', '\\'))); } if (deploymentInfo != null && deploymentInfo.Deployer == Constants.OneDeploy) { var projectPath = !String.IsNullOrEmpty(targetProjectPath) ? targetProjectPath : repositoryRoot; return(new OneDeployBuilder(_environment, settings, _propertyProvider, repositoryRoot, projectPath, deploymentInfo)); } if (settings.RunFromLocalZip()) { return(new RunFromZipSiteBuilder()); } if (!settings.DoBuildDuringDeployment()) { var projectPath = !String.IsNullOrEmpty(targetProjectPath) ? targetProjectPath : repositoryRoot; if (DeploymentHelper.IsDeploymentV2Request()) { return(new DeploymentV2Builder(_environment, settings, _propertyProvider, repositoryRoot)); } else { return(new BasicBuilder(_environment, settings, _propertyProvider, repositoryRoot, projectPath)); } } // Check if we really need a builder for this // If not, return the NoOpBuilder string appFramework = System.Environment.GetEnvironmentVariable("FRAMEWORK"); if (!string.IsNullOrEmpty(appFramework) && string.Equals(appFramework, "STATICSITE", StringComparison.OrdinalIgnoreCase)) { var projectPath = !String.IsNullOrEmpty(targetProjectPath) ? targetProjectPath : repositoryRoot; return(new NoOpBuilder(_environment, settings, _propertyProvider, repositoryRoot, projectPath)); } // If ENABLE_ORYX_BUILD is not set, for function app, we assume it on by default string enableOryxBuild = System.Environment.GetEnvironmentVariable("ENABLE_ORYX_BUILD"); if (!string.IsNullOrEmpty(enableOryxBuild)) { if (StringUtils.IsTrueLike(enableOryxBuild)) { return(new OryxBuilder(_environment, settings, _propertyProvider, repositoryRoot)); } } else if (FunctionAppHelper.LooksLikeFunctionApp()) { return(new OryxBuilder(_environment, settings, _propertyProvider, repositoryRoot)); } string framework = System.Environment.GetEnvironmentVariable("FRAMEWORK"); if (framework.Equals("ruby", StringComparison.OrdinalIgnoreCase)) { return(new RubySiteBuilder(_environment, settings, _propertyProvider, repositoryRoot, targetProjectPath)); } if (!String.IsNullOrEmpty(targetProjectPath)) { // Try to resolve the project return(ResolveProject(repositoryRoot, targetProjectPath, settings, fileFinder, tryWebSiteProject: true, searchOption: SearchOption.TopDirectoryOnly)); } // Get all solutions in the current repository path var solutions = VsHelper.GetSolutions(repositoryRoot, fileFinder).ToList(); if (!solutions.Any()) { return(ResolveProject(repositoryRoot, settings, fileFinder, searchOption: SearchOption.AllDirectories)); } // More than one solution is ambiguous if (solutions.Count > 1) { // TODO: Show relative paths in error messages ThrowAmbiguousSolutionsError(solutions); } // We have a solution VsSolution solution = solutions[0]; // We need to determine what project to deploy so get a list of all web projects and // figure out with some heuristic, which one to deploy. // TODO: Pick only 1 and throw if there's more than one // shunTODO need to implement this VsSolutionProject project = solution.Projects.Where(p => p.IsWap || p.IsWebSite || p.IsAspNetCore || p.IsFunctionApp).FirstOrDefault(); if (project == null) { // Try executable type project project = solution.Projects.Where(p => p.IsExecutable).FirstOrDefault(); if (project != null) { return(new DotNetConsoleBuilder(_environment, settings, _propertyProvider, repositoryRoot, project.AbsolutePath, solution.Path)); } logger.Log(Resources.Log_NoDeployableProjects, solution.Path); // we have a solution file, but no deployable project // shunTODO how often do we run into this return(ResolveNonAspProject(repositoryRoot, null, settings)); } if (project.IsWap) { return(new WapBuilder(_environment, settings, _propertyProvider, repositoryRoot, project.AbsolutePath, solution.Path)); } if (project.IsAspNetCore) { return(new AspNetCoreBuilder(_environment, settings, _propertyProvider, repositoryRoot, project.AbsolutePath, solution.Path)); } if (project.IsWebSite) { return(new WebSiteBuilder(_environment, settings, _propertyProvider, repositoryRoot, project.AbsolutePath, solution.Path)); } return(new FunctionMsbuildBuilder(_environment, settings, _propertyProvider, repositoryRoot, project.AbsolutePath, solution.Path)); }
public ISiteBuilder CreateBuilder(ITracer tracer, ILogger logger) { string repositoryRoot = _environment.RepositoryPath; var configuration = new DeploymentConfiguration(repositoryRoot); // If there's a custom deployment file then let that take over. if (!String.IsNullOrEmpty(configuration.Command)) { return(new CustomBuilder(repositoryRoot, _environment.TempPath, configuration.Command, _propertyProvider, _environment.SiteRootPath)); } // If the repository has an explicit pointer to a project path to be deployed // then use it. string targetProjectPath = configuration.ProjectPath; if (!String.IsNullOrEmpty(targetProjectPath)) { tracer.Trace("Found .deployment file in repository"); // Try to resolve the project return(ResolveProject(repositoryRoot, targetProjectPath, tryWebSiteProject: true, searchOption: SearchOption.TopDirectoryOnly)); } // Get all solutions in the current repository path var solutions = VsHelper.GetSolutions(repositoryRoot).ToList(); if (!solutions.Any()) { return(ResolveProject(repositoryRoot, searchOption: SearchOption.AllDirectories)); } // More than one solution is ambiguous if (solutions.Count > 1) { // TODO: Show relative paths in error messages ThrowAmbiguousSolutionsError(solutions); } // We have a solution VsSolution solution = solutions[0]; // We need to determine what project to deploy so get a list of all web projects and // figure out with some heuristic, which one to deploy. // TODO: Pick only 1 and throw if there's more than one VsSolutionProject project = solution.Projects.Where(p => p.IsWap || p.IsWebSite).FirstOrDefault(); if (project == null) { logger.Log(Resources.Log_NoDeployableProjects, solution.Path); return(new BasicBuilder(repositoryRoot, _environment.TempPath, _environment.ScriptPath, _environment.SiteRootPath)); } if (project.IsWap) { return(new WapBuilder(_settings, _propertyProvider, repositoryRoot, project.AbsolutePath, _environment.TempPath, _environment.NuGetCachePath, solution.Path)); } return(new WebSiteBuilder(_propertyProvider, repositoryRoot, project.AbsolutePath, _environment.TempPath, _environment.NuGetCachePath, solution.Path)); }