Exemplo n.º 1
0
        public void DoNotFindFileOnPath()
        {
            string bogusFile = Path.ChangeExtension(Guid.NewGuid().ToString(), ".txt");

            // for the NUnit "Standard Out" tab
            Console.WriteLine("The bogus file name is: " + bogusFile);

            string bogusFilePath = NativeMethodsShared.FindOnPath(bogusFile);

            Assert.Null(bogusFilePath);
        }
Exemplo n.º 2
0
        public void FindFileOnPath()
        {
            string expectedCmdPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.System), "cmd.exe");
            string cmdPath         = NativeMethodsShared.FindOnPath("cmd.exe");

            Assert.NotNull(cmdPath);

            // for the NUnit "Standard Out" tab
            Console.WriteLine("Expected location of \"cmd.exe\": " + expectedCmdPath);
            Console.WriteLine("Found \"cmd.exe\" here: " + cmdPath);

            Assert.Equal(0, String.Compare(cmdPath, expectedCmdPath, StringComparison.OrdinalIgnoreCase));
        }
Exemplo n.º 3
0
        /// <summary>
        /// This method is called to find the tool if ToolPath wasn't specified.
        /// We just return the name of the tool so it can be found on the path.
        /// Deriving classes can choose to do something else.
        /// </summary>
        protected override string GenerateFullPathToTool()
        {
#if WHIDBEY_BUILD
            // if we just have the file name, search for the file on the system path
            string actualPathToTool = NativeMethodsShared.FindOnPath(ToolName);

            // if we find the file
            if (actualPathToTool != null)
            {
                // point to it
                return(actualPathToTool);
            }
            else
            {
                return(ToolName);
            }
#else
            return(ToolName);
#endif
        }
Exemplo n.º 4
0
        private string ComputePathToTool()
        {
            string str;

            if (this.UseCommandProcessor)
            {
                return(this.ToolExe);
            }
            if ((this.ToolPath != null) && (this.ToolPath.Length > 0))
            {
                str = Path.Combine(this.ToolPath, this.ToolExe);
            }
            else
            {
                str = this.GenerateFullPathToTool();
                if ((str != null) && !string.IsNullOrEmpty(this.toolExe))
                {
                    str = Path.Combine(Path.GetDirectoryName(str), this.ToolExe);
                }
            }
            if (str != null)
            {
                if (Path.GetFileName(str).Length != str.Length)
                {
                    if (!File.Exists(str))
                    {
                        this.LogPrivate.LogErrorWithCodeFromResources("ToolTask.ToolExecutableNotFound", new object[] { str });
                        return(null);
                    }
                    return(str);
                }
                string str3 = NativeMethodsShared.FindOnPath(str);
                if (str3 != null)
                {
                    str = str3;
                }
            }
            return(str);
        }