diff --git a/NuGet/SimpleStubs.nuspec b/NuGet/SimpleStubs.nuspec index 09c8a44..a241a69 100644 --- a/NuGet/SimpleStubs.nuspec +++ b/NuGet/SimpleStubs.nuspec @@ -2,7 +2,7 @@ Etg.SimpleStubs - 2.4.2 + 2.4.3 SimpleStubs Mocking Framework (C#). Nehme Bilal Microsoft diff --git a/Targets/Etg.SimpleStubs.targets b/Targets/Etg.SimpleStubs.targets index 2fcbc0f..9da5cf3 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)" -Configuration:"$(Configuration)" -Platform:"$(Platform)"" /> diff --git a/src/SimpleStubs.CodeGen/CodeGen/SimpleStubsGenerator.cs b/src/SimpleStubs.CodeGen/CodeGen/SimpleStubsGenerator.cs index c02fadd..bfbf549 100644 --- a/src/SimpleStubs.CodeGen/CodeGen/SimpleStubsGenerator.cs +++ b/src/SimpleStubs.CodeGen/CodeGen/SimpleStubsGenerator.cs @@ -25,9 +25,12 @@ namespace Etg.SimpleStubs.CodeGen _config = config; } - public async Task GenerateStubs(string testProjectPath, string configuration) + public async Task GenerateStubs(string testProjectPath, string configuration, string platform) { - using (var workspace = MSBuildWorkspace.Create(new Dictionary { { "Configuration", configuration } })) + using (var workspace = MSBuildWorkspace.Create(new Dictionary { + { "Configuration", configuration }, + { "Platform", platform} + })) { Project currentProject = await workspace.OpenProjectAsync(testProjectPath); @@ -38,7 +41,7 @@ namespace Etg.SimpleStubs.CodeGen { stringBuilder.AppendLine(diagnostic.ToString()); } - throw new Exception("Failed to open project, Errors: " + stringBuilder.ToString()); + Console.WriteLine("Simplestubs encountered errors when opening the workspace; Stubs will be generated only for projects that successfully opened. Errors: " + stringBuilder.ToString()); } if (currentProject == null) diff --git a/src/SimpleStubs.CodeGen/Program.cs b/src/SimpleStubs.CodeGen/Program.cs index 009727e..8cdc7e0 100644 --- a/src/SimpleStubs.CodeGen/Program.cs +++ b/src/SimpleStubs.CodeGen/Program.cs @@ -39,6 +39,13 @@ namespace Etg.SimpleStubs.CodeGen return; } + string platform = parser.Arguments["-Platform"]; + if (string.IsNullOrEmpty(platform)) + { + Console.WriteLine(DecorateMessage($"Platform cannot be empty")); + return; + } + DiModule diModule = new DiModule(projectPath, outputPath); Directory.CreateDirectory(Path.GetDirectoryName(outputPath)); @@ -46,7 +53,7 @@ namespace Etg.SimpleStubs.CodeGen try { - string stubsCode = diModule.StubsGenerator.GenerateStubs(projectPath, configuration).Result; + string stubsCode = diModule.StubsGenerator.GenerateStubs(projectPath, configuration, platform).Result; Console.WriteLine(DecorateMessage($"Writing stubs to file: {outputPath}")); File.WriteAllText(outputPath, stubsCode); } diff --git a/test/TestClassLibraryTest/Etg.SimpleStubs.targets b/test/TestClassLibraryTest/Etg.SimpleStubs.targets index fec2e74..3a01b44 100644 --- a/test/TestClassLibraryTest/Etg.SimpleStubs.targets +++ b/test/TestClassLibraryTest/Etg.SimpleStubs.targets @@ -15,7 +15,7 @@ + Command="..\..\src\SimpleStubs.CodeGen\bin\$(ConfigurationName)\Etg.SimpleStubs.CodeGen.exe -ProjectPath:"$(ProjectDir)$(ProjectName).csproj'" -OutputPath:"$(SimpleStubsCodeGenOutput)" -Configuration:"$(Configuration)" -Platform:"$(Platform)"" />