private IPackage FindPackage(out string path)
        {
            path = null;
            var dir = CommonHelper.MapPath(UpdatePackagePath, false);

            if (!Directory.Exists(dir))
                return null;

            var files = Directory.GetFiles(dir, "SmartStore.*.nupkg", SearchOption.TopDirectoryOnly);

            // TODO: allow more than one package in folder and return newest
            if (files == null || files.Length == 0 || files.Length > 1)
                return null;

            IPackage package = null;

            try
            {
                path = files[0];
                package = new ZipPackage(files[0]);
                _logger = CreateLogger(package);
                _logger.Information("Found update package '{0}'".FormatInvariant(package.GetFullName()));
                return package;
            }
            catch { }

            return null;
        }
        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;
        }