@@ -187,5 +187,60 @@ public void Interpreter (ApplePlatform platform, string runtimeIdentifiers)
187187 Assert . That ( File . GetLastWriteTimeUtc ( appExecutable ) , Is . EqualTo ( appExecutableTimestamp ) , "Modified B" ) ;
188188 }
189189
190+ [ Test ]
191+ [ TestCase ( ApplePlatform . iOS , "iossimulator-arm64" , true ) ]
192+ [ TestCase ( ApplePlatform . iOS , "iossimulator-arm64" , false ) ]
193+ public void CodeChangeSkipsTargets ( ApplePlatform platform , string runtimeIdentifiers , bool interpreterEnabled )
194+ {
195+ CodeChangeSkipsTargetsImpl ( platform , runtimeIdentifiers , interpreterEnabled ) ;
196+ }
197+
198+ [ Test ]
199+ [ Category ( "RemoteWindows" ) ]
200+ [ TestCase ( ApplePlatform . iOS , "iossimulator-arm64" , true ) ]
201+ [ TestCase ( ApplePlatform . iOS , "iossimulator-arm64" , false ) ]
202+ public void CodeChangeSkipsTargetsOnRemoteWindows ( ApplePlatform platform , string runtimeIdentifiers , bool interpreterEnabled )
203+ {
204+ Configuration . IgnoreIfNotOnWindows ( ) ;
205+ CodeChangeSkipsTargetsImpl ( platform , runtimeIdentifiers , interpreterEnabled ) ;
206+ }
207+
208+ void CodeChangeSkipsTargetsImpl ( ApplePlatform platform , string runtimeIdentifiers , bool interpreterEnabled )
209+ {
210+ var project = "IncrementalTestApp" ;
211+ Configuration . IgnoreIfIgnoredPlatform ( platform ) ;
212+ Configuration . AssertRuntimeIdentifiersAvailable ( platform , runtimeIdentifiers ) ;
213+
214+ var project_path = GetProjectPath ( project , runtimeIdentifiers : runtimeIdentifiers , platform : platform , out var appPath ) ;
215+ Clean ( project_path ) ;
216+ var properties = GetDefaultProperties ( runtimeIdentifiers ) ;
217+
218+ properties [ "UseInterpreter" ] = interpreterEnabled . ToString ( ) ;
219+
220+ // Build the first time
221+ var rv = DotNet . AssertBuild ( project_path , properties ) ;
222+ var allTargets = BinLog . GetAllTargets ( rv . BinLogPath ) ;
223+
224+ // Verify these targets executed on first build
225+ AssertTargetExecuted ( allTargets , "_CreatePkgInfo" , "A" ) ;
226+ AssertTargetExecuted ( allTargets , "_CompileNativeExecutable" , "A" ) ;
227+ AssertTargetExecuted ( allTargets , "_LinkNativeExecutable" , "A" ) ;
228+
229+ // Make a code change
230+ properties [ "AdditionalDefineConstants" ] = "INCLUDED_ADDITIONAL_CODE" ;
231+
232+ // Build again after modifying the helper C# file
233+ rv = DotNet . AssertBuild ( project_path , properties ) ;
234+ allTargets = BinLog . GetAllTargets ( rv . BinLogPath ) ;
235+
236+ // Verify these targets did NOT execute on incremental build after C# change
237+ AssertTargetNotExecuted ( allTargets , "_CreatePkgInfo" , "B" ) ;
238+ AssertTargetNotExecuted ( allTargets , "_CompileNativeExecutable" , "B" ) ;
239+ if ( interpreterEnabled ) {
240+ AssertTargetNotExecuted ( allTargets , "_LinkNativeExecutable" , "B" ) ;
241+ } else {
242+ AssertTargetExecuted ( allTargets , "_LinkNativeExecutable" , "B" ) ;
243+ }
244+ }
190245 }
191246}
0 commit comments