示例#1
0
        public void UpdateMSBuildLocations()
        {
            var msBuildLocations = SettingsService.GetRecentMSBuildLocations(
                DotnetUtilities.GetMsBuildPathCollection().Reverse());

            MSBuildLocations.Clear();
            foreach (var msbuild in msBuildLocations)
            {
                MSBuildLocations.Add(msbuild);
            }

            MSBuildLocation = MSBuildLocations.FirstOrDefault();
        }
        public static string[] GetMSBuildLocations()
        {
            var candidates = new HashSet <string>(StringComparer.OrdinalIgnoreCase);

            var vs15Locations = GetVS15Locations();

            candidates.UnionWith(vs15Locations.Select(l => Path.Combine(l, "MSBuild", "15.0", "Bin", "MSBuild.exe")));
            candidates.UnionWith(vs15Locations.Select(l => Path.Combine(l, "MSBuild", "15.0", "Bin", "amd64", "MSBuild.exe")));
            candidates.UnionWith(vs15Locations.Select(l => Path.Combine(l, "MSBuild", "Current", "Bin", "MSBuild.exe")));
            candidates.UnionWith(vs15Locations.Select(l => Path.Combine(l, "MSBuild", "Current", "Bin", "amd64", "MSBuild.exe")));
            candidates.UnionWith(GetMsBuildInstancesFromVisualStudio());

            var finalResults = candidates
                               .Where(File.Exists)
                               .OrderBy(s => s);

            return(DotnetUtilities.GetMsBuildPathCollection()
                   .Reverse()
                   .Concat(finalResults)
                   .ToArray());
        }