private void Compile(CompilerBuildCache assemblyCache, string outputFile, string docFile)
        {
            // If no changes in source files, return.
            if (!GetIfMustRecompile(assemblyCache, outputFile))
            {
                return;
            }

            // NOTE: Ensure LoaderLock Managed Debugging Assistant in Exception settings is disabled, to allow VS to run dynamic compilation within IDE.

            // Compile the source files, etc.
            string outputDir       = _fileSystem.Path.GetDirectoryName(outputFile);
            var    compilerOptions = new CompilerOptions
            {
                OutputFile           = outputFile,
                DocFile              = docFile,
                ReferencedAssemblies = assemblyCache.Dependencies.Select(d =>
                {
                    string localFilePath = _fileSystem.Path.Combine(outputDir, d.Name);
                    return(_fileSystem.File.Exists(localFilePath) ? localFilePath : d.Name);
                })
                                       .ToArray()
            };

            _compiler.CompileCode(assemblyCache.SourceFiles.Select(cs => _fileSystem.Path.Combine(ControllerDir, cs.Name)).ToArray(), compilerOptions);

            SaveBuildCache(assemblyCache, outputFile);
        }
Ejemplo n.º 2
0
        public void Given_null_file_names_when_compiling_should_throw()
        {
            // Act
            Action act = () => _sut.CompileCode((string[])null, new CompilerOptions());

            // Assert
            act.Should().Throw <ArgumentNullException>()
            .WithParamName("fileNames");
        }