private async Task GenerateAsync(SpriteDocument sprite, bool hasUpdated = false)
        {
            _dte.StatusBar.Text = "Generating sprite...";

            ProjectHelpers.AddFileToProject(Path.GetDirectoryName(sprite.FileName), sprite.FileName);

            string imageFile = Path.ChangeExtension(sprite.FileName, sprite.FileExtension);

            if (string.IsNullOrEmpty(sprite.OutputDirectory))
            {
                imageFile = ProjectHelpers.GetAbsolutePathFromSettings(sprite.OutputDirectory, Path.ChangeExtension(sprite.FileName, sprite.FileExtension));
            }

            ProjectHelpers.CreateDirectoryInProject(imageFile);

            IEnumerable <SpriteFragment> fragments = await SpriteGenerator.MakeImage(sprite, imageFile, UpdateSpriteAsync);

            ProjectHelpers.AddFileToProject(sprite.FileName, imageFile);

            if (!hasUpdated)
            {
                WebEssentialsPackage.DTE.ItemOperations.OpenFile(sprite.FileName);
            }

            await Export(fragments, imageFile, sprite);

            if (sprite.Optimize)
            {
                await new ImageCompressor().CompressFilesAsync(imageFile);
            }

            _dte.StatusBar.Text = "Sprite generated";
        }