Test fixes for tools deps.json generation

This commit is contained in:
Daniel Plaisted 2017-04-21 16:14:44 -07:00
parent fa51bb43fc
commit 5c679cd32e
4 changed files with 36 additions and 4 deletions

View file

@ -281,7 +281,8 @@ namespace Microsoft.DotNet.Tests
lockFile,
s_toolPackageFramework,
depsJsonFile,
new SingleProjectInfo("dotnet-portable", "1.0.0", Enumerable.Empty<ResourceAssemblyInfo>()));
new SingleProjectInfo("dotnet-portable", "1.0.0", Enumerable.Empty<ResourceAssemblyInfo>()),
GetToolDepsJsonGeneratorProject());
File.ReadAllText(depsJsonFile).Should().Be("temp");
File.Delete(depsJsonFile);
@ -456,5 +457,12 @@ namespace Microsoft.DotNet.Tests
return projectToolsCommandResolver;
}
private string GetToolDepsJsonGeneratorProject()
{
// When using the product, the ToolDepsJsonGeneratorProject property is used to get this path, but for testing
// we'll hard code the path inside the SDK since we don't have a project to evaluate here
return Path.Combine(new RepoDirectoriesProvider().Stage2Sdk, @"Sdks\Microsoft.NET.Sdk\build\GenerateDeps\GenerateDeps.proj");
}
}
}

View file

@ -14,6 +14,8 @@ using NuGet.Protocol;
using Xunit;
using Xunit.Abstractions;
using MSBuildCommand = Microsoft.DotNet.Tools.Test.Utilities.MSBuildCommand;
using System.Diagnostics;
using System.Threading;
namespace Microsoft.DotNet.Cli.MSBuild.Tests
{
@ -164,11 +166,16 @@ namespace Microsoft.DotNet.Cli.MSBuild.Tests
MSBuildForwardingApp msBuildForwardingApp = new MSBuildForwardingApp(Enumerable.Empty<string>());
FieldInfo forwardingAppFieldInfo = msBuildForwardingApp
object forwardingAppWithoutLogging = msBuildForwardingApp
.GetType()
.GetField("_forwardingAppWithoutLogging", BindingFlags.Instance | BindingFlags.NonPublic)
?.GetValue(msBuildForwardingApp);
FieldInfo forwardingAppFieldInfo = forwardingAppWithoutLogging
.GetType()
.GetField("_forwardingApp", BindingFlags.Instance | BindingFlags.NonPublic);
ForwardingApp forwardingApp = forwardingAppFieldInfo?.GetValue(msBuildForwardingApp) as ForwardingApp;
object forwardingApp = forwardingAppFieldInfo?.GetValue(forwardingAppWithoutLogging);
FieldInfo allArgsFieldinfo = forwardingApp?
.GetType()