public async Task <string> RebuildSite(int staticSiteId)
        {
            var stopwatch = new Stopwatch();

            stopwatch.Start();

            var entity = _sitesRepo.Get(staticSiteId);

            if (entity == null)
            {
                throw new HttpException(404, "Site not found with id " + staticSiteId);
            }

            using (var umbracoContext = _umbracoContextFactory.EnsureUmbracoContext())
            {
                IFileNameGenerator fileNamer = entity.ExportFormat == "api" ? (IFileNameGenerator) new JsonFileNameGenerator() : new EverythingIsIndexHtmlFileNameGenerator();

                int rootNodeId = int.Parse(entity.RootNode);
                var rootNode   = umbracoContext.UmbracoContext.Content.GetById(rootNodeId);

                var builder = new JobBuilder(entity.Id, fileNamer)
                              .AddPageWithDescendants(rootNode);

                AddMediaToBuilder(entity, umbracoContext, builder);
                AddMediaCropsToBuilder(entity, builder);

                AddAssetsToBuilder(entity, builder);

                var listFactory  = _exportTypeSettings.GetTransformerListFactory(entity.ExportFormat);
                var transformers = listFactory.BuildTransformers(entity);

                if (transformers.Any())
                {
                    builder.AddTransformers(transformers);
                }

                var results = await GetResults(entity, builder);

                stopwatch.Stop();

                _sitesRepo.UpdateLastRun(staticSiteId, (int)(stopwatch.ElapsedMilliseconds / 1000));

                return(string.Join(Environment.NewLine, results));
            }
        }