Skip to content

Commit 632c5e0

Browse files
committed
Try a different way to get .NET 8 over .NET 10
1 parent f93064c commit 632c5e0

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,16 @@ public async Task DoesNotInstrumentExcludedNames(string excludedProcess)
117117
var logDir = await RunDotnet($"new console -n {excludedProcess} -o . --no-restore");
118118
AssertNotInstrumented(agent, logDir);
119119

120+
// Force the project to target .NET 8 instead of whatever the SDK defaults to
121+
var projectFile = Path.Combine(workingDir, $"{excludedProcess}.csproj");
122+
var projectContent = File.ReadAllText(projectFile);
123+
124+
// Replace any target framework with net8.0
125+
var updatedContent = System.Text.RegularExpressions.Regex.Replace(
126+
projectContent,
127+
@"<TargetFramework>net\d+\.\d+</TargetFramework>",
128+
"<TargetFramework>net8.0</TargetFramework>");
129+
120130
var programCs = GetProgramCSThatMakesSpans();
121131

122132
File.WriteAllText(Path.Combine(workingDir, "Program.cs"), programCs);
@@ -154,6 +164,17 @@ public async Task DoesInstrumentAllowedProcesses(string allowedProcess)
154164

155165
var logDir = await RunDotnet($"new console -n {allowedProcess} -o . --no-restore");
156166
AssertNotInstrumented(agent, logDir);
167+
168+
// Force the project to target .NET 8 instead of whatever the SDK defaults to
169+
var projectFile = Path.Combine(workingDir, $"{allowedProcess}.csproj");
170+
var projectContent = File.ReadAllText(projectFile);
171+
172+
// Replace any target framework with net8.0
173+
var updatedContent = System.Text.RegularExpressions.Regex.Replace(
174+
projectContent,
175+
@"<TargetFramework>net\d+\.\d+</TargetFramework>",
176+
"<TargetFramework>net8.0</TargetFramework>");
177+
157178
var programCs = GetProgramCSThatMakesSpans();
158179

159180
File.WriteAllText(Path.Combine(workingDir, "Program.cs"), programCs);

0 commit comments

Comments
 (0)