diff --git a/NuGet/SimpleStubs.nuspec b/NuGet/SimpleStubs.nuspec index f62fbad..e2ebe97 100644 --- a/NuGet/SimpleStubs.nuspec +++ b/NuGet/SimpleStubs.nuspec @@ -2,7 +2,7 @@ Etg.SimpleStubs - 2.3.4 + 2.4.0 SimpleStubs mocking framework Microsoft Studios (BigPark) Microsoft Studios (BigPark) @@ -18,29 +18,11 @@ - - - - - - - - - - - - - - - - - - - - + + + - \ No newline at end of file diff --git a/Targets/Etg.SimpleStubs.targets b/Targets/Etg.SimpleStubs.targets index 19fb12d..1aa825f 100644 --- a/Targets/Etg.SimpleStubs.targets +++ b/Targets/Etg.SimpleStubs.targets @@ -15,7 +15,7 @@ + Command="$(MSBuildThisFileDirectory)\..\tools\Etg.SimpleStubs.CodeGen.exe -ProjectPath:"$(ProjectDir)$(ProjectName).csproj'" -OutputPath:"$(SimpleStubsCodeGenOutput)"" /> diff --git a/src/SimpleStubs.CodeGen/Program.cs b/src/SimpleStubs.CodeGen/Program.cs index 0b4ea5e..0278945 100644 --- a/src/SimpleStubs.CodeGen/Program.cs +++ b/src/SimpleStubs.CodeGen/Program.cs @@ -1,6 +1,7 @@ using System; using System.IO; -using Etg.SimpleStubs.CodeGen; +using System.Reflection; +using System.Text; using Etg.SimpleStubs.CodeGen.DI; namespace Etg.SimpleStubs.CodeGen @@ -30,11 +31,37 @@ namespace Etg.SimpleStubs.CodeGen Directory.CreateDirectory(Path.GetDirectoryName(outputPath)); Console.WriteLine(DecorateMessage($"Generating stubs for project: {projectPath}")); - string stubsCode = diModule.StubsGenerator.GenerateStubs(projectPath).Result; - Console.WriteLine(DecorateMessage($"Writing stubs to file: {outputPath}")); - File.WriteAllText(outputPath, stubsCode); - return; + try + { + string stubsCode = diModule.StubsGenerator.GenerateStubs(projectPath).Result; + Console.WriteLine(DecorateMessage($"Writing stubs to file: {outputPath}")); + File.WriteAllText(outputPath, stubsCode); + } + catch (ReflectionTypeLoadException ex) + { + StringBuilder sb = new StringBuilder(); + foreach (Exception exSub in ex.LoaderExceptions) + { + sb.AppendLine(exSub.Message); + FileNotFoundException exFileNotFound = exSub as FileNotFoundException; + if (exFileNotFound != null) + { + if (!string.IsNullOrEmpty(exFileNotFound.FusionLog)) + { + sb.AppendLine("Fusion Log:"); + sb.AppendLine(exFileNotFound.FusionLog); + } + } + sb.AppendLine(); + } + string errorMessage = sb.ToString(); + Console.WriteLine(DecorateMessage($"Failed to generate stubs: {errorMessage}")); + } + catch(Exception e) + { + Console.WriteLine(DecorateMessage($"Failed to generate stubs: {e.ToString()}")); + } } private static string DecorateMessage(string message)