コード例 #1
0
        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);
            }
        }
コード例 #2
0
        private void ValidateLegacyRuntimeInfo(WebAppDeploymentKind deploymentKind, RuntimeInfo runtimeInfo, string templateVersion)
        {
            var cacheAssemblies   = new HashSet <string>(File.ReadAllLines(Asset($"DotNetCache.{deploymentKind}.{templateVersion}.txt")), StringComparer.InvariantCultureIgnoreCase);
            var modulesNotInCache = new List <string>();

            foreach (var runtimeInfoModule in runtimeInfo.Modules)
            {
                // Skip native
                if (runtimeInfoModule.Version == null)
                {
                    continue;
                }


                // Check if assembly that is in the cache is loaded from it
                var moduleName = Path.GetFileNameWithoutExtension(runtimeInfoModule.ModuleName);
                if (cacheAssemblies.Contains(moduleName))
                {
                    if (runtimeInfoModule.FileName.IndexOf("\\DotNetCache\\x86\\", StringComparison.CurrentCultureIgnoreCase) == -1)
                    {
                        modulesNotInCache.Add(moduleName);
                    }
                    continue;
                }
            }

            Assert.Empty(modulesNotInCache);
        }
コード例 #3
0
        public async Task TemplateRuns(WebAppDeploymentKind deploymentKind, string dotnetVersion, string template, string expected)
        {
            var testId = ToFriendlyName(nameof(TemplateRuns), deploymentKind, template, dotnetVersion);

            var siteTask = _fixture.Deploy(AppServicesWithSiteExtensionsTemplate, GetSiteExtensionArguments(), testId);

            var testDirectory = GetTestDirectory(testId);
            var dotnet        = DotNet(_logger, testDirectory, dotnetVersion);

            await dotnet.ExecuteAndAssertAsync($"--info");

            await dotnet.ExecuteAndAssertAsync("new " + template);

            InjectMiddlware(testDirectory, RuntimeInformationMiddlewareType, RuntimeInformationMiddlewareFile);
            FixAspNetCoreVersion(testDirectory, dotnet.Command);

            var site = await siteTask;

            // There is no feed with packages included in lastes so we have to enable first run experience
            if (deploymentKind == WebAppDeploymentKind.Git && dotnetVersion == "latest")
            {
                await site.Update().WithAppSetting("DOTNET_SKIP_FIRST_TIME_EXPERIENCE", "false").ApplyAsync();
            }

            await site.Deploy(deploymentKind, testDirectory, dotnet, _logger);

            using (var httpClient = site.CreateClient())
            {
                var getResult = await httpClient.GetAsync("/");

                getResult.EnsureSuccessStatusCode();
                Assert.Contains(expected, await getResult.Content.ReadAsStringAsync());

                getResult = await httpClient.GetAsync("/runtimeInfo");

                getResult.EnsureSuccessStatusCode();

                var runtimeInfoJson = await getResult.Content.ReadAsStringAsync();

                _logger.LogTrace("Runtime info: {Info}", runtimeInfoJson);

                var runtimeInfo = JsonConvert.DeserializeObject <RuntimeInfo>(runtimeInfoJson);
                ValidateStoreRuntimeInfo(runtimeInfo, dotnet.Command);
            }
        }
コード例 #4
0
        public async Task LegacyTemplateRuns(WebAppDeploymentKind deploymentKind, string templateVersion, string expectedRuntime, string template, string expected)
        {
            var testId = ToFriendlyName(nameof(LegacyTemplateRuns), deploymentKind, template, templateVersion);

            var siteTask = _fixture.Deploy(AppServicesWithSiteExtensionsTemplate, GetSiteExtensionArguments(), testId);

            var testDirectory = GetTestDirectory(testId);

            // we are going to deploy with 2.0 dotnet to enable WebDeploy
            var dotnet20 = DotNet(_logger, testDirectory, "2.0");

            CopyFilesToProjectDirectory(testDirectory, Asset($"AspNetCore1x{template}"));
            CopyToProjectDirectory(testDirectory, Asset($"NuGet.{templateVersion}.config"), "NuGet.config", false);
            CopyToProjectDirectory(testDirectory, Asset($"Legacy.{templateVersion}.{template}.csproj"));
            InjectMiddlware(testDirectory, RuntimeInformationMiddlewareType, RuntimeInformationMiddlewareFile);

            await dotnet20.ExecuteAndAssertAsync("restore");

            var site = await siteTask;
            await site.Deploy(deploymentKind, testDirectory, dotnet20, _logger);

            using (var httpClient = site.CreateClient())
            {
                var getResult = await httpClient.GetAsync("/");

                getResult.EnsureSuccessStatusCode();
                Assert.Contains(expected, await getResult.Content.ReadAsStringAsync());

                getResult = await httpClient.GetAsync("/runtimeInfo");

                getResult.EnsureSuccessStatusCode();

                var runtimeInfoJson = await getResult.Content.ReadAsStringAsync();

                _logger.LogTrace("Runtime info: {Info}", runtimeInfoJson);

                var runtimeInfo = JsonConvert.DeserializeObject <RuntimeInfo>(runtimeInfoJson);
                ValidateLegacyRuntimeInfo(deploymentKind, runtimeInfo, templateVersion);
            }
        }