Created
January 11, 2014 15:01
-
-
Save FabienArcellier/8371946 to your computer and use it in GitHub Desktop.
get the DotNetFramework path using ToolLocationHelper
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Microsoft.Build.Utilities; | |
using System; | |
using System.Collections.Generic; | |
using System.IO; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
namespace DotNetPaths | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var sb = new StringBuilder(); | |
var methods = typeof(ToolLocationHelper).GetMethods(); | |
foreach (var method in methods) | |
{ | |
if (typeof(string) == method.ReturnType && | |
method.GetParameters().Count() == 1 && | |
method.GetParameters()[0].ParameterType == typeof(TargetDotNetFrameworkVersion)) | |
{ | |
var result = (string)method.Invoke(null, new object[] { TargetDotNetFrameworkVersion.VersionLatest }); | |
sb.AppendLine(string.Format("[{0}]", method.Name)); | |
sb.AppendLine(string.Format(" {0}", result)); | |
} | |
} | |
Console.Out.WriteLine(sb.ToString()); | |
var fs = new StreamWriter("output.txt"); | |
fs.Write(sb.ToString()); | |
fs.Close(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment