Exemplo n.º 1
0
        private RunningResults RunMsBuild(string submissionCompilationDirectory)
        {
            var projSubmission = (ProjRunnerSubmission)submission;

            log.Info($"Запускаю проверку C#-решения {projSubmission.Id}, компилирую с помощью MsBuild");
            var dir = new DirectoryInfo(submissionCompilationDirectory);

            try
            {
                Utils.UnpackZip(projSubmission.ZipFileData, dir.FullName);
            }
            catch (Exception ex)
            {
                log.Error("Не могу распаковать решение", ex);
                return(new RunningResults(submission.Id, Verdict.SandboxError, error: ex.ToString()));
            }

            log.Info($"Компилирую решение {submission.Id}: {projSubmission.ProjectFileName} в папке {dir.FullName}");

            var builderResult = MsBuildRunner.BuildProject(settings.MsBuildSettings, projSubmission.ProjectFileName, dir);

            if (!builderResult.Success)
            {
                log.Info($"Решение {submission.Id} не скомпилировалось: {builderResult.ToString().Replace("\n", @"\n")}");
                return(new RunningResults(Verdict.CompilationError, compilationOutput: builderResult.ToString()));
            }

            return(RunSandbox($"\"{builderResult.PathToExe}\" {submission.Id}"));
        }
Exemplo n.º 2
0
        public void SimpleProjTest()
        {
            var dir            = new DirectoryInfo(@"..\..\test");
            var buildingResult = MsBuildRunner.BuildProject(
                new MsBuildSettings(),
                "test.csproj",
                dir);

            Console.WriteLine(buildingResult.ErrorMessage);
            Assert.That(buildingResult.Success, Is.True);
            Assert.That(buildingResult.ErrorMessage, Is.Null);
        }