public void TestGeneralFrameworkMonikerNonExistentOverrideError()
        {
            MockEngine engine = new MockEngine();
            GetReferenceAssemblyPaths getReferencePaths = new GetReferenceAssemblyPaths();

            getReferencePaths.BuildEngine = engine;
            // Make a framework which does not exist, intentional misspelling of framework
            getReferencePaths.TargetFrameworkMoniker = ".NetFramewok, Version=v99.0";

            try
            {
                Environment.SetEnvironmentVariable("MSBUILDWARNONNOREFERENCEASSEMBLYDIRECTORY", "1");
                bool success = getReferencePaths.Execute();
                Assert.True(success);
            }
            finally
            {
                Environment.SetEnvironmentVariable("MSBUILDWARNONNOREFERENCEASSEMBLYDIRECTORY", null);
            }

            string[] returnedPaths = getReferencePaths.ReferenceAssemblyPaths;
            Assert.Equal(0, returnedPaths.Length);
            string displayName = getReferencePaths.TargetFrameworkMonikerDisplayName;

            Assert.Null(displayName);
            FrameworkNameVersioning frameworkMoniker = new FrameworkNameVersioning(getReferencePaths.TargetFrameworkMoniker);
            string message = ResourceUtilities.FormatResourceString("GetReferenceAssemblyPaths.NoReferenceAssemblyDirectoryFound", frameworkMoniker.ToString());

            engine.AssertLogContains("WARNING MSB3644: " + message);
        }
예제 #2
0
        public void TestGeneralFrameworkMonikerGoodWithFrameworkInFallbackPaths()
        {
            using (var env = TestEnvironment.Create())
            {
                string frameworkRootDir     = Path.Combine(env.DefaultTestDirectory.Path, "framework-root");
                var    framework41Directory = env.CreateFolder(Path.Combine(frameworkRootDir, Path.Combine("MyFramework", "v4.1") + Path.DirectorySeparatorChar));
                var    redistListDirectory  = env.CreateFolder(Path.Combine(framework41Directory.Path, "RedistList"));

                string redistListContents =
                    "<FileList Redist='Microsoft-Windows-CLRCoreComp' Name='.NET Framework 4.1'>" +
                    "<File AssemblyName='System.Xml' Version='2.0.0.0' PublicKeyToken='b03f5f7f11d50a3a' Culture='Neutral' FileVersion='2.0.50727.208' InGAC='true' />" +
                    "<File AssemblyName='Microsoft.Build.Engine' Version='2.0.0.0' PublicKeyToken='b03f5f7f11d50a3a' Culture='Neutral' FileVersion='2.0.50727.208' InGAC='true' />" +
                    "</FileList >";

                env.CreateFile(redistListDirectory, "FrameworkList.xml", redistListContents);

                string     targetFrameworkMoniker = "MyFramework, Version=v4.1";
                MockEngine engine = new MockEngine();
                GetReferenceAssemblyPaths getReferencePaths = new GetReferenceAssemblyPaths();
                getReferencePaths.BuildEngine            = engine;
                getReferencePaths.TargetFrameworkMoniker = targetFrameworkMoniker;
                getReferencePaths.RootPath = env.CreateFolder().Path;
                getReferencePaths.RootPath = frameworkRootDir;
                getReferencePaths.TargetFrameworkFallbackSearchPaths = $"/foo/bar;{frameworkRootDir}";
                getReferencePaths.Execute();
                string[] returnedPaths = getReferencePaths.ReferenceAssemblyPaths;
                string   displayName   = getReferencePaths.TargetFrameworkMonikerDisplayName;
                Assert.Single(returnedPaths);
                Assert.Equal(framework41Directory.Path, returnedPaths[0]);
                Assert.Equal(0, engine.Log.Length); // "Expected the log to contain nothing"
                Assert.Equal(".NET Framework 4.1", displayName);
            }
        }
예제 #3
0
        public void TestGeneralFrameworkMonikerGoodWithInvalidCharInIncludePath()
        {
            string tempDirectory        = Path.Combine(Path.GetTempPath(), "TestGeneralFrameworkMonikerGoodWithInvalidCharInIncludePath");
            string framework41Directory = Path.Combine(tempDirectory, Path.Combine("MyFramework", "v4.1") + Path.DirectorySeparatorChar);
            string redistListDirectory  = Path.Combine(framework41Directory, "RedistList");
            string redistListFile       = Path.Combine(redistListDirectory, "FrameworkList.xml");

            try
            {
                Directory.CreateDirectory(framework41Directory);
                Directory.CreateDirectory(redistListDirectory);

                string redistListContents =
                    "<FileList Redist='Microsoft-Windows-CLRCoreComp' IncludeFramework='v4.*' Name='Chained oh noes'>" +
                    "<File AssemblyName='System.Xml' Version='2.0.0.0' PublicKeyToken='b03f5f7f11d50a3a' Culture='Neutral' FileVersion='2.0.50727.208' InGAC='true' />" +
                    "<File AssemblyName='Microsoft.Build.Engine' Version='2.0.0.0' PublicKeyToken='b03f5f7f11d50a3a' Culture='Neutral' FileVersion='2.0.50727.208' InGAC='true' />" +
                    "</FileList >";

                File.WriteAllText(redistListFile, redistListContents);

                string     targetFrameworkMoniker = "MyFramework, Version=v4.1";
                MockEngine engine = new MockEngine();
                GetReferenceAssemblyPaths getReferencePaths = new GetReferenceAssemblyPaths();
                getReferencePaths.BuildEngine            = engine;
                getReferencePaths.TargetFrameworkMoniker = targetFrameworkMoniker;
                getReferencePaths.RootPath = tempDirectory;
                getReferencePaths.Execute();
                string[] returnedPaths = getReferencePaths.ReferenceAssemblyPaths;
                Assert.Empty(returnedPaths);
                string displayName = getReferencePaths.TargetFrameworkMonikerDisplayName;
                Assert.Null(displayName);
                FrameworkNameVersioning frameworkMoniker = new FrameworkNameVersioning(getReferencePaths.TargetFrameworkMoniker);
                if (NativeMethodsShared.IsWindows)
                {
                    engine.AssertLogContains("MSB3643");
                }
                else
                {
                    // Since under Unix there are no invalid characters, we don't fail in the incorrect path
                    // and go through to actually looking for the directory
                    string message =
                        ResourceUtilities.FormatResourceStringStripCodeAndKeyword(
                            "GetReferenceAssemblyPaths.NoReferenceAssemblyDirectoryFound",
                            frameworkMoniker.ToString());
                    engine.AssertLogContains(message);
                }
            }
            finally
            {
                if (Directory.Exists(framework41Directory))
                {
                    FileUtilities.DeleteWithoutTrailingBackslash(framework41Directory, true);
                }
            }
        }
        public void TestGeneralFrameworkMonikerGood()
        {
            string     targetFrameworkMoniker = ".NetFramework, Version=v4.5";
            MockEngine engine = new MockEngine();
            GetReferenceAssemblyPaths getReferencePaths = new GetReferenceAssemblyPaths();

            getReferencePaths.BuildEngine            = engine;
            getReferencePaths.TargetFrameworkMoniker = targetFrameworkMoniker;
            getReferencePaths.Execute();
            string[] returnedPaths = getReferencePaths.ReferenceAssemblyPaths;
            Assert.Equal(ToolLocationHelper.GetPathToReferenceAssemblies(new FrameworkNameVersioning(targetFrameworkMoniker)).Count, returnedPaths.Length);
            Assert.Equal(0, engine.Errors); // "Expected the log to contain no errors"
        }
        public void TestGeneralFrameworkMonikerNull()
        {
            MockEngine engine = new MockEngine();
            GetReferenceAssemblyPaths getReferencePaths = new GetReferenceAssemblyPaths();

            getReferencePaths.BuildEngine            = engine;
            getReferencePaths.TargetFrameworkMoniker = null;
            getReferencePaths.Execute();
            string[] returnedPaths = getReferencePaths.ReferenceAssemblyPaths;
            Assert.Null(getReferencePaths.TargetFrameworkMonikerDisplayName);
            Assert.Equal(0, returnedPaths.Length);
            Assert.Equal(1, engine.Errors);
        }
        public void TestGeneralFrameworkMonikerGoodWithInvalidIncludePath()
        {
            string tempDirectory        = Path.Combine(Path.GetTempPath(), "TestGeneralFrameworkMonikerGoodWithInvalidIncludePath");
            string framework41Directory = Path.Combine(tempDirectory, "MyFramework\\v4.1\\");
            string redistListDirectory  = Path.Combine(framework41Directory, "RedistList");
            string redistListFile       = Path.Combine(redistListDirectory, "FrameworkList.xml");

            try
            {
                Directory.CreateDirectory(framework41Directory);
                Directory.CreateDirectory(redistListDirectory);

                string redistListContents =
                    "<FileList Redist='Microsoft-Windows-CLRCoreComp' IncludeFramework='..\\Mooses' Name='Chained oh noes'>" +
                    "<File AssemblyName='System.Xml' Version='2.0.0.0' PublicKeyToken='b03f5f7f11d50a3a' Culture='Neutral' FileVersion='2.0.50727.208' InGAC='true' />" +
                    "<File AssemblyName='Microsoft.Build.Engine' Version='2.0.0.0' PublicKeyToken='b03f5f7f11d50a3a' Culture='Neutral' FileVersion='2.0.50727.208' InGAC='true' />" +
                    "</FileList >";

                File.WriteAllText(redistListFile, redistListContents);

                string     targetFrameworkMoniker = "MyFramework, Version=v4.1";
                MockEngine engine = new MockEngine();
                GetReferenceAssemblyPaths getReferencePaths = new GetReferenceAssemblyPaths();
                getReferencePaths.BuildEngine            = engine;
                getReferencePaths.TargetFrameworkMoniker = targetFrameworkMoniker;
                getReferencePaths.RootPath = tempDirectory;
                getReferencePaths.Execute();
                string[] returnedPaths = getReferencePaths.ReferenceAssemblyPaths;
                Assert.Equal(0, returnedPaths.Length);
                string displayName = getReferencePaths.TargetFrameworkMonikerDisplayName;
                Assert.Null(displayName);
                FrameworkNameVersioning frameworkMoniker = new FrameworkNameVersioning(getReferencePaths.TargetFrameworkMoniker);
                string message = ResourceUtilities.FormatResourceString("GetReferenceAssemblyPaths.NoReferenceAssemblyDirectoryFound", frameworkMoniker.ToString());
                engine.AssertLogContains(message);
            }
            finally
            {
                if (Directory.Exists(framework41Directory))
                {
                    Directory.Delete(framework41Directory, true);
                }
            }
        }
예제 #7
0
        public void TestSuppressNotFoundError()
        {
            MockEngine engine = new MockEngine();
            GetReferenceAssemblyPaths getReferencePaths = new GetReferenceAssemblyPaths();

            getReferencePaths.BuildEngine = engine;
            // Make a framework which does not exist, intentional misspelling of framework
            getReferencePaths.TargetFrameworkMoniker = ".NetFramewok, Version=v99.0";
            getReferencePaths.SuppressNotFoundError  = true;
            bool success = getReferencePaths.Execute();

            Assert.True(success);
            string[] returnedPaths = getReferencePaths.ReferenceAssemblyPaths;
            Assert.Empty(returnedPaths);
            string displayName = getReferencePaths.TargetFrameworkMonikerDisplayName;

            Assert.Null(displayName);
            Assert.Equal(0, engine.Errors);
        }
예제 #8
0
        public void TestGeneralFrameworkMonikerNonExistent()
        {
            MockEngine engine = new MockEngine();
            GetReferenceAssemblyPaths getReferencePaths = new GetReferenceAssemblyPaths();

            getReferencePaths.BuildEngine = engine;
            // Make a framework which does not exist, intentional mispelling of framework
            getReferencePaths.TargetFrameworkMoniker = ".NetFramewok, Version=v99.0";
            getReferencePaths.Execute();
            string[] returnedPaths = getReferencePaths.ReferenceAssemblyPaths;
            Assert.Equal(0, returnedPaths.Length);
            string displayName = getReferencePaths.TargetFrameworkMonikerDisplayName;

            Assert.Null(displayName);
            FrameworkNameVersioning frameworkMoniker = new FrameworkNameVersioning(getReferencePaths.TargetFrameworkMoniker);
            string message = ResourceUtilities.FormatResourceString("GetReferenceAssemblyPaths.NoReferenceAssemblyDirectoryFound", frameworkMoniker.ToString());

            engine.AssertLogContains(message);
        }
        public void TestGeneralFrameworkMonikerGoodWithRoot()
        {
            string tempDirectory        = Path.Combine(Path.GetTempPath(), "TestGeneralFrameworkMonikerGoodWithRoot");
            string framework41Directory = Path.Combine(tempDirectory, "MyFramework\\v4.1\\");
            string redistListDirectory  = Path.Combine(framework41Directory, "RedistList");
            string redistListFile       = Path.Combine(redistListDirectory, "FrameworkList.xml");

            try
            {
                Directory.CreateDirectory(framework41Directory);
                Directory.CreateDirectory(redistListDirectory);

                string redistListContents =
                    "<FileList Redist='Microsoft-Windows-CLRCoreComp' Name='.NET Framework 4.1'>" +
                    "<File AssemblyName='System.Xml' Version='2.0.0.0' PublicKeyToken='b03f5f7f11d50a3a' Culture='Neutral' FileVersion='2.0.50727.208' InGAC='true' />" +
                    "<File AssemblyName='Microsoft.Build.Engine' Version='2.0.0.0' PublicKeyToken='b03f5f7f11d50a3a' Culture='Neutral' FileVersion='2.0.50727.208' InGAC='true' />" +
                    "</FileList >";

                File.WriteAllText(redistListFile, redistListContents);

                string     targetFrameworkMoniker = "MyFramework, Version=v4.1";
                MockEngine engine = new MockEngine();
                GetReferenceAssemblyPaths getReferencePaths = new GetReferenceAssemblyPaths();
                getReferencePaths.BuildEngine            = engine;
                getReferencePaths.TargetFrameworkMoniker = targetFrameworkMoniker;
                getReferencePaths.RootPath = tempDirectory;
                getReferencePaths.Execute();
                string[] returnedPaths = getReferencePaths.ReferenceAssemblyPaths;
                string   displayName   = getReferencePaths.TargetFrameworkMonikerDisplayName;
                Assert.Equal(1, returnedPaths.Length);
                Assert.True(returnedPaths[0].Equals(framework41Directory, StringComparison.OrdinalIgnoreCase));
                Assert.Equal(0, engine.Log.Length); // "Expected the log to contain nothing"
                Assert.True(displayName.Equals(".NET Framework 4.1", StringComparison.OrdinalIgnoreCase));
            }
            finally
            {
                if (Directory.Exists(framework41Directory))
                {
                    Directory.Delete(framework41Directory, true);
                }
            }
        }
예제 #10
0
        public void TestGeneralFrameworkMonikerGoodWithRoot()
        {
            string tempDirectory        = Path.Combine(Path.GetTempPath(), "TestGeneralFrameworkMonikerGoodWithRoot");
            string framework41Directory = Path.Combine(tempDirectory, Path.Combine("MyFramework", "v4.1") + Path.DirectorySeparatorChar);
            string redistListDirectory  = Path.Combine(framework41Directory, "RedistList");
            string redistListFile       = Path.Combine(redistListDirectory, "FrameworkList.xml");

            try
            {
                Directory.CreateDirectory(framework41Directory);
                Directory.CreateDirectory(redistListDirectory);

                string redistListContents =
                    "<FileList Redist='Microsoft-Windows-CLRCoreComp' Name='.NET Framework 4.1'>" +
                    "<File AssemblyName='System.Xml' Version='2.0.0.0' PublicKeyToken='b03f5f7f11d50a3a' Culture='Neutral' FileVersion='2.0.50727.208' InGAC='true' />" +
                    "<File AssemblyName='net.r_eg.IeXod.Engine' Version='2.0.0.0' PublicKeyToken='4bbd2ef743db151e' Culture='Neutral' FileVersion='2.0.50727.208' InGAC='true' />" +
                    "</FileList >";

                File.WriteAllText(redistListFile, redistListContents);

                string     targetFrameworkMoniker = "MyFramework, Version=v4.1";
                MockEngine engine = new MockEngine();
                GetReferenceAssemblyPaths getReferencePaths = new GetReferenceAssemblyPaths();
                getReferencePaths.BuildEngine            = engine;
                getReferencePaths.TargetFrameworkMoniker = targetFrameworkMoniker;
                getReferencePaths.RootPath = tempDirectory;
                getReferencePaths.Execute();
                string[] returnedPaths = getReferencePaths.ReferenceAssemblyPaths;
                string   displayName   = getReferencePaths.TargetFrameworkMonikerDisplayName;
                Assert.Single(returnedPaths);
                Assert.Equal(framework41Directory, returnedPaths[0]);
                Assert.Equal(0, engine.Log.Length); // "Expected the log to contain nothing"
                Assert.Equal(".NET Framework 4.1", displayName);
            }
            finally
            {
                if (Directory.Exists(framework41Directory))
                {
                    FileUtilities.DeleteWithoutTrailingBackslash(framework41Directory, true);
                }
            }
        }
예제 #11
0
        public void TestGeneralFrameworkMonikerGoodWithRootWithProfile()
        {
            string tempDirectory        = Path.Combine(Path.GetTempPath(), "TestGeneralFrameworkMonikerGoodWithRootWithProfile");
            string framework41Directory = Path.Combine(tempDirectory, Path.Combine("MyFramework", "v4.1", "Profile", "Client"));
            string redistListDirectory  = Path.Combine(framework41Directory, "RedistList");
            string redistListFile       = Path.Combine(redistListDirectory, "FrameworkList.xml");

            try
            {
                Directory.CreateDirectory(framework41Directory);
                Directory.CreateDirectory(redistListDirectory);

                string redistListContents =
                    "<FileList Redist='Microsoft-Windows-CLRCoreComp' Name='.NET Framework 4.1 Client'>" +
                    "<File AssemblyName='System.Xml' Version='2.0.0.0' PublicKeyToken='b03f5f7f11d50a3a' Culture='Neutral' FileVersion='2.0.50727.208' InGAC='true' />" +
                    "<File AssemblyName='Microsoft.Build.Engine' Version='2.0.0.0' PublicKeyToken='b03f5f7f11d50a3a' Culture='Neutral' FileVersion='2.0.50727.208' InGAC='true' />" +
                    "</FileList >";

                File.WriteAllText(redistListFile, redistListContents);
                FrameworkNameVersioning name      = new FrameworkNameVersioning("MyFramework", new Version("4.1"), "Client");
                string     targetFrameworkMoniker = name.FullName;
                MockEngine engine = new MockEngine();
                GetReferenceAssemblyPaths getReferencePaths = new GetReferenceAssemblyPaths();
                getReferencePaths.BuildEngine            = engine;
                getReferencePaths.TargetFrameworkMoniker = targetFrameworkMoniker;
                getReferencePaths.RootPath = tempDirectory;
                getReferencePaths.Execute();
                string[] returnedPaths = getReferencePaths.ReferenceAssemblyPaths;
                string   displayName   = getReferencePaths.TargetFrameworkMonikerDisplayName;
                Assert.Single(returnedPaths);
                Assert.Equal(framework41Directory + Path.DirectorySeparatorChar, returnedPaths[0]);
                Assert.Equal(".NET Framework 4.1 Client", displayName);
            }
            finally
            {
                if (Directory.Exists(framework41Directory))
                {
                    FileUtilities.DeleteWithoutTrailingBackslash(framework41Directory, true);
                }
            }
        }