Beispiel #1
0
        public FileCompileResult Compile(string fileToCompile)
        {
            CompileResult result;

            if (fileToCompile.EndsWith(".cs"))
            {
                var compiler       = new CSharpCompiler();
                var copiedFileName = fileToCompile + ".cs";
                File.Copy(fileToCompile, copiedFileName);
                result = compiler.Compile(this.csharpCompilerPath, copiedFileName, "/optimize+ /nologo /reference:System.Numerics.dll");
            }
            else if (fileToCompile.EndsWith(".zip"))
            {
                var compiler       = new MsBuildCompiler();
                var copiedFileName = fileToCompile + ".zip";
                File.Copy(fileToCompile, copiedFileName);
                result = compiler.Compile(this.msbuildCompilerPath, copiedFileName, "/t:rebuild /p:Configuration=Release,Optimize=true /verbosity:quiet /nologo");
            }
            else
            {
                throw new ArgumentException("Invalid file extension", "fileToCompile");
            }

            return(new FileCompileResult(result));
        }
Beispiel #2
0
        public void MsBuildCompilerShouldWorkWhenGivenValidZippedProjectInSingleFolder()
        {
            var compiler = new MsBuildCompiler();
            var result   = compiler.Compile(MsBuildCompilerPath, FileHelpers.SaveByteArrayToTempFile(this.GetSampleSolutionWhereTheProjectIsLocatedInSingleFolder()), string.Empty);

            Assert.IsTrue(result.IsCompiledSuccessfully, "Compilation is not successful");
            Assert.IsFalse(string.IsNullOrWhiteSpace(result.OutputFile), "Output file is null");
            Assert.IsTrue(result.OutputFile.EndsWith(".exe"), "Output file does not ends with .exe");
        }
        public void MsBuildCompilerShouldWorkWhenGivenValidZippedSolution()
        {
            var compiler = new MsBuildCompiler();
            var result = compiler.Compile(MsBuildCompilerPath, FileHelpers.SaveByteArrayToTempFile(this.GetSampleSolutionFile()), string.Empty);

            Assert.IsTrue(result.IsCompiledSuccessfully, "Compilation is not successful");
            Assert.IsFalse(string.IsNullOrWhiteSpace(result.OutputFile), "Output file is null");
            Assert.IsTrue(result.OutputFile.EndsWith(".exe"), "Output file does not ends with .exe");
        }