public static async Task Deploy(this IWebApp site, WebAppDeploymentKind kind, DirectoryInfo from, TestCommand dotnet, ILogger logger)
        {
            switch (kind)
            {
            case WebAppDeploymentKind.Git:
                await site.GitDeploy(from, logger);

                break;

            case WebAppDeploymentKind.WebDeploy:
                await site.BuildPublishProfileAsync(from.FullName);

                await dotnet.ExecuteAndAssertAsync("publish /p:PublishProfile=Profile");

                break;

            case WebAppDeploymentKind.Ftp:
                var publishDirectory = from.CreateSubdirectory("publish");
                await dotnet.ExecuteAndAssertAsync("restore");

                await dotnet.ExecuteAndAssertAsync("publish -o " + publishDirectory.FullName);

                await site.UploadFilesAsync(publishDirectory, "/", await site.GetPublishingProfileAsync(), logger);

                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(kind), kind, null);
            }
        }
        public static async Task GitDeploy(this IWebApp site, DirectoryInfo workingDirectory, ILogger logger)
        {
            // Allow site to restart after site extension installation
            await Task.Delay(GitDeployDelay);

            var git = new TestCommand("git")
            {
                Logger           = logger,
                WorkingDirectory = workingDirectory.FullName
            };

            var publishingProfile = await site.GetPublishingProfileAsync();

            await git.ExecuteAndAssertAsync("init");

            await git.ExecuteAndAssertAsync($"remote add origin https://{publishingProfile.GitUsername}:{publishingProfile.GitPassword}@{publishingProfile.GitUrl}");

            await git.ExecuteAndAssertAsync("add .");

            await git.ExecuteAndAssertAsync("commit -am Initial");

            var result = await git.ExecuteAndAssertAsync("push origin master");

            Assert.DoesNotContain("An error has occurred during web site deployment", result.StdErr);
            Assert.DoesNotContain("deployment to website failed", result.StdErr);
        }
示例#3
0
    protected async Task <IPublishingProfile> GetTargetPublishingProfileAsync(IWebApp app)
    {
        var targetSlot = await FindTargetSlotAndCleanOldSlotsAsync(app);

        if (targetSlot != null)
        {
            Console.WriteLine($"Retrieving publishing profile of slot {targetSlot.Name}.");
            return(await targetSlot.GetPublishingProfileAsync());
        }

        Console.WriteLine($"Retrieving publishing profile of slot production.");
        return(await app.GetPublishingProfileAsync());
    }