private ProjectGraphWithPredictionsResult <string> BuildGraphAndDeserialize(IMsBuildAssemblyLoader assemblyLoader, string projectEntryPointContent = null) { string outputFile = Path.Combine(TemporaryDirectory, Guid.NewGuid().ToString()); string entryPoint = Path.Combine(TemporaryDirectory, Guid.NewGuid().ToString()); if (projectEntryPointContent != null) { File.WriteAllText(entryPoint, projectEntryPointContent); } using (var reporter = new GraphBuilderReporter(Guid.NewGuid().ToString())) { var arguments = new MSBuildGraphBuilderArguments( TemporaryDirectory, entryPoint, outputFile, globalProperties: null, mSBuildSearchLocations: new string[] { TestDeploymentDir }, entryPointTargets: new string[0]); MsBuildGraphBuilder.BuildGraphAndSerializeForTesting(assemblyLoader, reporter, arguments); } // The serialized graph should exist Assert.True(File.Exists(outputFile)); var projectGraphWithPredictionsResult = SimpleDeserializer.Instance.DeserializeGraph(outputFile); return(projectGraphWithPredictionsResult); }
private ProjectGraphWithPredictionsResult <string> BuildGraphAndDeserialize(IMsBuildAssemblyLoader assemblyLoader, string projectEntryPointContent = null) { string outputFile = Path.Combine(TemporaryDirectory, Guid.NewGuid().ToString()); string entryPoint = Path.Combine(TemporaryDirectory, Guid.NewGuid().ToString()); if (projectEntryPointContent != null) { File.WriteAllText(entryPoint, projectEntryPointContent); } using (var reporter = new GraphBuilderReporter(Guid.NewGuid().ToString())) { var arguments = GetStandardBuilderArguments( new[] { entryPoint }, outputFile, globalProperties: GlobalProperties.Empty, entryPointTargets: new string[0], requestedQualifiers: new GlobalProperties[] { GlobalProperties.Empty }, allowProjectsWithoutTargetProtocol: false); MsBuildGraphBuilder.BuildGraphAndSerializeForTesting(assemblyLoader, reporter, arguments); } // The serialized graph should exist Assert.True(File.Exists(outputFile)); var projectGraphWithPredictionsResult = SimpleDeserializer.Instance.DeserializeGraph(outputFile); return(projectGraphWithPredictionsResult); }
public void ProblematicPredictorsAreHandled() { string outputFile = Path.Combine(TemporaryDirectory, Guid.NewGuid().ToString()); // We don't bother creating content for the entry point project. The predictor is going to fail anyway. string entryPoint = Path.Combine(TemporaryDirectory, Guid.NewGuid().ToString()); using (var reporter = new GraphBuilderReporter(Guid.NewGuid().ToString())) { var arguments = new MSBuildGraphBuilderArguments( TestOutputDirectory, entryPoint, outputFile, globalProperties: null, mSBuildSearchLocations: new[] { TestDeploymentDir }, entryPointTargets: new string[0]); MsBuildGraphBuilder.BuildGraphAndSerializeForTesting( MsBuildAssemblyLoader.Instance, reporter, arguments, new IProjectStaticPredictor[] { new ThrowOnPredictionPredictor() }); } var result = SimpleDeserializer.Instance.DeserializeGraph(outputFile); // The result should gracefully fail, with some error message. Assert.False(result.Succeeded); Assert.True(result.Failure.Message != null); }
public void ProblematicPredictorsAreHandled() { string outputFile = Path.Combine(TemporaryDirectory, Guid.NewGuid().ToString()); // We don't bother creating content for the entry point project. The predictor is going to fail anyway. string entryPoint = Path.Combine(TemporaryDirectory, Guid.NewGuid().ToString()); using (var reporter = new GraphBuilderReporter(Guid.NewGuid().ToString())) { var arguments = GetStandardBuilderArguments( new[] { entryPoint }, outputFile, globalProperties: GlobalProperties.Empty, entryPointTargets: new string[0], requestedQualifiers: new GlobalProperties[] { GlobalProperties.Empty }, allowProjectsWithoutTargetProtocol: false); MsBuildGraphBuilder.BuildGraphAndSerializeForTesting( AssemblyLoader, reporter, arguments, new IProjectPredictor[] { new ThrowOnPredictionPredictor() }); } var result = SimpleDeserializer.Instance.DeserializeGraph(outputFile); // The result should gracefully fail, with some error message. Assert.False(result.Succeeded); Assert.True(result.Failure.Message != null); }
private bool BuildAndReport(GraphBuilderReporter reporter, out string failure) { string outputFile = Path.Combine(TemporaryDirectory, Guid.NewGuid().ToString()); var arguments = GetStandardBuilderArguments( new[] { m_entryPoint }, outputFile, globalProperties: GlobalProperties.Empty, entryPointTargets: new string[0], requestedQualifiers: new GlobalProperties[] { GlobalProperties.Empty }, allowProjectsWithoutTargetProtocol: false); MsBuildGraphBuilder.BuildGraphAndSerializeForTesting(AssemblyLoader, reporter, arguments); var result = SimpleDeserializer.Instance.DeserializeGraph(outputFile); failure = string.Empty; if (!result.Succeeded) { failure = result.Failure.Message; } return(result.Succeeded); }
private bool BuildAndReport(GraphBuilderReporter reporter, out string failure) { string outputFile = Path.Combine(TemporaryDirectory, Guid.NewGuid().ToString()); var arguments = new MSBuildGraphBuilderArguments( TestOutputDirectory, new[] { m_entryPoint }, outputFile, globalProperties: null, mSBuildSearchLocations: new[] { TestDeploymentDir }, entryPointTargets: new string[0]); MsBuildGraphBuilder.BuildGraphAndSerializeForTesting(MsBuildAssemblyLoader.Instance, reporter, arguments); var result = SimpleDeserializer.Instance.DeserializeGraph(outputFile); failure = string.Empty; if (!result.Succeeded) { failure = result.Failure.Message; } return(result.Succeeded); }