Пример #1
0
        /// <summary>
        /// Given a filename (currently only Tracker.exe and FileTracker.dll are supported), return
        /// the path to that file.
        /// </summary>
        /// <param name="filename"></param>
        /// <param name="bitness"></param>
        /// <returns></returns>
        private static string GetPath(string filename, DotNetFrameworkArchitecture bitness)
        {
            // Make sure that if someone starts passing the wrong thing to this method we don't silently
            // eat it and do something possibly unexpected.
            ErrorUtilities.VerifyThrow(
                s_TrackerFilename.Equals(filename, StringComparison.OrdinalIgnoreCase) ||
                s_FileTrackerFilename.Equals(filename, StringComparison.OrdinalIgnoreCase),
                "This method should only be passed s_TrackerFilename or s_FileTrackerFilename, but was passed {0} instead!",
                filename
                );

            // Look for FileTracker.dll/Tracker.exe in the MSBuild tools directory. They may exist elsewhere on disk,
            // but other copies aren't guaranteed to be compatible with the latest.
            var path = ToolLocationHelper.GetPathToBuildToolsFile(filename, ToolLocationHelper.CurrentToolsVersion, bitness);

            // Due to a Detours limitation, the path to FileTracker32.dll must be
            // representable in ANSI characters. Look for it first in the global
            // shared location which is guaranteed to be ANSI. Fall back to
            // current folder.
            if (s_FileTrackerFilename.Equals(filename, StringComparison.OrdinalIgnoreCase))
            {
                string progfilesPath = Path.Combine(FrameworkLocationHelper.GenerateProgramFiles32(),
                                                    "MSBuild", "15.0", "FileTracker", s_FileTrackerFilename);

                if (FileSystems.Default.FileExists(progfilesPath))
                {
                    return(progfilesPath);
                }
            }

            return(path);
        }
Пример #2
0
        /// <summary>
        /// Given a filename (currently only Tracker.exe and FileTracker.dll are supported), return
        /// the path to that file.
        /// </summary>
        /// <param name="filename"></param>
        /// <param name="bitness"></param>
        /// <returns></returns>
        private static string GetPath(string filename, DotNetFrameworkArchitecture bitness)
        {
            // Make sure that if someone starts passing the wrong thing to this method we don't silently
            // eat it and do something possibly unexpected.
            ErrorUtilities.VerifyThrow(
                s_TrackerFilename.Equals(filename, StringComparison.OrdinalIgnoreCase) ||
                s_FileTrackerFilename.Equals(filename, StringComparison.OrdinalIgnoreCase),
                "This method should only be passed s_TrackerFilename or s_FileTrackerFilename, but was passed {0} instead!",
                filename
                );

            // Look for FileTracker.dll/Tracker.exe in the MSBuild tools directory. They may exist elsewhere on disk,
            // but other copies aren't guaranteed to be compatible with the latest.
            return(ToolLocationHelper.GetPathToBuildToolsFile(filename, ToolLocationHelper.CurrentToolsVersion, bitness));
        }
Пример #3
0
        /// <summary>
        /// Given a filename (currently only Tracker.exe and FileTracker.dll are supported), return
        /// the path to that file.
        /// </summary>
        /// <param name="filename"></param>
        /// <param name="bitness"></param>
        /// <returns></returns>
        private static string GetPath(string filename, DotNetFrameworkArchitecture bitness)
        {
            string trackerPath;

            // Make sure that if someone starts passing the wrong thing to this method we don't silently
            // eat it and do something possibly unexpected.
            ErrorUtilities.VerifyThrow(
                s_TrackerFilename.Equals(filename, StringComparison.OrdinalIgnoreCase) ||
                s_FileTrackerFilename.Equals(filename, StringComparison.OrdinalIgnoreCase),
                "This method should only be passed s_TrackerFilename or s_FileTrackerFilename, but was passed {0} instead!",
                filename
                );

            // Look for FileTracker.dll/FileTracker.exe first in the MSBuild tools directory, then fall back to .NET framework directory
            // and finally to .NET SDK directories.
            trackerPath = ToolLocationHelper.GetPathToBuildToolsFile(filename, ToolLocationHelper.CurrentToolsVersion, bitness);

            if (String.IsNullOrEmpty(trackerPath))
            {
                trackerPath = ToolLocationHelper.GetPathToDotNetFrameworkFile(filename, TargetDotNetFrameworkVersion.VersionLatest, bitness);

                if ((String.IsNullOrEmpty(trackerPath) || !File.Exists(trackerPath)) && s_TrackerFilename.Equals(filename, StringComparison.OrdinalIgnoreCase))
                {
                    // fall back to looking in the SDK directory -- this is where Tracker.exe will be in the typical VS case.  First check
                    // in the SDK for the latest target framework and latest Visual Studio version, since we want to make sure that we get
                    // the most up-to-date version of FileTracker.
                    trackerPath = ToolLocationHelper.GetPathToDotNetFrameworkSdkFile(filename, TargetDotNetFrameworkVersion.Version45, VisualStudioVersion.VersionLatest, bitness);

                    // If that didn't work, we may be in a scenario where, e.g., we have VS 10 on Windows 8, which comes with .NET 4.5
                    // pre-installed.  In which case, the Dev11 (or other "latest" SDK) may not exist, but the Dev10 SDK might.  Check
                    // for that here.
                    if (trackerPath == null)
                    {
                        trackerPath = ToolLocationHelper.GetPathToDotNetFrameworkSdkFile(filename, TargetDotNetFrameworkVersion.Version40, bitness);
                    }
                }
            }
            return(trackerPath);
        }