diff --git a/src/Microsoft.VisualStudio.ProjectSystem.Managed/ProjectSystem/UpToDate/BuildUpToDateCheck.cs b/src/Microsoft.VisualStudio.ProjectSystem.Managed/ProjectSystem/UpToDate/BuildUpToDateCheck.cs index 087ad6525d9..0ae0787d632 100644 --- a/src/Microsoft.VisualStudio.ProjectSystem.Managed/ProjectSystem/UpToDate/BuildUpToDateCheck.cs +++ b/src/Microsoft.VisualStudio.ProjectSystem.Managed/ProjectSystem/UpToDate/BuildUpToDateCheck.cs @@ -722,11 +722,9 @@ private bool CheckBuiltFromInputFiles(Log log, in TimestampCache timestampCache, return true; } - private bool CheckCopyToOutputDirectoryItems(Log log, UpToDateCheckImplicitConfiguredInput state, IEnumerable<(string Path, ImmutableArray CopyItems)> copyItemsByProject, ConfiguredFileSystemOperationAggregator fileSystemAggregator, bool? isBuildAccelerationEnabled, CancellationToken token) + private bool CheckCopyToOutputDirectoryItems(Log log, UpToDateCheckImplicitConfiguredInput state, IEnumerable<(string Path, ImmutableArray CopyItems)> copyItemsByProject, ConfiguredFileSystemOperationAggregator fileSystemAggregator, bool? isBuildAccelerationEnabled, SolutionBuildContext solutionBuildContext, CancellationToken token) { - ITimestampCache? timestampCache = _solutionBuildContextProvider.CurrentSolutionBuildContext?.CopyItemTimestamps; - - Assumes.NotNull(timestampCache); + ITimestampCache timestampCache = solutionBuildContext.CopyItemTimestamps; string outputFullPath = Path.Combine(state.MSBuildProjectDirectory, state.OutputRelativeOrFullPath); @@ -973,10 +971,12 @@ private async Task IsUpToDateInternalAsync( // // In either case, we construct an event here lazily so that we can correctly test for the // existence of copy items in CheckCopyToOutputDirectoryItems. - if (_solutionBuildContextProvider.CurrentSolutionBuildContext is null) + SolutionBuildContext? solutionBuildContext = _solutionBuildContextProvider.CurrentSolutionBuildContext; + if (solutionBuildContext is null) { _solutionBuildEventListener.NotifySolutionBuildStarting(); - Assumes.NotNull(_solutionBuildContextProvider.CurrentSolutionBuildContext); + solutionBuildContext = _solutionBuildContextProvider.CurrentSolutionBuildContext; + Assumes.NotNull(solutionBuildContext); } globalProperties.TryGetValue(FastUpToDateCheckIgnoresKindsGlobalPropertyName, out string? ignoreKindsString); @@ -1083,7 +1083,7 @@ private async Task IsUpToDateInternalAsync( !CheckInputsAndOutputs(logger, lastSuccessfulBuildStartTimeUtc, timestampCache, implicitState, ignoreKinds, token) || !CheckBuiltFromInputFiles(logger, timestampCache, implicitState, token) || !CheckMarkers(logger, timestampCache, implicitState, isBuildAccelerationEnabled, fileSystemOperations) || - !CheckCopyToOutputDirectoryItems(logger, implicitState, copyInfo.ItemsByProject, configuredFileSystemOperations, isBuildAccelerationEnabled, token)) + !CheckCopyToOutputDirectoryItems(logger, implicitState, copyInfo.ItemsByProject, configuredFileSystemOperations, isBuildAccelerationEnabled, solutionBuildContext, token)) { return (false, checkedConfigurations); }