diff --git a/src/BuildPrediction/Predictors/FakesOutputPathPredictor.cs b/src/BuildPrediction/Predictors/FakesOutputPathPredictor.cs
new file mode 100644
index 0000000..a5638ef
--- /dev/null
+++ b/src/BuildPrediction/Predictors/FakesOutputPathPredictor.cs
@@ -0,0 +1,27 @@
+// Copyright (c) Microsoft. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+
+using Microsoft.Build.Execution;
+
+namespace Microsoft.Build.Prediction.Predictors
+{
+ ///
+ /// Predicts the output directory for Microsoft Fakes assemblies based on the FakesOutputPath property.
+ ///
+ public sealed class FakesOutputPathPredictor : IProjectPredictor
+ {
+ internal const string FakesOutputPathPropertyName = "FakesOutputPath";
+
+ ///
+ public void PredictInputsAndOutputs(
+ ProjectInstance projectInstance,
+ ProjectPredictionReporter predictionReporter)
+ {
+ string fakesOutputPath = projectInstance.GetPropertyValue(FakesOutputPathPropertyName);
+ if (!string.IsNullOrWhiteSpace(fakesOutputPath))
+ {
+ predictionReporter.ReportOutputDirectory(fakesOutputPath);
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/BuildPrediction/ProjectPredictors.cs b/src/BuildPrediction/ProjectPredictors.cs
index b4b91e5..83e846b 100644
--- a/src/BuildPrediction/ProjectPredictors.cs
+++ b/src/BuildPrediction/ProjectPredictors.cs
@@ -64,6 +64,7 @@ public static class ProjectPredictors
///
///
///
+ ///
///
///
/// A collection of .
@@ -114,6 +115,7 @@ public static class ProjectPredictors
new GenerateBuildDependencyFilePredictor(),
new GeneratePublishDependencyFilePredictor(),
new GenerateRuntimeConfigurationFilesPredictor(),
+ new FakesOutputPathPredictor(),
//// NOTE! When adding a new predictor here, be sure to update the doc comment above.
};
diff --git a/src/BuildPredictionTests/Predictors/FakesOutputPathPredictorTests.cs b/src/BuildPredictionTests/Predictors/FakesOutputPathPredictorTests.cs
new file mode 100644
index 0000000..821c877
--- /dev/null
+++ b/src/BuildPredictionTests/Predictors/FakesOutputPathPredictorTests.cs
@@ -0,0 +1,96 @@
+// Copyright (c) Microsoft. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+
+using Microsoft.Build.Construction;
+using Microsoft.Build.Execution;
+using Microsoft.Build.Prediction.Predictors;
+using Xunit;
+
+namespace Microsoft.Build.Prediction.Tests.Predictors
+{
+ public class FakesOutputPathPredictorTests
+ {
+ [Fact]
+ public void FakesOutputPathFoundAsOutputDir()
+ {
+ const string FakesOutputPath = @"C:\repo\FakesAssemblies";
+ ProjectInstance projectInstance = CreateTestProjectInstance(FakesOutputPath);
+ new FakesOutputPathPredictor()
+ .GetProjectPredictions(projectInstance)
+ .AssertPredictions(
+ projectInstance,
+ null,
+ null,
+ null,
+ new[] { new PredictedItem(FakesOutputPath, nameof(FakesOutputPathPredictor)) });
+ }
+
+ [Fact]
+ public void RelativeFakesOutputPathFoundAsOutputDir()
+ {
+ const string FakesOutputPath = @"bin\FakesAssemblies";
+ ProjectInstance projectInstance = CreateTestProjectInstance(FakesOutputPath);
+ new FakesOutputPathPredictor()
+ .GetProjectPredictions(projectInstance)
+ .AssertPredictions(
+ projectInstance,
+ null,
+ null,
+ null,
+ new[] { new PredictedItem(FakesOutputPath, nameof(FakesOutputPathPredictor)) });
+ }
+
+ [Fact]
+ public void DefaultFakesAssembliesDirectoryFoundAsOutputDir()
+ {
+ const string FakesOutputPath = @"FakesAssemblies";
+ ProjectInstance projectInstance = CreateTestProjectInstance(FakesOutputPath);
+ new FakesOutputPathPredictor()
+ .GetProjectPredictions(projectInstance)
+ .AssertPredictions(
+ projectInstance,
+ null,
+ null,
+ null,
+ new[] { new PredictedItem(FakesOutputPath, nameof(FakesOutputPathPredictor)) });
+ }
+
+ [Fact]
+ public void NoOutputsReportedIfNoFakesOutputPath()
+ {
+ ProjectInstance projectInstance = CreateTestProjectInstance(null);
+ new FakesOutputPathPredictor()
+ .GetProjectPredictions(projectInstance)
+ .AssertNoPredictions();
+ }
+
+ [Fact]
+ public void NoOutputsReportedIfEmptyFakesOutputPath()
+ {
+ ProjectInstance projectInstance = CreateTestProjectInstance(string.Empty);
+ new FakesOutputPathPredictor()
+ .GetProjectPredictions(projectInstance)
+ .AssertNoPredictions();
+ }
+
+ [Fact]
+ public void NoOutputsReportedIfWhitespaceFakesOutputPath()
+ {
+ ProjectInstance projectInstance = CreateTestProjectInstance(" ");
+ new FakesOutputPathPredictor()
+ .GetProjectPredictions(projectInstance)
+ .AssertNoPredictions();
+ }
+
+ private static ProjectInstance CreateTestProjectInstance(string fakesOutputPath)
+ {
+ ProjectRootElement projectRootElement = ProjectRootElement.Create();
+ if (fakesOutputPath != null)
+ {
+ projectRootElement.AddProperty(FakesOutputPathPredictor.FakesOutputPathPropertyName, fakesOutputPath);
+ }
+
+ return TestHelpers.CreateProjectInstanceFromRootElement(projectRootElement);
+ }
+ }
+}
\ No newline at end of file