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);
            }
        }
        private string DoConfigure(string packagePath, Environment env, string outputPath)
        {
            _logger.InfoFormat("Configuring package {0} for {1}", new FileInfo(packagePath).Name, env.Name.ToUpper());
            var workingDir = _fileSystem.CreateTempWorkingDir();

            _logger.DebugFormat("Create temp work dir {0}", workingDir);

            // read nupkg metadata
            var nupkg = new ZipPackage(packagePath);
            _logger.DebugFormat("Unzipping {0} to {1}", nupkg.GetFullName(), workingDir);

            using (var zip = new ZipFile(packagePath))
            {
                zip.ExtractAll(workingDir);
            }

            _templateEngine.TransformDirectory(workingDir, env);
            var packageName = nupkg.Id + "_v" + nupkg.Version + "_" + env.Name.ToUpper(CultureInfo.InvariantCulture) + ".nupkg";
            var packageOutputPath = Path.Combine(outputPath, packageName);

            _fileSystem.DeleteFile(packageOutputPath);

            using (var zip = new ZipFile(packageOutputPath))
            {
                zip.AddDirectory(workingDir);
                zip.Save();
            }

            _fileSystem.DeleteDirectory(workingDir);

            return packageOutputPath;
        }
        public void Serialize_Environment_Test()
        {
            var target = new Environment();

            target.Name        = "Local";
            target.Description = "Used for unit tests, not a real environment";

            target.Variables = new List <Variable>();
            target.Variables.Add(new Variable()
            {
                Name = "Name", Value = "Tobi"
            });
            target.Variables.Add(new Variable()
            {
                Name = "Jack", Value = "Bauer"
            });

            var xml = new StringWriter();

            var serializer = new XmlSerializer(typeof(Environment));

            serializer.Serialize(xml, target);

            Console.WriteLine(xml);
        }
        public void Serialize_Environment_Test()
        {
            var target = new Environment();
            target.Name = "Local";
            target.Description = "Used for unit tests, not a real environment";

            target.Variables = new List<Variable>();
            target.Variables.Add(new Variable() { Name = "Name", Value = "Tobi" });
            target.Variables.Add(new Variable() { Name = "Jack", Value = "Bauer" });

            var xml = new StringWriter();

            var serializer = new XmlSerializer(typeof(Environment));
            serializer.Serialize(xml, target);

            Console.WriteLine(xml);
        }