public void VerifyTargetingPacks(ImageDescriptor imageDescriptor)
        {
            Version[] allFrameworkVersions = new Version[]
            {
                new Version("4.0"),
                new Version("4.5"),
                new Version("4.5.1"),
                new Version("4.5.2"),
                new Version("4.6"),
                new Version("4.6.1"),
                new Version("4.6.2"),
                new Version("4.7"),
                new Version("4.7.1"),
                new Version("4.7.2"),
                new Version("4.8")
            };

            string baseBuildImage = ImageTestHelper.GetImage("sdk", imageDescriptor.Version, imageDescriptor.OsVariant);
            string appId = $"targetingpacks-{DateTime.Now.ToFileTime()}";
            string command = @"cmd /c dir /B ""C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework""";
            string output = ImageTestHelper.DockerHelper.Run(image: baseBuildImage, name: appId, command: command);

            IEnumerable<Version> actualVersions = output.Split(Environment.NewLine)
                .Select(name => new Version(name.Substring(1))); // Trim the first character (v4.0 => 4.0)

            Version buildVersion = new Version(imageDescriptor.Version);

            IEnumerable<Version> expectedVersions = allFrameworkVersions;
            if (imageDescriptor.Version != "3.5")
            {
                expectedVersions = allFrameworkVersions.Where(version => version <= buildVersion);
            }

            Assert.Equal(expectedVersions, actualVersions);
        }
Exemplo n.º 2
0
        public static void Validate(
            IEnumerable <EnvironmentVariableInfo> variables,
            string imageType,
            ImageDescriptor imageDescriptor,
            ImageTestHelper imageTestHelper)
        {
            const char           delimiter = '|';
            IEnumerable <string> echoParts;
            string invokeCommand;
            char   delimiterEscape;

            if (DockerHelper.IsLinuxContainerModeEnabled)
            {
                echoParts       = variables.Select(envVar => $"${envVar.Name}");
                invokeCommand   = $"/bin/sh -c";
                delimiterEscape = '\\';
            }
            else
            {
                echoParts       = variables.Select(envVar => $"%{envVar.Name}%");
                invokeCommand   = $"CMD /S /C";
                delimiterEscape = '^';
            }

            string appId = $"envvar-{DateTime.Now.ToFileTime()}";

            string combinedValues = imageTestHelper.DockerHelper.Run(
                image: imageTestHelper.GetImage(imageType, imageDescriptor.Version, imageDescriptor.OsVariant),
                name: appId,
                command: $"{invokeCommand} \"echo {String.Join($"{delimiterEscape}{delimiter}", echoParts)}\"");

            string[] values = combinedValues.Split(delimiter);
            Assert.Equal(variables.Count(), values.Count());

            for (int i = 0; i < values.Count(); i++)
            {
                EnvironmentVariableInfo variable = variables.ElementAt(i);

                string actualValue;
                // Process unset variables in Windows
                if (!DockerHelper.IsLinuxContainerModeEnabled &&
                    string.Equals(values[i], $"%{variable.Name}%", StringComparison.Ordinal))
                {
                    actualValue = string.Empty;
                }
                else
                {
                    actualValue = values[i];
                }

                if (variable.AllowAnyValue)
                {
                    Assert.NotEmpty(actualValue);
                }
                else
                {
                    Assert.Equal(variable.ExpectedValue, actualValue);
                }
            }
        }
        public void VerifyNuGetCli(ImageDescriptor imageDescriptor)
        {
            string baseBuildImage = ImageTestHelper.GetImage("sdk", imageDescriptor.Version, imageDescriptor.OsVariant);
            string appId          = $"nuget-{DateTime.Now.ToFileTime()}";
            string command        = "nuget help";
            string output         = ImageTestHelper.DockerHelper.Run(image: baseBuildImage, name: appId, command: command);

            Assert.StartsWith("NuGet Version:", output);
        }
        public void VerifyGacUtil(ImageDescriptor imageDescriptor)
        {
            string baseBuildImage = ImageTestHelper.GetImage("sdk", imageDescriptor.Version, imageDescriptor.OsVariant);
            string appId          = $"gacutil-{DateTime.Now.ToFileTime()}";
            string command        = "gacutil";
            string output         = ImageTestHelper.DockerHelper.Run(image: baseBuildImage, name: appId, command: command);

            Assert.StartsWith("Microsoft (R) .NET Global Assembly Cache Utility", output);
        }
        public void VerifyVsTest(ImageDescriptor imageDescriptor)
        {
            string baseBuildImage = ImageTestHelper.GetImage("sdk", imageDescriptor.Version, imageDescriptor.OsVariant);
            string appId          = $"vstest-{DateTime.Now.ToFileTime()}";
            string command        = "vstest.console.exe /?";
            string output         = ImageTestHelper.DockerHelper.Run(image: baseBuildImage, name: appId, command: command);

            Assert.StartsWith("Microsoft (R) Test Execution Command Line Tool", output);
        }
        public void VerifyDotNetCli(ImageDescriptor imageDescriptor)
        {
            string baseBuildImage = ImageTestHelper.GetImage("sdk", imageDescriptor.Version, imageDescriptor.OsVariant);
            string appId          = $"dotnetcli-{DateTime.Now.ToFileTime()}";
            string command        = "dotnet --version";
            string output         = ImageTestHelper.DockerHelper.Run(image: baseBuildImage, name: appId, command: command);

            // Just verify the output is parseable to a Version object (it will throw if it's not)
            Version.Parse(output);
        }
Exemplo n.º 7
0
        public void VerifyWebDeploy(ImageDescriptor imageDescriptor)
        {
            string baseBuildImage = ImageTestHelper.GetImage("sdk", imageDescriptor.Version, imageDescriptor.OsVariant);
            string appId          = $"webdeploy-{DateTime.Now.ToFileTime()}";

            // Calling msdeploy's help command results in a -1 exit code. To prevent that from bubbling up and causing the
            // docker run call to fail, the call is batched with an echo command that will always run even if msdeploy
            // returns a non-zero exit code. This batch needs to be wrapped in space-separated quotes to work properly.
            string command = @"cmd /S /C "" ""C:\Program Files\IIS\Microsoft Web Deploy V3\msdeploy.exe"" -help & echo > nul """;
            string output  = ImageTestHelper.DockerHelper.Run(image: baseBuildImage, name: appId, command: command);

            Assert.StartsWith("Microsoft (R) Web Deployment Command Line Tool (MSDeploy.exe)", output);
        }
        public void VerifyImagesWithApps(ImageDescriptor imageDescriptor)
        {
            List <string> appBuildArgs = new List <string> {
            };

            string baseWCFImage = ImageTestHelper.GetImage("wcf", imageDescriptor.Version, imageDescriptor.OsVariant);

            appBuildArgs.Add($"BASE_WCF_IMAGE={baseWCFImage}");

            ImageTestHelper.BuildAndTestImage(
                imageDescriptor: imageDescriptor,
                buildArgs: appBuildArgs,
                appDescriptor: "wcf",
                runCommand: "",
                testUrl: "/Service1.svc"
                );
        }
        public void VerifyImagesWithApps(ImageDescriptor imageDescriptor)
        {
            List <string> appBuildArgs = new List <string> {
            };

            string baseAspnetImage = ImageTestHelper.GetImage("aspnet", imageDescriptor.Version, imageDescriptor.OsVariant);

            appBuildArgs.Add($"BASE_ASPNET_IMAGE={baseAspnetImage}");

            ImageTestHelper.BuildAndTestImage(
                imageDescriptor: imageDescriptor,
                buildArgs: appBuildArgs,
                appDescriptor: "aspnet",
                runCommand: "",
                testUrl: "/hello-world.aspx"
                );
        }
Exemplo n.º 10
0
        public void VerifyVsWhereOperability(ImageDescriptor imageDescriptor)
        {
            string       baseBuildImage = ImageTestHelper.GetImage("sdk", imageDescriptor.Version, imageDescriptor.OsVariant);
            string       appId          = $"vswhere-{DateTime.Now.ToFileTime()}";
            const string command        = @"cmd /c ""C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe"" -products * -latest -format json";
            string       output         = ImageTestHelper.DockerHelper.Run(image: baseBuildImage, name: appId, command: command);

            JArray json = (JArray)JsonConvert.DeserializeObject(output);

            Assert.Single(json);
            Assert.Equal(@"C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools", json[0]["installationPath"]);

            Version actualVsVersion = Version.Parse(json[0]["catalog"]["productDisplayVersion"].ToString());

            Version expectedVsVersion = Config.GetManifestVsVersion();

            Assert.Equal(expectedVsVersion.Major, actualVsVersion.Major);
            Assert.Equal(expectedVsVersion.Minor, actualVsVersion.Minor);
        }
Exemplo n.º 11
0
        public void VerifyClickOncePublishing(ImageDescriptor imageDescriptor)
        {
            string        baseBuildImage = ImageTestHelper.GetImage("sdk", imageDescriptor.Version, imageDescriptor.OsVariant);
            List <string> buildArgs      = new List <string>
            {
                $"BASE_BUILD_IMAGE={baseBuildImage}",
            };

            string command = $"cmd /s /c dir /b publish";
            string output  = ImageTestHelper.BuildAndTestImage(imageDescriptor, buildArgs, "clickonce", command, null);

            string[] outputLines = output.Split(Environment.NewLine);

            Assert.Equal(4, outputLines.Length);
            Assert.Equal("Application Files", outputLines[0]);
            Assert.Equal($"clickonce-{imageDescriptor.Version}.application", outputLines[1]);
            Assert.Equal($"clickonce-{imageDescriptor.Version}.exe", outputLines[2]);
            Assert.Equal($"setup.exe", outputLines[3]);
        }
Exemplo n.º 12
0
        public void VerifyVsWhereOperability(ImageDescriptor imageDescriptor)
        {
            string       baseBuildImage      = ImageTestHelper.GetImage("sdk", imageDescriptor.Version, imageDescriptor.OsVariant);
            string       appId               = $"vswhere-{DateTime.Now.ToFileTime()}";
            const string securityProtocolCmd = "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12";
            const string vsWhereUrl          = "https://github.com/Microsoft/vswhere/releases/download/2.8.4/vswhere.exe";
            string       downloadVsWhereCmd  = $"Invoke-WebRequest -UseBasicParsing {vsWhereUrl} -OutFile vswhere.exe";
            const string executeVsWhereCmd   = @".\vswhere.exe -products * -latest -format json";
            string       command             = $@"powershell {securityProtocolCmd}; {downloadVsWhereCmd}; {executeVsWhereCmd}";
            string       output              = ImageTestHelper.DockerHelper.Run(image: baseBuildImage, name: appId, command: command);

            JArray json = (JArray)JsonConvert.DeserializeObject(output);

            Assert.Single(json);
            Assert.Equal(@"C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools", json[0]["installationPath"]);

            Version actualVsVersion = Version.Parse(json[0]["catalog"]["productDisplayVersion"].ToString());

            VsInfo  vsInfo            = Config.GetVsInfo();
            Version expectedVsVersion = Version.Parse(vsInfo.VsVersion);

            Assert.Equal(expectedVsVersion.Major, actualVsVersion.Major);
            Assert.Equal(expectedVsVersion.Minor, actualVsVersion.Minor);
        }
Exemplo n.º 13
0
 public RuntimeSdkImageTests(ITestOutputHelper outputHelper)
 {
     _imageTestHelper = new ImageTestHelper(outputHelper);
 }
Exemplo n.º 14
0
 public AspnetImageTests(ITestOutputHelper outputHelper)
 {
     imageTestHelper = new ImageTestHelper(outputHelper);
 }
 protected ImageTests(ITestOutputHelper outputHelper)
 {
     ImageTestHelper = new ImageTestHelper(outputHelper);
 }
Exemplo n.º 16
0
 public SdkOnlyImageTests(ITestOutputHelper outputHelper)
 {
     imageTestHelper = new ImageTestHelper(outputHelper);
 }
 public WcfImageTests(ITestOutputHelper outputHelper)
 {
     imageTestHelper = new ImageTestHelper(outputHelper);
 }
 public static IEnumerable <object[]> GetImageData()
 {
     return(ImageTestHelper.ApplyImageDataFilters(ImageData));
 }
 public RuntimeOnlyImageTests(ITestOutputHelper outputHelper)
 {
     imageTestHelper = new ImageTestHelper(outputHelper);
 }