/// <summary> /// Checks whether an implementation directory matches the expected digest. /// Throws <see cref="DigestMismatchException"/> if it does not match. /// </summary> /// <param name="path">The path of the directory ot check.</param> /// <param name="manifestDigest">The expected digest.</param> /// <param name="handler">A callback object used when the the user is to be informed about progress.</param> /// <exception cref="OperationCanceledException">The user canceled the task.</exception> /// <exception cref="NotSupportedException"><paramref name="manifestDigest"/> does not list any supported digests.</exception> /// <exception cref="IOException">The directory could not be processed.</exception> /// <exception cref="UnauthorizedAccessException">Read access to the directory is not permitted.</exception> /// <exception cref="DigestMismatchException">The directory does not match the expected digest</exception> public static void Verify(string path, ManifestDigest manifestDigest, ITaskHandler handler) { #region Sanity checks if (string.IsNullOrEmpty(path)) { throw new ArgumentNullException(nameof(path)); } if (handler == null) { throw new ArgumentNullException(nameof(handler)); } #endregion string expectedDigest = manifestDigest.Best ?? throw new NotSupportedException(Resources.NoKnownDigestMethod); var format = ManifestFormat.FromPrefix(expectedDigest); var builder = new ManifestBuilder(format); handler.RunTask(new ReadDirectory(path, builder)); if (Verify(builder.Manifest, expectedDigest) == null) { string manifestFilePath = Path.Combine(path, Manifest.ManifestFile); var expectedManifest = File.Exists(manifestFilePath) ? Manifest.Load(manifestFilePath, format) : null; throw new DigestMismatchException( expectedDigest, actualDigest: builder.Manifest.CalculateDigest(), expectedManifest, actualManifest: builder.Manifest); } }
public virtual void AddContractNameAttribute(ManifestBuilder mfb, XmlNode node, MetaDataCustomAttribute data, string contractName) { mfb.AddAttribute(node, "contractName", contractName); }
/// <summary> /// Calculates a <see cref="ManifestDigest"/> for a retrieval method. Sets missing properties in the process. /// </summary> /// <param name="retrievalMethod">The retrieval method.</param> /// <param name="executor">Used to modify properties in an undoable fashion.</param> /// <param name="handler">A callback object used when the the user is to be informed about progress.</param> /// <param name="format">The manifest format. Leave <c>null</c> for default.</param> /// <returns>The generated digest.</returns> /// <exception cref="OperationCanceledException">The user canceled the task.</exception> /// <exception cref="WebException">A file could not be downloaded from the internet.</exception> public static ManifestDigest CalculateDigest(this RetrievalMethod retrievalMethod, ICommandExecutor executor, ITaskHandler handler, ManifestFormat?format = null) { #region Sanity checks if (retrievalMethod == null) { throw new ArgumentNullException(nameof(retrievalMethod)); } if (executor == null) { throw new ArgumentNullException(nameof(executor)); } if (handler == null) { throw new ArgumentNullException(nameof(handler)); } #endregion var builder = new ManifestBuilder(format ?? ManifestFormat.Sha256New); builder.Add(retrievalMethod, executor, handler); var digest = new ManifestDigest(builder.Manifest.CalculateDigest()); if (digest.PartialEquals(ManifestDigest.Empty)) { Log.Warn(Resources.EmptyImplementation); } return(digest); }
public static async Task <int> Main(string[] args) { var options = CommandLineHelper <DeploymentOptions> .FromArgs(args, "HyperFabric", "Commandline parallel deployment tool for service fabric.") .For(o => o.Json).IsRequired("Json string or file path for the manifest.", "-j", "--json") .For(o => o.Loggers).IsOptional( "Comma-separated list of loggers to use e.g. Console, File.", "-l", "--loggers") .WithOptionHandler(new JsonOptionHandler()) .WithOptionHandler(new LoggersOptionHandler()) .Parse(); var exitCode = -1; if (options != null) { var manifestBuilder = new ManifestBuilder(); var manifest = string.IsNullOrWhiteSpace(options.JsonString) ? manifestBuilder.FromFile(options.JsonPath) : manifestBuilder.FromString(options.JsonString); var success = await DeploymentService.RunAsync(manifest, options.LoggerList); exitCode = success ? 0 : -1; } return(exitCode); }
private void PrepareModulesTestDirectories(string testPath, string moduleAPath, string moduleBPath) { if (Directory.Exists(testPath)) { Directory.Delete(testPath, true); } Directory.CreateDirectory(testPath); // compile modules into a.dll / b.dll var compiler = new ModuleCompiler(); compiler.OutputDirectory = moduleAPath; compiler.OutputName = Path.Combine(moduleAPath, "a.dll"); compiler.GenerateModuleFromCode( @"..\Source\Nomad.Tests\FunctionalTests\Data\SimplestModulePossible1.cs"); compiler.OutputDirectory = moduleBPath; compiler.OutputName = Path.Combine(moduleBPath, "b.dll"); compiler.GenerateModuleFromCode( @"..\Source\Nomad.Tests\FunctionalTests\Data\SimplestModulePossible1.cs"); // generate manifests var builder = new ManifestBuilder(@"TEST_ISSUER", KeyFile, @"a.dll", moduleAPath); builder.CreateAndPublish(); builder = new ManifestBuilder(@"TEST_ISSUER", KeyFile, @"b.dll", moduleBPath); builder.CreateAndPublish(); // add spoiling module (assembly without manifest) File.Copy(Path.Combine(moduleAPath, @"a.dll"), Path.Combine(testPath, "c.dll")); }
private Manifest GenerateManifest(string path, string?subdir) { var builder = new ManifestBuilder(_algorithm); if (Directory.Exists(path)) { if (!string.IsNullOrEmpty(subdir)) { throw new OptionException(Resources.TooManyArguments + Environment.NewLine + subdir.EscapeArgument(), null); } Handler.RunTask(new ReadDirectory(path, builder)); return(builder.Manifest); } else if (File.Exists(path)) { var extractor = ArchiveExtractor.For(Archive.GuessMimeType(path), Handler); Handler.RunTask(new ReadFile(path, stream => extractor.Extract(builder, stream, subdir))); return(builder.Manifest); } else { throw new FileNotFoundException(string.Format(Resources.FileOrDirNotFound, path)); } }
protected virtual IValidationManifest GetManifest() { var builder = ManifestBuilder.Create <TValidated>(); ConfigureManifest(builder); return(builder.GetManifest()); }
private static void GenerateManifestUsingApi(string assemblyName, string path) { var builder = new ManifestBuilder(@"TUTORIAL_ISSUER", @"..\..\KEY_FILE.xml", assemblyName, path); builder.CreateAndPublish(); }
public static void DefaultBuid(BuildTarget target) { Setting config = Setting.CreateDefault(target); ManifestBuilder builder = new ManifestBuilder(config); builder.Extension = new ExDataProvider(); builder.Run(); }
/// <inheritdoc/> public void Add(ManifestDigest manifestDigest, Action <IBuilder> build) { #region Sanity checks if (build == null) { throw new ArgumentNullException(nameof(build)); } #endregion if (manifestDigest.AvailableDigests.Any(digest => Directory.Exists(System.IO.Path.Combine(Path, digest)))) { throw new ImplementationAlreadyInStoreException(manifestDigest); } string expectedDigest = manifestDigest.Best ?? throw new NotSupportedException(Resources.NoKnownDigestMethod); Log.Debug($"Storing implementation {expectedDigest} in {this}"); var format = ManifestFormat.FromPrefix(manifestDigest.Best); // Place files in temp directory until digest is verified string tempDir = GetTempDir(); using var _ = new Disposable(() => DeleteTempDir(tempDir)); var builder = new ManifestBuilder(format); build(new DirectoryBuilder(tempDir, builder)); var manifest = ImplementationStoreUtils.Verify(builder.Manifest, expectedDigest); if (manifest == null) { throw new DigestMismatchException( expectedDigest, actualDigest: builder.Manifest.CalculateDigest(), actualManifest: builder.Manifest); } manifest.Save(System.IO.Path.Combine(tempDir, Manifest.ManifestFile)); string target = System.IO.Path.Combine(Path, expectedDigest); lock (_renameLock) // Prevent race-conditions when adding the same digest twice { if (Directory.Exists(target)) { throw new ImplementationAlreadyInStoreException(manifestDigest); } // Move directory to final destination try { Directory.Move(tempDir, target); } catch (IOException ex) when(ex.Message.Contains("already exists") || Directory.Exists(target)) { throw new ImplementationAlreadyInStoreException(manifestDigest); } } // Prevent any further changes to the directory if (UseWriteProtection) { EnableWriteProtection(target); } }
public PropertyEditorResolver(Func <IEnumerable <Type> > typeListProducerList) : base(typeListProducerList, ObjectLifetimeScope.Application) { var builder = new ManifestBuilder( ApplicationContext.Current.ApplicationCache.RuntimeCache, new ManifestParser(new DirectoryInfo(IOHelper.MapPath("~/App_Plugins")), ApplicationContext.Current.ApplicationCache.RuntimeCache)); _unioned = new Lazy <List <PropertyEditor> >(() => Values.Union(builder.PropertyEditors).ToList()); }
public PropertyEditorResolver(IServiceProvider serviceProvider, ILogger logger, Func <IEnumerable <Type> > typeListProducerList, IRuntimeCacheProvider runtimeCache) : base(serviceProvider, logger, typeListProducerList, ObjectLifetimeScope.Application) { var builder = new ManifestBuilder( runtimeCache, new ManifestParser(new DirectoryInfo(IOHelper.MapPath("~/App_Plugins")), runtimeCache)); _unioned = new Lazy <List <PropertyEditor> >(() => Values.Union(builder.PropertyEditors).ToList()); }
private void SignUsedModules() { var builder = new ManifestBuilder(IssuerName, IssuerXmlPath, @"SimplestModulePossible1.dll", @"Modules\Simple\"); builder.CreateAndPublish(); builder = new ManifestBuilder(IssuerName, IssuerXmlPath, @"SimplestModulePossible2.dll", @"Modules\Simple\"); builder.CreateAndPublish(); }
public PackCommand( ClonePackageBuilder clonePackageBuilder, TokenisedPackageBuilder packageTokeniser, ManifestBuilder manifestBuilder, IoHelper ioHelper) { this.clonePackageBuilder = clonePackageBuilder; this.packageTokeniser = packageTokeniser; this.manifestBuilder = manifestBuilder; this.ioHelper = ioHelper; }
public void RandomData_ReturnsSimpleManifest() { var sut = new ManifestBuilder(); var fixture = new Fixture(); var fileData = fixture.Create<byte[]>(); var result = sut.BuildFileManifest(fileData); Assert.IsNotNull(result); Assert.IsEmpty(result.ItemList); }
private static string AddManifestFile() { // generate manifest for SimplestModulePossible file var builder = new ManifestBuilder(IssuerName, IssuerXmlPath, @"SimplestModulePossible1.dll", @"Modules\Simple"); _manifest = builder.CreateAndPublish(); return(@"Modules\Simple\SimplestModulePossible1.dll" + ModuleManifest.ManifestFileNameSuffix); }
public ModuleManifest GenerateManifest(string assemblyFilePath, string folderPath) { // build manifest with this settings KeysGeneratorProgram.Main(new[] { IssuerPath }); var manifestBuilder = new ManifestBuilder(IssuerName, IssuerPath, assemblyFilePath, folderPath, KeyStorage.Nomad, string.Empty, Configuration); return manifestBuilder.Create(); }
public ModuleManifest GenerateManifest(string assemblyFilePath, string folderPath) { // build manifest with this settings KeysGeneratorProgram.Main(new[] { IssuerPath }); var manifestBuilder = new ManifestBuilder(IssuerName, IssuerPath, assemblyFilePath, folderPath, KeyStorage.Nomad, string.Empty, Configuration); return(manifestBuilder.Create()); }
/// <summary> /// Wrapps the generating manifest with values that should be provided. Provides access to <paramref name="configuration"/>. /// </summary> /// <param name="modulePath"></param> /// <param name="keyLocation"></param> /// <param name="configuration"></param> /// <returns></returns> public string GenerateManifestForModule(string modulePath, string keyLocation, ManifestBuilderConfiguration configuration) { string directory = Path.GetFullPath(Path.GetDirectoryName(modulePath)); var builder = new ManifestBuilder("TEST_ISSUER_COMPILER", keyLocation, Path.GetFileName(modulePath), directory, KeyStorage.Nomad, string.Empty, configuration); builder.CreateAndPublish(); return(modulePath + ModuleManifest.ManifestFileNameSuffix); }
public override void OnInspectorGUI() { // Fields serializedObject.Update(); EditorGUILayout.PropertyField(_prefabsPath); EditorGUILayout.PropertyField(_uriPrefix); serializedObject.ApplyModifiedProperties(); // Build button EditorGUILayout.Separator(); if (GUILayout.Button("Build", GUILayout.ExpandWidth(true))) { ManifestBuilder.Build(Target); } }
public void OnGUI() { var manifest = ManifestManager.Manifest; // Begin scroll EditorGUILayout.BeginVertical(); _scrollPos = EditorGUILayout.BeginScrollView(_scrollPos); // Build button if (GUILayout.Button("Build", GUILayout.ExpandWidth(true))) { ManifestBuilder.Build(); } // Filter EditorGUILayout.Separator(); EditorGUILayout.BeginHorizontal(); GUILayout.Label("Filter", EditorStyles.boldLabel, GUILayout.ExpandWidth(false)); EditorGUILayout.BeginVertical(); GUILayout.Space(6); _filter = GUILayout.TextField(_filter, GUILayout.MaxWidth(200)); EditorGUILayout.EndVertical(); EditorGUILayout.EndHorizontal(); // Variants EditorGUILayout.Separator(); GUILayout.Label("Variants", EditorStyles.whiteLargeLabel); ShowVariants(manifest.AllVariants); // Models => View Models EditorGUILayout.Separator(); GUILayout.Label("Models => View Models", EditorStyles.whiteLargeLabel); Labels(manifest.ModelsToViewModels); // View Models => Views EditorGUILayout.Separator(); GUILayout.Label("View Models => Views", EditorStyles.whiteLargeLabel); Labels(manifest.ViewModelsToViews); // Views => Prefabs EditorGUILayout.Separator(); GUILayout.Label("Views => Prefabs", EditorStyles.whiteLargeLabel); Labels(manifest.ViewsToPrefabs); // End scroll EditorGUILayout.EndScrollView(); EditorGUILayout.EndVertical(); }
public override void AddContractNameAttribute(ManifestBuilder mfb, XmlNode node, MetaDataCustomAttribute data, string contractName) { // takes endpoint type as argument if (data.FixedArgs == null || data.FixedArgs.Length != 1) { mfb.Error("ServiceEndpoint attribute must have 1 type argument"); return; } // now make it easy to split into name=value pairs by doing some // string replacing string ctorArgument = "contractName=" + data.FixedArgs[0]; ctorArgument = ctorArgument.Replace("+", " endpointEnd="); ctorArgument = ctorArgument.Replace(", V", " v"); ctorArgument = ctorArgument.Replace(", C", " c"); ctorArgument = ctorArgument.Replace(", P", " p"); ctorArgument = ctorArgument.Replace(",", " assembly="); // now we can split on ' ' and '=' to get name/value pairs string [] endpointConfig = ctorArgument.Split(' '); // grab only the contractName, ignore the rest #if false foreach (string attrib in endpointConfig) { string [] pair = attrib.Split('='); if (pair.Length == 2) { string name = pair[0]; string value = pair[1]; AddAttribute(node, name, value); } } #else string [] pair = endpointConfig[0].Split('='); Debug.Assert(pair.Length == 2); string name = pair[0]; Debug.Assert(name == "contractName"); string value = pair[1]; base.AddContractNameAttribute(mfb, node, data, value); #endif }
public void discovers_all_proper_modules_with_manifests_ignores_others_assemblies() { // make another folder string testPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"IntegrationTests\DirectoryModuleDiscovery2\"); if (Directory.Exists(testPath)) { Directory.Delete(testPath, true); } Directory.CreateDirectory(testPath); // compile modules into a.dll / b.dll var compiler = new ModuleCompiler(); compiler.OutputDirectory = testPath; compiler.OutputName = Path.Combine(testPath, "a.dll"); compiler.GenerateModuleFromCode( @"..\Source\Nomad.Tests\FunctionalTests\Data\SimplestModulePossible1.cs"); compiler.OutputName = Path.Combine(testPath, "b.dll"); compiler.GenerateModuleFromCode( @"..\Source\Nomad.Tests\FunctionalTests\Data\SimplestModulePossible1.cs"); // generate manifests var builder = new ManifestBuilder(@"TEST_ISSUER", KeyFile, @"a.dll", testPath); builder.CreateAndPublish(); builder = new ManifestBuilder(@"TEST_ISSUER", KeyFile, @"b.dll", testPath); builder.CreateAndPublish(); // add spoiling module (assembly without manifest) File.Copy(Path.Combine(testPath, @"a.dll"), Path.Combine(testPath, "c.dll")); var expectedModules = new[] { new ModuleInfo(Path.Combine(testPath, "a.dll")), new ModuleInfo(Path.Combine(testPath, "b.dll")), }; var discovery = new Nomad.Modules.Discovery.DirectoryModuleDiscovery(testPath, SearchOption.TopDirectoryOnly); Assert.That(discovery.GetModules().ToArray(), Is.EquivalentTo(expectedModules), "Discovered modules differ from expected"); }
public async Task <IActionResult> General(GeneralForm generalForm) { if (ModelState.IsValid) { var tasks = new Task[9]; var manifest = new ManifestBuilder { ShortName = generalForm.SiteName, Name = generalForm.SiteName, Icons = new[] { new ManifestBuilder.Icon { Src = "assets/icon.png", Type = "image/png", Sizes = "512x512" } }, ThemeColor = "#FFF", BackgroundColor = "#FFF", GcmSenderId = "103953800507" }; tasks[0] = Task.Run(async() => await _settingsKeeper.AddSettings("SiteName", generalForm.SiteName)); tasks[1] = Task.Run(async() => await _settingsKeeper.AddSettings("SiteDescription", generalForm.SiteDescription)); tasks[2] = Task.Run(async() => await _settingsKeeper.AddSettings("SiteUrl", generalForm.SiteUrl)); tasks[3] = Task.Run(async() => await _settingsKeeper.AddSettings("EnableRegistration", generalForm.EnableRegistration.ToString())); tasks[4] = Task.Run(async() => await _settingsKeeper.AddSettings("NumberOfUpdatesToShow", generalForm.NumberOfUpdatesToShow.ToString())); tasks[5] = Task.Run(async() => await _settingsKeeper.AddSettings("SiteFooterCode", generalForm.SiteFooter ?? string.Empty)); tasks[6] = Task.Run(async() => await _settingsKeeper.AddSettings("SiteSideBar", generalForm.SiteSideBar ?? string.Empty)); tasks[7] = Task.Run(async() => await _settingsKeeper.AddSettings("SiteAboutPage", generalForm.SiteAboutPage ?? string.Empty)); tasks[8] = Task.Run(async() => await manifest.BuildManifest(_webHostEnvironment)); TempData["Error"] = false; await Task.WhenAll(tasks); } else { TempData["Error"] = true; } return(RedirectToAction("General")); }
/// <summary> /// Loads the <see cref="Manifest"/> file in a directory. /// </summary> /// <param name="dirPath">The directory to check for a manifest file.</param> /// <returns>The loaded <see cref="Manifest"/>.</returns> private Manifest LoadManifest(string dirPath) { string manifestPath = Path.Combine(dirPath, Manifest.ManifestFile); if (File.Exists(manifestPath)) { return(Manifest.Load(manifestPath, ManifestFormat.Sha256New)); } else if (Directory.Exists(dirPath) && Directory.GetFileSystemEntries(dirPath).Length != 0) { Log.Info($"No .manifest file found in '{dirPath}'. Assuming directory is clean."); var builder = new ManifestBuilder(ManifestFormat.Sha256New); Handler.RunTask(new ReadDirectory(dirPath, builder)); return(builder.Manifest); } else { return(new Manifest(ManifestFormat.Sha256)); } }
private static void BuildModule() { // some remarkable constancies, we are using sample module from psake build const string issuerName = @"TEST_ISSUER"; const string issuerXmlPath = @"TEST_XML_KEY_FILE.xml"; const string assemblyName = @"Modules\Simple\SimplestModulePossible1.dll"; // get the key file KeysGeneratorProgram.Main(new[] { Path.Combine(FolderPath, issuerXmlPath) }); // get the assembly file into test folder File.Copy(assemblyName, Path.Combine(FolderPath, Path.GetFileName(assemblyName)), true); // NOTE: we are using here default builder configuration for simplicity of the test var manifestBuilder = new ManifestBuilder(issuerName, Path.Combine(FolderPath, issuerXmlPath), Path.GetFileName(assemblyName), FolderPath, KeyStorage.Nomad, string.Empty, ManifestBuilderConfiguration.Default); manifestBuilder.CreateAndPublish(); }
public void ZipFile_ReturnsFileList() { var sut = new ManifestBuilder(); var fixture = new Fixture(); var dataList = fixture.CreateMany<ZipEntryData>(); byte[] zipFileBytes; using(ZipFile file = new ZipFile()) { foreach (var data in dataList) { string fullFileName = data.Directory + "/" + data.FileName; var entry = file.AddEntry(fullFileName, data.FileData); entry.AccessedTime = data.AccessDateTime; entry.CreationTime = data.CreatedDateTime; entry.ModifiedTime = data.ModifiedDateTime; entry.Attributes = data.FileAttributes; } using (var stream = new MemoryStream()) { file.Save(stream); stream.Position = 0; zipFileBytes = TempStreamHelper.ReadAllBytes(stream); } } var result = sut.BuildFileManifest(zipFileBytes); Assert.IsNotNull(result); Assert.IsNotEmpty(result.ItemList); foreach(var data in dataList) { var entry = result.ItemList.SingleOrDefault(i=>i.FileName == data.FileName && i.Directory == data.Directory); Assert.IsNotNull(entry); Assert.AreEqual(data.AccessDateTime.ToUniversalTime(), entry.FileAccessedDateTime.ToUniversalTime()); Assert.AreEqual(data.ModifiedDateTime.ToUniversalTime(), entry.FileModifiedDateTime.ToUniversalTime()); Assert.AreEqual(data.CreatedDateTime.ToUniversalTime(), entry.FileCreatedDateTime.ToUniversalTime()); Assert.AreEqual(data.FileAttributes, entry.Attributes); } }
/// <summary> /// Wrapps the generating manifest with values that should be provided. Provides access to <paramref name="configuration"/>. /// </summary> /// <param name="modulePath"></param> /// <param name="keyLocation"></param> /// <param name="configuration"></param> /// <returns></returns> public string GenerateManifestForModule(string modulePath, string keyLocation, ManifestBuilderConfiguration configuration) { string directory = Path.GetFullPath(Path.GetDirectoryName(modulePath)); var builder = new ManifestBuilder("TEST_ISSUER_COMPILER", keyLocation, Path.GetFileName(modulePath), directory, KeyStorage.Nomad, string.Empty, configuration); builder.CreateAndPublish(); return modulePath + ModuleManifest.ManifestFileNameSuffix; }
private static void BuildModule() { // some remarkable constancies, we are using sample module from psake build const string issuerName = @"TEST_ISSUER"; const string issuerXmlPath = @"TEST_XML_KEY_FILE.xml"; const string assemblyName = @"Modules\Simple\SimplestModulePossible1.dll"; // get the key file KeysGeneratorProgram.Main(new[] { Path.Combine(FolderPath, issuerXmlPath) }); // get the assembly file into test folder File.Copy(assemblyName, Path.Combine(FolderPath, Path.GetFileName(assemblyName)),true); // NOTE: we are using here default builder configuration for simplicity of the test var manifestBuilder = new ManifestBuilder(issuerName, Path.Combine(FolderPath, issuerXmlPath), Path.GetFileName(assemblyName), FolderPath, KeyStorage.Nomad, string.Empty, ManifestBuilderConfiguration.Default); manifestBuilder.CreateAndPublish(); }
private void GetNodeTags( TreeNode parent, ManifestBuilder builder ) { foreach ( TreeNode child in parent.Nodes ) { GetNodeTags( child, builder ); } if ( parent.Tag is RecipeSlotInfo ) { RecipeSlotInfo info = parent.Tag as RecipeSlotInfo; builder.AddSlotInfo( info ); } }
public ParameterEditorResolver(IServiceProvider serviceProvider, ILogger logger, Func <IEnumerable <Type> > typeListProducerList, ManifestBuilder builder) : base(serviceProvider, logger, typeListProducerList, ObjectLifetimeScope.Application) { _builder = builder; _contentSection = UmbracoConfig.For.UmbracoSettings().Content; }
private static string AddManifestFile() { // generate manifest for SimplestModulePossible file var builder = new ManifestBuilder(IssuerName, IssuerXmlPath, @"SimplestModulePossible1.dll", @"Modules\Simple"); _manifest = builder.CreateAndPublish(); return @"Modules\Simple\SimplestModulePossible1.dll" + ModuleManifest.ManifestFileNameSuffix; }
/// <summary> /// Program main code /// </summary> /// <returns>true on success, false on usage due to invalid options</returns> internal static bool MainCode(CommandLineOptions options) { if (options.ShowHelp) { return(false); } // Detect target var target = Locations.SetTarget(options.Target); // Build APK/BAR? if (!string.IsNullOrEmpty(options.PackagePath)) { #if DEBUG //Debugger.Launch(); #endif // Build APK first var apkPath = options.PackagePath; if (target == Targets.BlackBerry) { // Put APK in TEMP folder apkPath = Path.GetTempFileName() + ".apk"; } var apkBuilder = new ApkBuilder.ApkBuilder(apkPath); apkBuilder.MapFilePath = Path.ChangeExtension(options.PackagePath, ".d42map"); apkBuilder.ManifestPath = options.ManifestFile; apkBuilder.DexFiles.AddRange(options.DexFiles); apkBuilder.MapFiles.AddRange(options.MapFiles); if (options.Assemblies.Any()) { apkBuilder.Assemblies.AddRange(options.Assemblies); } apkBuilder.ResourcesFolder = options.ResourcesFolder; apkBuilder.PfxFile = options.PfxFile; apkBuilder.PfxPassword = options.PfxPassword; apkBuilder.CertificateThumbprint = options.CertificateThumbprint; apkBuilder.FreeAppsKeyPath = options.FreeAppsKeyPath; apkBuilder.PackageName = options.PackageName; apkBuilder.NativeCodeLibraries.AddRange(options.NativeCodeLibs); apkBuilder.Build(); if (target == Targets.BlackBerry) { // Now build BAR var barBuilder = new BarBuilder.BarBuilder(options.PackagePath); barBuilder.ApkPath = apkPath; barBuilder.DebugTokenPath = options.DebugToken; barBuilder.Build(); } } else if (!string.IsNullOrEmpty(options.JarFile)) // Import jar file? { var module = new XModule(); var resolver = new AssemblyResolver(options.ReferenceFolders, new AssemblyClassLoader(module.OnClassLoaded), module.OnAssemblyLoaded); var jarImporter = new JarImporter(options.JarFile, options.LibName, options.ImportStubsOnly, false /*true*/, options.GeneratedCodeFolder, resolver, options.ExcludedPackages, options.UseAutoExcludedPackages); foreach (var path in options.References) { jarImporter.ImportAssembly(path); } jarImporter.ImportAssembliesCompleted(); jarImporter.Import(); } else if (options.WcfProxyInputAssemblies.Any()) // Generate WCF Proxy { var resolver = new AssemblyResolver(options.ReferenceFolders, null, null); var readerParameters = new ReaderParameters(ReadingMode.Immediate) { AssemblyResolver = resolver, SymbolReaderProvider = new SafeSymbolReaderProvider(), ReadSymbols = true }; var assemblies = options.WcfProxyInputAssemblies.Select(x => AssemblyDefinition.ReadAssembly(x, readerParameters)).ToList(); var proxyTool = new ProxyBuilderTool(assemblies, options.GeneratedProxySourcePath); proxyTool.Build(); } else { // Create namespace converter var nsConverter = new NameConverter(options.PackageName, options.RootNamespace); // Create manifest file? if (options.CreateManifest) { ManifestBuilder.CreateManifest(target, options.Assemblies.First(), options.ReferenceFolders, options.PackageName, nsConverter, options.DebugInfo, options.AppWidgetProviders, options.TargetSdkVersion, options.OutputFolder); } else { // Code compilation? if (options.Assemblies.Any()) { #if DEBUG //Debugger.Launch(); #endif CompileAssembly(options, nsConverter); } } // Xml compilation if (options.CompileResources) { if (!CompileResources(options)) { return(false); } } } return(true); }
internal PropertyEditorResolver(IServiceProvider serviceProvider, ILogger logger, Func <IEnumerable <Type> > typeListProducerList, ManifestBuilder builder) : base(serviceProvider, logger, typeListProducerList, ObjectLifetimeScope.Application) { _unioned = new Lazy <List <PropertyEditor> >(() => SanitizeNames(Values.Union(builder.PropertyEditors).ToList())); }
protected override bool Execute() { ArrayList codegen = new ArrayList(); ArrayList linker = new ArrayList(); string outfile = _outputManifestPath; string appname = _applicationName; string x86file = _outputNativeExecutablePath; string cacheDirectory = _cacheRootPath; // check all input files ArrayList infiles = new ArrayList(); foreach (ITaskItem assembly in _assemblies) { if (!File.Exists(assembly.ItemSpec)) { LogError(String.Format("Error: Assembly '{0}' not found.", assembly.ItemSpec)); return(false); } infiles.Add(assembly.ItemSpec); } if (!Directory.Exists(cacheDirectory)) { LogError(String.Format("Error: Cache directory '{0}' not found.", cacheDirectory)); return(false); } // This is to work around a bug in ManifestBuilder that causes it to emit paths like // cache="/Apps/..." into manifests, which are later interpreted as absolute paths // by NIB. if (!cacheDirectory.EndsWith("\\")) { cacheDirectory += "\\"; } // initialize the empty app manifest. ManifestBuilder mb = new ManifestBuilder(_cacheRootPath, infiles); string nativeExecutableFullPath; if (!String.IsNullOrEmpty(_outputNativeExecutablePath)) { nativeExecutableFullPath = Path.GetFullPath(_outputNativeExecutablePath); } else { nativeExecutableFullPath = ""; } // create the app manifest if (!mb.CreateNewManifest(appname, nativeExecutableFullPath)) { LogError("An error occurred while generating the manifest."); return(false); } // Add the codegen flags. foreach (string param in codegen) { mb.AddCodegenParameter(param); } // Add the linker flags. foreach (string param in linker) { mb.AddLinkerParameter(param); } // output the xml document: try { using (XmlTextWriter writer = new XmlTextWriter(outfile, System.Text.Encoding.UTF8)) { writer.Formatting = Formatting.Indented; mb.Save(writer); } } catch (Exception ex) { LogError("The manifest file could not be created: " + ex.Message); return(false); } return(true); }
public ModPackInfo(XDocument documentInfo) { string currentDirectory = GetProjectPath().Replace("/", "\\"); if (documentInfo != null) { #region Build AssetBundle Target Array IEnumerable <XElement> bundleTargets = documentInfo.Root.Element("bundles").Elements("bundle"); assetBundleNames = new string[bundleTargets.Count()]; assetNames = new string[bundleTargets.Count()][]; int index = 0; // lmao foreach (var bundle in bundleTargets) { IEnumerable <XElement> assets = bundle.Elements("asset"); int assetIndex = 0; string[] assetArray = new string[assets.Count()]; foreach (var asset in assets) { assetArray[assetIndex] = Path.Combine(currentDirectory, asset.Attribute("path").Value).Replace("\\", "/"); assetIndex++; } assetBundleNames[index] = bundle.Attribute("path").Value; assetNames[index] = assetArray; index++; } #endregion #region Build Material Swap Script if (documentInfo.Root.Element("matswap") != null) { sbuScriptBuilder = new SBUScriptBuilder(documentInfo.Root.Element("matswap")); } #endregion #region Build Manifest Buffer fileName = documentInfo.Root.Element("build").Attribute("name").Value; manifestBuilder = new ManifestBuilder(documentInfo); #endregion #region Build CSV Buffer IEnumerable <XElement> buildLists = documentInfo.Root.Element("build").Elements("list"); csvBuilders = new CSVBuilder[buildLists.Count()]; int csvIndex = 0; foreach (var list in buildLists) { string type = list.Attribute("type").Value; if (CSVBuilder.listTypeInfo.ContainsKey(type)) { if (CSVBuilder.listTypeInfo[type].isStudioMod) { csvBuilders[csvIndex] = new CSVBuilder(type, list.Attribute("path").Value, this); } else { csvBuilders[csvIndex] = new CSVBuilder(type, this); } } else { Debug.LogError(string.Format("Type \"{0}\" is an invalid list category.", type)); } csvBuilders[csvIndex].Generate(list.Elements("item")); csvIndex++; } #endregion } else { Debug.LogError("Invalid XML Document."); } }
protected void SignModule(string name, string path) { var builder = new ManifestBuilder(IssuerName, IssuerXmlPath, name, path); builder.CreateAndPublish(); }
private static void GenerateSongPsarcRS1(Stream output, DLCPackageData info, Platform platform) { var soundBankName = String.Format("Song_{0}", info.Name); try { Stream albumArtStream = null, audioStream = null; string albumArtPath; if (File.Exists(info.AlbumArtPath)) { albumArtPath = info.AlbumArtPath; } else { using (var defaultArtStream = new MemoryStream(Resources.albumart)) { albumArtPath = GeneralExtensions.GetTempFileName(".dds"); defaultArtStream.WriteFile(albumArtPath); defaultArtStream.Dispose(); TMPFILES_ART.Add(albumArtPath); } } var ddsfiles = info.ArtFiles; if (ddsfiles == null) { ddsfiles = new List<DDSConvertedFile>(); ddsfiles.Add(new DDSConvertedFile() { sizeX = 512, sizeY = 512, sourceFile = albumArtPath, destinationFile = GeneralExtensions.GetTempFileName(".dds") }); ToDDS(ddsfiles); // Save for reuse info.ArtFiles = ddsfiles; } albumArtStream = new FileStream(ddsfiles[0].destinationFile, FileMode.Open, FileAccess.Read, FileShare.Read); // AUDIO var audioFile = info.OggPath; if (File.Exists(audioFile)) if (platform.IsConsole != audioFile.GetAudioPlatform().IsConsole) audioStream = OggFile.ConvertAudioPlatform(audioFile); else audioStream = File.OpenRead(audioFile); else throw new InvalidOperationException(String.Format("Audio file '{0}' not found.", audioFile)); using (var aggregateGraphStream = new MemoryStream()) using (var manifestStream = new MemoryStream()) using (var xblockStream = new MemoryStream()) using (var soundbankStream = new MemoryStream()) using (var packageIdStream = new MemoryStream()) using (var soundStream = OggFile.ConvertOgg(audioStream)) using (var arrangementFiles = new DisposableCollection<Stream>()) { var manifestBuilder = new ManifestBuilder { AggregateGraph = new AggregateGraph.AggregateGraph { SoundBank = new SoundBank { File = soundBankName + ".bnk" }, AlbumArt = new AlbumArt { File = info.AlbumArtPath } } }; foreach (var x in info.Arrangements) { //Generate sng file in execution time GenerateSNG(x, platform); manifestBuilder.AggregateGraph.SongFiles.Add(x.SongFile); manifestBuilder.AggregateGraph.SongXMLs.Add(x.SongXml); } manifestBuilder.AggregateGraph.XBlock = new XBlockFile { File = info.Name + ".xblock" }; manifestBuilder.AggregateGraph.Write(info.Name, platform.GetPathName(), platform, aggregateGraphStream); aggregateGraphStream.Flush(); aggregateGraphStream.Seek(0, SeekOrigin.Begin); { var manifestData = manifestBuilder.GenerateManifest(info.Name, info.Arrangements, info.SongInfo, platform); var writer = new StreamWriter(manifestStream); writer.Write(manifestData); writer.Flush(); manifestStream.Seek(0, SeekOrigin.Begin); } GameXblock<Entity>.Generate(info.Name, manifestBuilder.Manifest, manifestBuilder.AggregateGraph, xblockStream); xblockStream.Flush(); xblockStream.Seek(0, SeekOrigin.Begin); var soundFileName = SoundBankGenerator.GenerateSoundBank(info.Name, soundStream, soundbankStream, info.Volume, platform); soundbankStream.Flush(); soundbankStream.Seek(0, SeekOrigin.Begin); GenerateSongPackageId(packageIdStream, info.Name); var songPsarc = new PSARC.PSARC(); songPsarc.AddEntry("PACKAGE_ID", packageIdStream); songPsarc.AddEntry("AggregateGraph.nt", aggregateGraphStream); songPsarc.AddEntry("Manifests/songs.manifest.json", manifestStream); songPsarc.AddEntry(String.Format("Exports/Songs/{0}.xblock", info.Name), xblockStream); songPsarc.AddEntry(String.Format("Audio/{0}/{1}.bnk", platform.GetPathName()[0], soundBankName), soundbankStream); songPsarc.AddEntry(String.Format("Audio/{0}/{1}.ogg", platform.GetPathName()[0], soundFileName), soundStream); songPsarc.AddEntry(String.Format("GRAssets/AlbumArt/{0}.dds", manifestBuilder.AggregateGraph.AlbumArt.Name), albumArtStream); foreach (var x in info.Arrangements) { var xmlFile = File.OpenRead(x.SongXml.File); arrangementFiles.Add(xmlFile); var sngFile = File.OpenRead(x.SongFile.File); arrangementFiles.Add(sngFile); songPsarc.AddEntry(String.Format("GR/Behaviors/Songs/{0}.xml", Path.GetFileNameWithoutExtension(x.SongXml.File)), xmlFile); songPsarc.AddEntry(String.Format("GRExports/{0}/{1}.sng", platform.GetPathName()[1], Path.GetFileNameWithoutExtension(x.SongFile.File)), sngFile); } songPsarc.Write(output, false); output.Flush(); output.Seek(0, SeekOrigin.Begin); } } finally { } }
private void BuildManifest() { theListView.Items.Clear(); ManifestBuilder manifest = new ManifestBuilder(); GetNodeTags( theTreeView.Nodes[ 0 ], manifest ); IList<ManifestItem> items = new List<ManifestItem>(); foreach ( KeyValuePair<long, int> pair in manifest.Items ) { items.Add( new ManifestItem { Item = Db.GetItemName( pair.Key ), Count = pair.Value, } ); } foreach ( ManifestItem item in items.OrderBy( i => i.Item ) ) { ListViewItem viewItem = theListView.Items.Add( item.Item ); viewItem.SubItems.Add( item.Count.ToString() ); } items.Clear(); foreach ( KeyValuePair<long, int> pair in manifest.Components ) { items.Add( new ManifestItem { Item = Db.GetItemName( pair.Key ), Count = pair.Value, } ); } foreach ( ManifestItem item in items.OrderBy( i => i.Item ) ) { ListViewItem viewItem = theListView.Items.Add( item.Item ); viewItem.SubItems.Add( item.Count.ToString() ); viewItem.BackColor = Color.LightPink; } }
/// <summary> /// Create the resolvers /// </summary> protected virtual void InitializeResolvers() { var builder = new ManifestBuilder( ApplicationCache.RuntimeCache, new ManifestParser(new DirectoryInfo(IOHelper.MapPath("~/App_Plugins")), ApplicationCache.RuntimeCache)); PropertyEditorResolver.Current = new PropertyEditorResolver(ServiceProvider, ProfilingLogger.Logger, () => PluginManager.ResolvePropertyEditors(), builder); ParameterEditorResolver.Current = new ParameterEditorResolver(ServiceProvider, ProfilingLogger.Logger, () => PluginManager.ResolveParameterEditors(), builder); //setup the validators resolver with our predefined validators ValidatorsResolver.Current = new ValidatorsResolver( ServiceProvider, ProfilingLogger.Logger, new[] { new Lazy <Type>(() => typeof(RequiredManifestValueValidator)), new Lazy <Type>(() => typeof(RegexValidator)), new Lazy <Type>(() => typeof(DelimitedManifestValueValidator)), new Lazy <Type>(() => typeof(EmailValidator)), new Lazy <Type>(() => typeof(IntegerValidator)), new Lazy <Type>(() => typeof(DecimalValidator)), }); //by default we'll use the db server registrar unless the developer has the legacy // dist calls enabled, in which case we'll use the config server registrar if (UmbracoConfig.For.UmbracoSettings().DistributedCall.Enabled) { ServerRegistrarResolver.Current = new ServerRegistrarResolver(new ConfigServerRegistrar()); } else if ("true".InvariantEquals(ConfigurationManager.AppSettings["umbracoDisableElectionForSingleServer"])) { ServerRegistrarResolver.Current = new ServerRegistrarResolver(new SingleServerRegistrar()); } else { ServerRegistrarResolver.Current = new ServerRegistrarResolver( new DatabaseServerRegistrar( new Lazy <IServerRegistrationService>(() => ApplicationContext.Services.ServerRegistrationService), new DatabaseServerRegistrarOptions())); } //by default we'll use the database server messenger with default options (no callbacks), // this will be overridden in the web startup ServerMessengerResolver.Current = new ServerMessengerResolver( new DatabaseServerMessenger(ApplicationContext, true, new DatabaseServerMessengerOptions())); MappingResolver.Current = new MappingResolver( ServiceProvider, ProfilingLogger.Logger, () => PluginManager.ResolveAssignedMapperTypes()); //RepositoryResolver.Current = new RepositoryResolver( // new RepositoryFactory(ApplicationCache)); CacheRefreshersResolver.Current = new CacheRefreshersResolver( ServiceProvider, ProfilingLogger.Logger, () => PluginManager.ResolveCacheRefreshers()); DataTypesResolver.Current = new DataTypesResolver( ServiceProvider, ProfilingLogger.Logger, () => PluginManager.ResolveDataTypes()); MacroFieldEditorsResolver.Current = new MacroFieldEditorsResolver( ServiceProvider, ProfilingLogger.Logger, () => PluginManager.ResolveMacroRenderings()); PackageActionsResolver.Current = new PackageActionsResolver( ServiceProvider, ProfilingLogger.Logger, () => PluginManager.ResolvePackageActions()); ActionsResolver.Current = new ActionsResolver( ServiceProvider, ProfilingLogger.Logger, () => PluginManager.ResolveActions()); //the database migration objects MigrationResolver.Current = new MigrationResolver( ProfilingLogger.Logger, () => PluginManager.ResolveTypes <IMigration>()); // todo: remove once we drop IPropertyEditorValueConverter support. PropertyEditorValueConvertersResolver.Current = new PropertyEditorValueConvertersResolver( ServiceProvider, ProfilingLogger.Logger, PluginManager.ResolvePropertyEditorValueConverters()); // need to filter out the ones we dont want!! PropertyValueConvertersResolver.Current = new PropertyValueConvertersResolver( ServiceProvider, ProfilingLogger.Logger, PluginManager.ResolveTypes <IPropertyValueConverter>()); // use the new DefaultShortStringHelper ShortStringHelperResolver.Current = new ShortStringHelperResolver( //new LegacyShortStringHelper()); new DefaultShortStringHelper(UmbracoConfig.For.UmbracoSettings()).WithDefaultConfig()); UrlSegmentProviderResolver.Current = new UrlSegmentProviderResolver( ServiceProvider, ProfilingLogger.Logger, typeof(DefaultUrlSegmentProvider)); // by default, no factory is activated PublishedContentModelFactoryResolver.Current = new PublishedContentModelFactoryResolver(); }
private void PrepareModulesTestDirectories(string testPath, string moduleAPath, string moduleBPath) { if (Directory.Exists(testPath)) Directory.Delete(testPath, true); Directory.CreateDirectory(testPath); // compile modules into a.dll / b.dll var compiler = new ModuleCompiler(); compiler.OutputDirectory = moduleAPath; compiler.OutputName = Path.Combine(moduleAPath, "a.dll"); compiler.GenerateModuleFromCode( @"..\Source\Nomad.Tests\FunctionalTests\Data\SimplestModulePossible1.cs"); compiler.OutputDirectory = moduleBPath; compiler.OutputName = Path.Combine(moduleBPath, "b.dll"); compiler.GenerateModuleFromCode( @"..\Source\Nomad.Tests\FunctionalTests\Data\SimplestModulePossible1.cs"); // generate manifests var builder = new ManifestBuilder(@"TEST_ISSUER", KeyFile, @"a.dll", moduleAPath); builder.CreateAndPublish(); builder = new ManifestBuilder(@"TEST_ISSUER", KeyFile, @"b.dll", moduleBPath); builder.CreateAndPublish(); // add spoiling module (assembly without manifest) File.Copy(Path.Combine(moduleAPath, @"a.dll"), Path.Combine(testPath, "c.dll")); }
public void discovers_all_proper_modules_with_manifests_ignores_others_assemblies() { // make another folder string testPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"IntegrationTests\DirectoryModuleDiscovery2\"); if (Directory.Exists(testPath)) Directory.Delete(testPath, true); Directory.CreateDirectory(testPath); // compile modules into a.dll / b.dll var compiler = new ModuleCompiler(); compiler.OutputDirectory = testPath; compiler.OutputName = Path.Combine(testPath, "a.dll"); compiler.GenerateModuleFromCode( @"..\Source\Nomad.Tests\FunctionalTests\Data\SimplestModulePossible1.cs"); compiler.OutputName = Path.Combine(testPath, "b.dll"); compiler.GenerateModuleFromCode( @"..\Source\Nomad.Tests\FunctionalTests\Data\SimplestModulePossible1.cs"); // generate manifests var builder = new ManifestBuilder(@"TEST_ISSUER", KeyFile, @"a.dll", testPath); builder.CreateAndPublish(); builder = new ManifestBuilder(@"TEST_ISSUER", KeyFile, @"b.dll", testPath); builder.CreateAndPublish(); // add spoiling module (assembly without manifest) File.Copy(Path.Combine(testPath, @"a.dll"), Path.Combine(testPath, "c.dll")); var expectedModules = new[] { new ModuleInfo(Path.Combine(testPath, "a.dll")), new ModuleInfo(Path.Combine(testPath, "b.dll")), }; var discovery = new Nomad.Modules.Discovery.DirectoryModuleDiscovery(testPath,SearchOption.TopDirectoryOnly); Assert.That(discovery.GetModules().ToArray(), Is.EquivalentTo(expectedModules), "Discovered modules differ from expected"); }