Change how we resolve dotnet in tests (#16934)

This commit is contained in:
Brennan 2019-11-09 17:00:10 -08:00 committed by John Luo
parent 22dedcb2f0
commit 2b2153afe6
2 changed files with 13 additions and 1 deletions

View File

@ -5,6 +5,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.Extensions.CommandLineUtils; using Microsoft.Extensions.CommandLineUtils;
@ -88,15 +89,19 @@ namespace Microsoft.DotNet.Watcher.Tools.FunctionalTests
}; };
args.AddRange(arguments); args.AddRange(arguments);
var dotnetPath = typeof(WatchableApp).Assembly.GetCustomAttributes<AssemblyMetadataAttribute>()
.Single(s => s.Key == "DotnetPath").Value;
var spec = new ProcessSpec var spec = new ProcessSpec
{ {
Executable = DotNetMuxer.MuxerPathOrDefault(), Executable = dotnetPath,
Arguments = args, Arguments = args,
WorkingDirectory = SourceDirectory, WorkingDirectory = SourceDirectory,
EnvironmentVariables = EnvironmentVariables =
{ {
["DOTNET_CLI_CONTEXT_VERBOSE"] = bool.TrueString, ["DOTNET_CLI_CONTEXT_VERBOSE"] = bool.TrueString,
["DOTNET_USE_POLLING_FILE_WATCHER"] = UsePollingWatcher.ToString(), ["DOTNET_USE_POLLING_FILE_WATCHER"] = UsePollingWatcher.ToString(),
["DOTNET_ROOT"] = Directory.GetParent(dotnetPath).FullName,
}, },
}; };

View File

@ -17,6 +17,13 @@
<ProjectReference Include="..\src\dotnet-watch.csproj" /> <ProjectReference Include="..\src\dotnet-watch.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<AssemblyAttribute Include="System.Reflection.AssemblyMetadataAttribute">
<_Parameter1>DotnetPath</_Parameter1>
<_Parameter2>$(DotNetTool)</_Parameter2>
</AssemblyAttribute>
</ItemGroup>
<Target Name="CleanTestProjects" BeforeTargets="CoreCompile"> <Target Name="CleanTestProjects" BeforeTargets="CoreCompile">
<RemoveDir Directories="$(TargetDir)TestProjects" Condition="Exists('$(TargetDir)TestProjects')" /> <RemoveDir Directories="$(TargetDir)TestProjects" Condition="Exists('$(TargetDir)TestProjects')" />
</Target> </Target>