protected override void ProcessRecord() { LogManager.LogFactory = new PowerShellCommandLineLogFactory(); Log = LogManager.GetLogger(typeof(InvokeDirectoryTransform)); try { // TODO: make that nice, i'm in hurry right know :) EnvironmentProvider envProvider = null; envProvider = string.IsNullOrEmpty(Environment) ? new EnvironmentProvider() : new EnvironmentProvider(Directory); var templateEngine = new TemplateEngine(); Environment env = !string.IsNullOrEmpty(Environment) ? envProvider.GetEnvironment(Environment) : envProvider.GetEnvironmentFromFile(EnvironmentFile); this.LoadAesKey(); if (string.IsNullOrEmpty(this.aesKey) == false) { env.DecryptVariables(this.aesKey); } templateEngine.TransformDirectory(Directory, env, false); } catch (DirectoryNotFoundException) { Log.Warn(".powerdeploy folder not found for " + Directory + "!"); } catch (FileNotFoundException exception) { Log.Error(exception.Message); } }
public override bool Execute() { LogManager.LogFactory = new BuildLogFactory(Log); Log.LogCommandLine("Transform all project files within the current solution..."); try { var envProvider = new EnvironmentProvider(Directory); var templateEngine = new TemplateEngine(); templateEngine.TransformDirectory(Directory, envProvider.GetEnvironment(Environment)); } catch (DirectoryNotFoundException) { Log.LogError(".powerdeploy folder not found for project " + Directory + "! :("); return(false); } catch (FileNotFoundException exception) { Log.LogError(exception.Message); return(false); } return(true); }
public void Find_Environment_With_Dir_Not_Existing() { using (var workDir = new TestFolder(Environment.SpecialFolder.LocalApplicationData)) { workDir.AddFolder("dir1"); workDir.AddFolder("dir1/subdir1"); var target = new EnvironmentProvider(Path.Combine(workDir.DirectoryInfo.FullName, "dir1/subdir1")); target.GetEnvironment("unittest"); } }
public void Find_Environment() { var target = new EnvironmentProvider(); target.Initialize(@"samples\PowerDeploy.Sample.XCopy".MapVcsRoot()); var result = target.GetEnvironment("unittest"); Assert.IsNotNull(result); Assert.AreEqual("unittest", result.Name); Assert.AreEqual("Jack", result["Firstname"].Value); Assert.AreEqual("Bauer", result["Lastname"].Value); }
public void Find_Environment_In_Same_Dir() { var xml = @"<?xml version=""1.0""?> <environment name=""local"" description=""Used for unit tests, not a real environment""> <variable name=""Name"" value=""Tobi"" /> <variable name=""Jack"" value=""Bauer"" /> </environment>"; using (var workDir = new TestFolder(Environment.SpecialFolder.LocalApplicationData)) { workDir.AddFolder("dir1"); workDir.AddFolder("dir1/subdir1"); workDir.AddFolder(".powerdeploy"); workDir.AddFile(".powerdeploy/unittest.xml", xml); var target = new EnvironmentProvider(workDir.DirectoryInfo.FullName); var result = target.GetEnvironment("unittest"); Assert.AreEqual("local", result.Name); Assert.AreEqual("Tobi", result["Name"].Value); Assert.AreEqual("Bauer", result["Jack"].Value); } }