Skip to content

Commit c3dd3d3

Browse files
committed
Try to make global.json to use .NET 8
1 parent d526168 commit c3dd3d3

File tree

1 file changed

+24
-4
lines changed

1 file changed

+24
-4
lines changed

tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/InstrumentationTests.cs

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public async Task DoesNotInstrumentDotnetBuild()
8282

8383
using var agent = EnvironmentHelper.GetMockAgent(useTelemetry: true);
8484

85-
var logDir = await RunDotnet("new console -n instrumentation_test -o . --no-restore -f net8.0");
85+
var logDir = await RunDotnet("new console -n instrumentation_test -o . --no-restore");
8686
AssertNotInstrumented(agent, logDir);
8787

8888
logDir = await RunDotnet("restore");
@@ -110,11 +110,14 @@ public async Task DoesNotInstrumentExcludedNames(string excludedProcess)
110110
var workingDir = Path.Combine(Path.GetTempPath(), Path.GetFileNameWithoutExtension(Path.GetRandomFileName()));
111111
Directory.CreateDirectory(workingDir);
112112

113+
// Hack to ensure that the .NET 8.0 SDK is used instead of .NET 10 as it complains about not finding the runtime
114+
EnsureNet8Sdk(workingDir);
115+
113116
Output.WriteLine("Using workingDirectory: " + workingDir);
114117

115118
using var agent = EnvironmentHelper.GetMockAgent(useTelemetry: true);
116119

117-
var logDir = await RunDotnet($"new console -n {excludedProcess} -o . --no-restore -f net8.0");
120+
var logDir = await RunDotnet($"new console -n {excludedProcess} -o . --no-restore");
118121
AssertNotInstrumented(agent, logDir);
119122

120123
var programCs = GetProgramCSThatMakesSpans();
@@ -148,11 +151,14 @@ public async Task DoesInstrumentAllowedProcesses(string allowedProcess)
148151
var workingDir = Path.Combine(Path.GetTempPath(), Path.GetFileNameWithoutExtension(Path.GetRandomFileName()));
149152
Directory.CreateDirectory(workingDir);
150153

154+
// Hack to ensure that the .NET 8.0 SDK is used instead of .NET 10 as it complains about not finding the runtime
155+
EnsureNet8Sdk(workingDir);
156+
151157
Output.WriteLine("Using workingDirectory: " + workingDir);
152158

153159
using var agent = EnvironmentHelper.GetMockAgent(useTelemetry: true);
154160

155-
var logDir = await RunDotnet($"new console -n {allowedProcess} -o . --no-restore -f net8.0");
161+
var logDir = await RunDotnet($"new console -n {allowedProcess} -o . --no-restore");
156162
AssertNotInstrumented(agent, logDir);
157163
var programCs = GetProgramCSThatMakesSpans();
158164

@@ -182,11 +188,14 @@ public async Task InstrumentsDotNetTest()
182188
var workingDir = Path.Combine(Path.GetTempPath(), Path.GetFileNameWithoutExtension(Path.GetRandomFileName()));
183189
Directory.CreateDirectory(workingDir);
184190

191+
// Hack to ensure that the .NET 8.0 SDK is used instead of .NET 10 as it complains about not finding the runtime
192+
EnsureNet8Sdk(workingDir);
193+
185194
Output.WriteLine("Using workingDirectory: " + workingDir);
186195

187196
using var agent = EnvironmentHelper.GetMockAgent(useTelemetry: true);
188197

189-
var logDir = await RunDotnet("new xunit -n instrumentation_test -o . --no-restore -f net8.0");
198+
var logDir = await RunDotnet("new xunit -n instrumentation_test -o . --no-restore");
190199
AssertNotInstrumented(agent, logDir);
191200

192201
// this _should_ be instrumented so we expect managed data.
@@ -840,6 +849,17 @@ private void AddFilesAsReportable(string logDir, AssertionScope scope, string[]
840849
});
841850
}
842851

852+
private void EnsureNet8Sdk(string workingDirectory)
853+
{
854+
var globalJson = @"{
855+
""sdk"": {
856+
""version"": ""8.0.0"",
857+
""rollForward"": ""latestMinor""
858+
}
859+
}";
860+
File.WriteAllText(Path.Combine(workingDirectory, "global.json"), globalJson);
861+
}
862+
843863
private bool IsAllLoggingDisabledForBailout()
844864
{
845865
var isSsi = EnvironmentHelper.CustomEnvironmentVariables.TryGetValue("DD_INJECTION_ENABLED", out var injectionEnabled)

0 commit comments

Comments
 (0)