Merge pull request #1 from nehmebilal/jlaans/loop

Fix exe path in targets file and update nuspec
This commit is contained in:
Johan Laanstra 2018-02-13 15:07:35 -08:00 коммит произвёл GitHub
Родитель 65763788a2 dcc7ed0b58
Коммит 3cbe06f7e4
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
3 изменённых файлов: 37 добавлений и 28 удалений

Просмотреть файл

@ -2,7 +2,7 @@
<package >
<metadata>
<id>Etg.SimpleStubs</id>
<version>2.3.4</version>
<version>2.4.0</version>
<title>SimpleStubs mocking framework</title>
<authors>Microsoft Studios (BigPark)</authors>
<owners>Microsoft Studios (BigPark)</owners>
@ -18,29 +18,11 @@
</metadata>
<files>
<file src="..\src\SimpleStubs.CodeGen\bin\Release\Etg.SimpleStubs.CodeGen.dll" target="tools" />
<file src="..\src\SimpleStubs.CodeGen\bin\Release\Microsoft.Build.dll" target="tools" />
<file src="..\src\SimpleStubs.CodeGen\bin\Release\Microsoft.Build.Engine.dll" target="tools" />
<file src="..\src\SimpleStubs.CodeGen\bin\Release\Microsoft.Build.Framework.dll" target="tools" />
<file src="..\src\SimpleStubs.CodeGen\bin\Release\Microsoft.Build.Tasks.Core.dll" target="tools" />
<file src="..\src\SimpleStubs.CodeGen\bin\Release\Microsoft.Build.Utilities.Core.dll" target="tools" />
<file src="..\src\SimpleStubs.CodeGen\bin\Release\Microsoft.CodeAnalysis.CSharp.dll" target="tools" />
<file src="..\src\SimpleStubs.CodeGen\bin\Release\Microsoft.CodeAnalysis.CSharp.Workspaces.dll" target="tools" />
<file src="..\src\SimpleStubs.CodeGen\bin\Release\Microsoft.CodeAnalysis.dll" target="tools" />
<file src="..\src\SimpleStubs.CodeGen\bin\Release\Microsoft.CodeAnalysis.Workspaces.Desktop.dll" target="tools" />
<file src="..\src\SimpleStubs.CodeGen\bin\Release\Microsoft.CodeAnalysis.Workspaces.dll" target="tools" />
<file src="..\src\SimpleStubs.CodeGen\bin\Release\System.Collections.Immutable.dll" target="tools" />
<file src="..\src\SimpleStubs.CodeGen\bin\Release\System.Composition.AttributedModel.dll" target="tools" />
<file src="..\src\SimpleStubs.CodeGen\bin\Release\System.Composition.Convention.dll" target="tools" />
<file src="..\src\SimpleStubs.CodeGen\bin\Release\System.Composition.Hosting.dll" target="tools" />
<file src="..\src\SimpleStubs.CodeGen\bin\Release\System.Composition.Runtime.dll" target="tools" />
<file src="..\src\SimpleStubs.CodeGen\bin\Release\System.Composition.TypedParts.dll" target="tools" />
<file src="..\src\SimpleStubs.CodeGen\bin\Release\System.Reflection.Metadata.dll" target="tools" />
<file src="..\src\SimpleStubs.CodeGen\bin\Release\Newtonsoft.Json.dll" target="tools" />
<file src="..\src\SimpleStubs.CodeGen\bin\Release\Autofac.dll" target="tools" />
<file src="..\src\SimpleStubs.CodeGen\bin\Release\**\*.dll" target="tools" />
<file src="..\src\SimpleStubs.CodeGen\bin\Release\**\*.config" target="tools" />
<file src="..\src\SimpleStubs.CodeGen\bin\Release\Etg.SimpleStubs.CodeGen.exe" target="tools" />
<file src="..\Targets\Etg.SimpleStubs.targets" target="build" />
<file src="SimpleStubs.generated.cs" target="content\Properties\SimpleStubs.generated.cs" />
<file src="SimpleStubs.json" target="content\SimpleStubs.json" />
</files>
</package>

Просмотреть файл

@ -15,7 +15,7 @@
<Exec
WorkingDirectory="$(ProjectDir)"
Command="..\tools\Etg.SimpleStubs.CodeGen.exe -ProjectPath:&quot;$(ProjectDir)$(ProjectName).csproj'&quot; -OutputPath:&quot;$(SimpleStubsCodeGenOutput)&quot;" />
Command="$(MSBuildThisFileDirectory)\..\tools\Etg.SimpleStubs.CodeGen.exe -ProjectPath:&quot;$(ProjectDir)$(ProjectName).csproj'&quot; -OutputPath:&quot;$(SimpleStubsCodeGenOutput)&quot;" />
<ItemGroup>
<Compile Include="$(SimpleStubsCodeGenOutput)" />

Просмотреть файл

@ -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)