private void ReportErrorIfStudentsZipHasErrors()
        {
            var tempExZipFilePath = new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory).GetFile($"{slide.Id}.exercise.zip");
            var tempExFolder      = new DirectoryInfo(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "ExerciseFolder_From_StudentZip"));

            exerciseStudentZipBuilder.BuildStudentZip(slide, tempExZipFilePath);
            Utils.UnpackZip(tempExZipFilePath.ReadAllContent(), tempExFolder.FullName);
            try
            {
                ReportErrorIfStudentsZipHasWrongAnswerOrSolutionFiles(tempExFolder);

                var csprojFile = tempExFolder.GetFile(ex.CsprojFileName);
                var csproj     = new Project(csprojFile.FullName, null, null, new ProjectCollection());
                ReportErrorIfCsprojHasUserCodeOfNotCompileType(tempExFolder, csproj);
                ReportErrorIfCsprojHasWrongAnswerOrSolutionItems(tempExFolder, csproj);

                if (!ex.StudentZipIsCompilable)
                {
                    return;
                }

                var buildResult = MsBuildRunner.BuildProject(settings.MsBuildSettings, ex.CsprojFile.Name, tempExFolder);
                ReportErrorIfStudentsZipNotBuilding(buildResult);
            }
            finally
            {
                tempExFolder.Delete(true);
                tempExZipFilePath.Delete();
            }
        }
Beispiel #2
0
        private void StudentsZipIsBuildingOk(Slide slide, ProjectExerciseBlock ex)
        {
            var tempDir = new DirectoryInfo("./temp");

            try
            {
                Utils.UnpackZip(ex.StudentsZip.Content(), "./temp");
                var res = MsBuildRunner.BuildProject(settings.MsBuildSettings, tempDir.GetFile(ex.CsprojFileName).FullName, tempDir);
                if (!res.Success)
                {
                    ReportSlideError(slide, ex.CsprojFileName + " not building! " + res);
                }
            }
            finally
            {
                tempDir.Delete(true);
            }
        }