public HandlerResponse Process(string outputPath) { var di = new DirectoryInfo(outputPath); if (!di.Exists) { throw new DirectoryNotFoundException("Invalid output path!"); } var files = di.GetFiles(); var manifestPresent = files.Any(f => f.Extension == ".cltw"); var infoPresent = files.Any(f => f.Name == "app.info"); if (!(manifestPresent && infoPresent)) { return(new HandlerResponse(this, false, "This handler requires both a deployment manifest (cltw file) and an info file (app.info)! Try adding AppInfoHandler to your OutputHandlers and ensure you have set an InformationSource to generate a manifest.")); } Manifest = ManifestManager.ReadFromFile(GetManifest(outputPath).FullName); AppInfo = AppInfoManager.ReadFromFile(GetInfoFile(outputPath).FullName); Engine.Manifest = Manifest; Engine.AppInfo = AppInfo; var contentDirectory = Engine.CreateContentDirectory(new DirectoryInfo(outputPath)); contentDirectory.Copy(outputPath, copySubDirs: true); if (FileNameMap.Any()) { var outFiles = new DirectoryInfo(outputPath).GetFiles(); foreach (var file in FileNameMap) { var target = outFiles.FirstOrDefault(f => f.Name == file.Key); target?.Rename(file.Value); } } Engine.Dispose(); return(new HandlerResponse(this, true)); }
HandlerResponse IInputHandler.Process(string inputPath) { var files = new DirectoryInfo(inputPath).EnumerateFiles("app.info", SearchOption.AllDirectories).ToList(); var projects = new DirectoryInfo(inputPath).EnumerateFiles("*.csproj", SearchOption.TopDirectoryOnly); if (files.Any()) { AppInfo = AppInfoManager.ReadFromFile(files.First().FullName); Manager = new AppInfoManager(AppInfo); } else { Manager = new AppInfoManager(projects.FirstOrDefault()?.FullName); } if (Configuration != null && Manager != null) { Configuration.Invoke(Manager); } return(new HandlerResponse(this, true)); }
public static AppInfoManager AppInfo(this ICakeContext ctx, FilePath projectFile) { if (ctx == null) { throw new ArgumentNullException(nameof(ctx)); } if (projectFile == null) { throw new ArgumentNullException(nameof(projectFile)); } if (ctx.Environment.IsUnix()) { throw new PlatformNotSupportedException("ClickTwice is currently only supported on the Windows platform"); } var infoPath = projectFile.GetDirectory().GetFilePath("app.info"); return(ctx.FileSystem.Exist(infoPath) ? new AppInfoManager(AppInfoManager.ReadFromFile(infoPath.MakeAbsolute(ctx.Environment).FullPath)) : new AppInfoManager(projectFile.MakeAbsolute(ctx.Environment).FullPath)); }