Skip to content
This repository has been archived by the owner on Jul 12, 2022. It is now read-only.

Commit

Permalink
Merge pull request #51 from dotnet/terrajobst/detect-missing-dev14
Browse files Browse the repository at this point in the history
Add error handling do detect when MSBuild 14 is missing
  • Loading branch information
terrajobst committed Feb 8, 2015
2 parents 788eabc + ab60dbb commit 68004f5
Showing 1 changed file with 26 additions and 9 deletions.
35 changes: 26 additions & 9 deletions src/CodeFormatter/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.Collections.Immutable;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.MSBuild;
Expand Down Expand Up @@ -90,15 +91,31 @@ private static int Main(string[] args)

Console.CancelKeyPress += delegate { cts.Cancel(); };

RunAsync(
projectOrSolutionPath,
ruleTypeBuilder.ToImmutableArray(),
fileNamesBuilder.ToImmutableArray(),
configBuilder.ToImmutableArray(),
copyrightHeader,
ct).Wait(ct);
Console.WriteLine("Completed formatting.");
return 0;
try
{
RunAsync(
projectOrSolutionPath,
ruleTypeBuilder.ToImmutableArray(),
fileNamesBuilder.ToImmutableArray(),
configBuilder.ToImmutableArray(),
copyrightHeader,
ct).Wait(ct);
Console.WriteLine("Completed formatting.");
return 0;
}
catch (AggregateException ex)
{
var typeLoadException = ex.InnerExceptions.FirstOrDefault() as ReflectionTypeLoadException;
if (typeLoadException == null)
throw;

Console.WriteLine("ERROR: Type loading error detected. In order to run this tool you need either Visual Studio 2015 or Microsoft Build Tools 2015 tools installed.");
var messages = typeLoadException.LoaderExceptions.Select(e => e.Message).Distinct();
foreach (var message in messages)
Console.WriteLine("- {0}", message);

return 1;
}
}

private static async Task RunAsync(
Expand Down

0 comments on commit 68004f5

Please sign in to comment.