Skip to content

Commit 77afd21

Browse files
committed
Change how we resolve dotnet in tests (#16934)
1 parent 80fec4e commit 77afd21

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/Tools/dotnet-watch/test/Scenario/WatchableApp.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using System.Collections.Generic;
66
using System.IO;
77
using System.Linq;
8+
using System.Reflection;
89
using System.Runtime.CompilerServices;
910
using System.Threading.Tasks;
1011
using Microsoft.Extensions.CommandLineUtils;
@@ -88,15 +89,19 @@ public void Start(IEnumerable<string> arguments, [CallerMemberName] string name
8889
};
8990
args.AddRange(arguments);
9091

92+
var dotnetPath = typeof(WatchableApp).Assembly.GetCustomAttributes<AssemblyMetadataAttribute>()
93+
.Single(s => s.Key == "DotnetPath").Value;
94+
9195
var spec = new ProcessSpec
9296
{
93-
Executable = DotNetMuxer.MuxerPathOrDefault(),
97+
Executable = dotnetPath,
9498
Arguments = args,
9599
WorkingDirectory = SourceDirectory,
96100
EnvironmentVariables =
97101
{
98102
["DOTNET_CLI_CONTEXT_VERBOSE"] = bool.TrueString,
99103
["DOTNET_USE_POLLING_FILE_WATCHER"] = UsePollingWatcher.ToString(),
104+
["DOTNET_ROOT"] = Directory.GetParent(dotnetPath).FullName,
100105
},
101106
};
102107

src/Tools/dotnet-watch/test/dotnet-watch.Tests.csproj

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@
1717
<ProjectReference Include="..\src\dotnet-watch.csproj" />
1818
</ItemGroup>
1919

20+
<ItemGroup>
21+
<AssemblyAttribute Include="System.Reflection.AssemblyMetadataAttribute">
22+
<_Parameter1>DotnetPath</_Parameter1>
23+
<_Parameter2>$(DotNetTool)</_Parameter2>
24+
</AssemblyAttribute>
25+
</ItemGroup>
26+
2027
<Target Name="CleanTestProjects" BeforeTargets="CoreCompile">
2128
<RemoveDir Directories="$(TargetDir)TestProjects" Condition="Exists('$(TargetDir)TestProjects')" />
2229
</Target>

0 commit comments

Comments
 (0)