@@ -117,6 +117,16 @@ public async Task DoesNotInstrumentExcludedNames(string excludedProcess)
117
117
var logDir = await RunDotnet ( $ "new console -n { excludedProcess } -o . --no-restore") ;
118
118
AssertNotInstrumented ( agent , logDir ) ;
119
119
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
+
120
130
var programCs = GetProgramCSThatMakesSpans ( ) ;
121
131
122
132
File . WriteAllText ( Path . Combine ( workingDir , "Program.cs" ) , programCs ) ;
@@ -154,6 +164,17 @@ public async Task DoesInstrumentAllowedProcesses(string allowedProcess)
154
164
155
165
var logDir = await RunDotnet ( $ "new console -n { allowedProcess } -o . --no-restore") ;
156
166
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
+
157
178
var programCs = GetProgramCSThatMakesSpans ( ) ;
158
179
159
180
File . WriteAllText ( Path . Combine ( workingDir , "Program.cs" ) , programCs ) ;
0 commit comments