Ejemplo n.º 1
0
        public void WhenNullIsPassedForVersionParameterThenMsBuildVersionIsFetchedFromPath_Success()
        {
            //Arrange
            var msbuildPath = Util.GetMsbuildPathOnWindows();

            //Act
            var toolset = new MsBuildToolset(version: null, path: msbuildPath);

            //Assert
            Assert.Equal(msbuildPath, toolset.Path);
            Assert.True(toolset.ParsedVersion.CompareTo(new Version()) > 0);
        }
Ejemplo n.º 2
0
        public void TestMsBuildPathFromVsPathWithNonEnglishCulture()
        {
            CultureInfo startingCulture = Thread.CurrentThread.CurrentCulture;

            // Change culture to Ukrainian (any culture with comma and period swapped compared to english in floating point)
            Thread.CurrentThread.CurrentCulture
                = CultureInfo.GetCultureInfo("uk-UA");

            using (var vsPath = TestDirectory.Create())
            {
                // Arrange
                // Create this tree:
                // VS
                // |- MSBuild
                //    |- 15.0
                //    |  |- bin
                //    |     |- msbuild.exe
                //    |- 15.1
                //       |- bin
                //          |- msbuild.exe
                // We want the highest version within the VS tree chosen (typically there's only one, but that's the logic
                // we'll go with in case there are more).
                var msBuild15BinPath  = Directory.CreateDirectory(Path.Combine(vsPath, "MSBuild", "15.0", "Bin")).FullName;
                var msBuild151BinPath = Directory.CreateDirectory(Path.Combine(vsPath, "MSBuild", "15.1", "Bin")).FullName;

                // Create dummy msbuild.exe files
                var msBuild15ExePath = Path.Combine(msBuild15BinPath, "msbuild.exe").ToString();
                File.WriteAllText(msBuild15ExePath, "foo 15");

                var msBuild151ExePath = Path.Combine(msBuild151BinPath, "msbuild.exe").ToString();
                File.WriteAllText(msBuild151ExePath, "foo 15.1");

                // Act
                var msBuildExePath = MsBuildToolset.GetMsBuildDirFromVsDir(vsPath);

                // Assert
                Assert.Equal(msBuildExePath, msBuild151BinPath, ignoreCase: true);
            }

            // reset culture
            Thread.CurrentThread.CurrentCulture = startingCulture;
        }
Ejemplo n.º 3
0
        public void TestMsBuildPathFromVsPath()
        {
            using (var vsPath = TestDirectory.Create())
            {
                // Arrange
                // Create this tree:
                // VS
                // |- MSBuild
                //    |- 15.0
                //    |  |- bin
                //    |     |- msbuild.exe
                //    |- 15.1
                //       |- bin
                //          |- msbuild.exe
                // We want the highest version within the VS tree chosen (typically there's only one, but that's the logic
                // we'll go with in case there are more).
                var msBuild15BinPath  = Directory.CreateDirectory(Path.Combine(vsPath, "MSBuild", "15.0", "Bin")).FullName;
                var msBuild151BinPath = Directory.CreateDirectory(Path.Combine(vsPath, "MSBuild", "15.1", "Bin")).FullName;

                // Create dummy msbuild.exe files
                var msBuild15ExePath = Path.Combine(msBuild15BinPath, "msbuild.exe").ToString();
                using (var fs15 = File.CreateText(msBuild15ExePath))
                {
                    fs15.Write("foo 15");
                }

                var msBuild151ExePath = Path.Combine(msBuild151BinPath, "msbuild.exe").ToString();
                using (var fs151 = File.CreateText(msBuild151ExePath))
                {
                    fs151.Write("foo 15.1");
                }

                // Act
                var msBuildExePath = MsBuildToolset.GetMsBuildDirFromVsDir(vsPath);

                // Assert
                Assert.Equal(msBuildExePath, msBuild151BinPath, ignoreCase: true);
            }
        }