Skip to content

Instantly share code, notes, and snippets.

@FabienArcellier
Created January 11, 2014 15:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FabienArcellier/8371946 to your computer and use it in GitHub Desktop.
Save FabienArcellier/8371946 to your computer and use it in GitHub Desktop.
get the DotNetFramework path using ToolLocationHelper
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