public void CompilesProject(EnvironmentPreference preference, string solutionPath, string projectPath)
        {
            // Given
            StringWriter    log     = new StringWriter();
            AnalyzerManager manager = new AnalyzerManager(solutionPath, new AnalyzerManagerOptions
            {
                LogWriter = log
            });
            IProjectAnalyzer   analyzer = manager.GetProject(projectPath);
            EnvironmentOptions options  = new EnvironmentOptions
            {
                Preference = preference
            };

            // Set some environment variables to make it seem like we're not in a CI build
            // Sometimes this messes up libraries like SourceLink since we're building as part of a test and not for CI
            options.EnvironmentVariables.Add("APPVEYOR", "False");
            options.EnvironmentVariables.Add("ContinuousIntegrationBuild", null);
            options.EnvironmentVariables.Add("CI", "False");
            options.EnvironmentVariables.Add("CI_LINUX", "False");
            options.EnvironmentVariables.Add("CI_WINDOWS", "False");

            // When
            DeleteProjectDirectory(analyzer.ProjectFile.Path, "obj");
            DeleteProjectDirectory(analyzer.ProjectFile.Path, "bin");
            analyzer.IgnoreFaultyImports = false;

#pragma warning disable 0162
            if (BinaryLog)
            {
                analyzer.AddBinaryLogger($@"C:\Temp\{Path.GetFileNameWithoutExtension(solutionPath)}.{Path.GetFileNameWithoutExtension(analyzer.ProjectFile.Path)}.core.binlog");
            }
#pragma warning restore 0162

#if Is_Windows
            IAnalyzerResults results = analyzer.Build(options);
#else
            // On non-Windows platforms we have to remove the .NET Framework target frameworks and only build .NET Core target frameworks
            // See https://github.com/dotnet/sdk/issues/826
            string[] excludedTargetFrameworks = new[] { "net2", "net3", "net4", "portable" };
            string[] targetFrameworks         = analyzer.ProjectFile.TargetFrameworks.Where(x => !excludedTargetFrameworks.Any(y => x.StartsWith(y))).ToArray();
            if (targetFrameworks.Length == 0)
            {
                Assert.Ignore();
            }
            IAnalyzerResults results = analyzer.Build(targetFrameworks, options);
#endif

            // Then
            results.Count.ShouldBeGreaterThan(0, log.ToString());
            results.OverallSuccess.ShouldBeTrue(log.ToString());
            results.ShouldAllBe(x => x.Succeeded, log.ToString());
        }
        public void GetsSourceFilesFromBinaryLog(
            [ValueSource(nameof(Preferences))] EnvironmentPreference preference,
            [ValueSource(nameof(ProjectFiles))] string projectFile)
        {
            // Given
            StringWriter       log      = new StringWriter();
            IProjectAnalyzer   analyzer = GetProjectAnalyzer(projectFile, log);
            EnvironmentOptions options  = new EnvironmentOptions
            {
                Preference = preference
            };
            string binLogPath = Path.ChangeExtension(Path.GetTempFileName(), ".binlog");

            analyzer.AddBinaryLogger(binLogPath);

            try
            {
                // When
                analyzer.Build(options);
                IAnalyzerResults results = analyzer.Manager.Analyze(binLogPath);

                // Then
                // If this is the multi-targeted project, use the net462 target
                IReadOnlyList <string> sourceFiles = results.Count == 1 ? results.First().SourceFiles : results["net462"].SourceFiles;
                sourceFiles.ShouldNotBeNull(log.ToString());
                new[]
                {
#if Is_Windows
                    // Linux and Mac builds appear to omit the AssemblyAttributes.cs file
                    "AssemblyAttributes",
#endif
                    "Class1",
                    "AssemblyInfo"
                }.ShouldBeSubsetOf(sourceFiles.Select(x => Path.GetFileName(x).Split('.').TakeLast(2).First()), log.ToString());
            }
            finally
            {
                if (File.Exists(binLogPath))
                {
                    File.Delete(binLogPath);
                }
            }
        }