private static Solution RemoveNonExistingReferences(Project project) { foreach (var metadataReference in project.MetadataReferences.ToArray()) { if (!File.Exists(metadataReference.Display)) { Log.Message("Reference assembly doesn't exist on disk: " + metadataReference.Display); project = project.RemoveMetadataReference(metadataReference); } } return project.Solution; }
/// <summary> /// Compiles the given P# project. /// </summary> /// <param name="project">Project</param> private static void CompileProject(Project project) { var runtimeDllPath = typeof(Dispatcher).Assembly.Location; var bugFindingRuntimeDllPath = typeof(BugFindingDispatcher).Assembly.Location; var runtimeDll = project.MetadataReferences.FirstOrDefault(val => val.Display.EndsWith( Path.DirectorySeparatorChar + "Microsoft.PSharp.Runtime.dll")); if (runtimeDll != null && (Configuration.RunStaticAnalysis || Configuration.RunDynamicAnalysis)) { project = project.RemoveMetadataReference(runtimeDll); } if ((Configuration.RunStaticAnalysis || Configuration.RunDynamicAnalysis) && !project.MetadataReferences.Any(val => val.Display.EndsWith( Path.DirectorySeparatorChar + "Microsoft.PSharp.BugFindingRuntime.dll"))) { project = project.AddMetadataReference(MetadataReference.CreateFromFile( bugFindingRuntimeDllPath)); } var compilation = project.GetCompilationAsync().Result; try { if (Configuration.RunDynamicAnalysis) { var dll = CompilationEngine.ToFile(compilation, OutputKind.DynamicallyLinkedLibrary, project.OutputFilePath); if (Configuration.ProjectName.Equals(project.Name)) { Configuration.AssembliesToBeAnalyzed.Add(dll); } } else if (Configuration.CompileForDistribution) { CompilationEngine.ToFile(compilation, OutputKind.DynamicallyLinkedLibrary, project.OutputFilePath); } else { CompilationEngine.ToFile(compilation, project.CompilationOptions.OutputKind, project.OutputFilePath); } } catch (ApplicationException ex) { ErrorReporter.ReportAndExit(ex.Message); } }
/// <summary> /// Compiles the given P# project. /// </summary> /// <param name="project">Project</param> private void CompileProject(Project project) { var runtimeDllPath = typeof(Dispatcher).Assembly.Location; var bugFindingRuntimeDllPath = typeof(BugFindingDispatcher).Assembly.Location; var runtimeDll = project.MetadataReferences.FirstOrDefault(val => val.Display.EndsWith( Path.DirectorySeparatorChar + "Microsoft.PSharp.Runtime.dll")); if (runtimeDll != null && this.CompilationContext.ActiveCompilationTarget == CompilationTarget.Testing) { project = project.RemoveMetadataReference(runtimeDll); } if (this.CompilationContext.ActiveCompilationTarget == CompilationTarget.Testing && !project.MetadataReferences.Any(val => val.Display.EndsWith( Path.DirectorySeparatorChar + "Microsoft.PSharp.BugFindingRuntime.dll"))) { project = project.AddMetadataReference(MetadataReference.CreateFromFile( bugFindingRuntimeDllPath)); } var compilation = project.GetCompilationAsync().Result; try { if (this.CompilationContext.ActiveCompilationTarget == CompilationTarget.Testing || this.CompilationContext.ActiveCompilationTarget == CompilationTarget.Distribution) { this.ToFile(compilation, OutputKind.DynamicallyLinkedLibrary, project.OutputFilePath); } else { this.ToFile(compilation, project.CompilationOptions.OutputKind, project.OutputFilePath); } } catch (ApplicationException ex) { ErrorReporter.ReportAndExit(ex.Message); } }