private static void BuildMod(BuildContext context) { var contentBuilder = new ContentBuilder(context); if (context.Options.Workshop && context.Method != BuildMethod.Cats) { Logger.Log(LogCategory.Warning, "You have specified workshop mode, but the build method is not catalogs. Is this intentional?"); } XDocument contentDocument; try { contentDocument = contentBuilder.BuildContent(); } catch (Exception e) { throw new Exception("Failed to build content.xml output: " + e.Message, e); } var contentStringBuilder = new StringBuilder(); using ( var contentWriter = XmlWriter.Create(contentStringBuilder, new XmlWriterSettings { Indent = true, IndentChars = " " }) ) { contentDocument.WriteTo(contentWriter); } Logger.Log(LogCategory.Debug, $"{context.Config.Build.ExcludePaths.Count()} excluded path patterns:"); Logger.Log(LogCategory.Debug, string.Join("\n", context.Config.Build.ExcludePaths)); var filesToPackage = new BuildPathsProcessor(context.Config).GetPathsToBuild(Directory.GetCurrentDirectory()); Logger.Log(LogCategory.Debug, $"{filesToPackage.Count} files to build:"); Logger.Log(LogCategory.Debug, string.Join("\n", filesToPackage)); try { Logger.Log(LogCategory.Info, "Building mod to directory " + context.Config.Build.OutputDirectory); Directory.CreateDirectory(context.Config.Build.OutputDirectory); } catch (Exception e) { throw new Exception( $"Failed to create build output directory at {context.Config.Build.OutputDirectory}: " + e.Message, e ); } IModFilesBuilder builder; var buildOutputPath = context.Config.Build.OutputDirectory; switch (context.Method) { case BuildMethod.Loose: builder = new LooseModFilesBuilder(); Logger.Log(LogCategory.Info, "Using build method: loose files"); break; case BuildMethod.Archive: builder = new ArchiveModFilesBuilder(context.Config, GetTemplateSpecs(context.Config)); Logger.Log(LogCategory.Info, "Using build method: zip archive"); break; case BuildMethod.Cats: builder = new CatModFilesBuilder(context.Config); Logger.Log(LogCategory.Info, "Using build method: catalogs"); break; default: throw new ArgumentException("Invalid build method: " + context.Config.Build.Method); } builder.BuildModFiles(buildOutputPath, filesToPackage, contentStringBuilder.ToString()); }
public void ThrowArgumentNullExceptionWhenBuildWithoutTemplateSet() { Assert.Throws <ArgumentNullException>(() => messageBuilder.BuildContent(null, bodyMock.Object)); }