Beispiel #1
0
        public static PsDefinition CreateNewNetCoreDefinition(Hashtable desktopData)
        {
            var psData        = new PsData();
            var desktopPsData = desktopData.GetValueAsHashtable("PrivateData").GetValueAsHashtable("PSData");

            if (desktopPsData.Any())
            {
                psData = new PsData
                {
                    Tags         = desktopPsData.GetValueAsStringList("Tags"),
                    LicenseUri   = new Uri(desktopPsData.GetValueAsString("LicenseUri")),
                    ProjectUri   = new Uri(desktopPsData.GetValueAsString("ProjectUri")),
                    ReleaseNotes = String.Empty,
                    Prerelease   = desktopPsData.ContainsKey("Prerelease") ? desktopPsData.GetValueAsString("Prerelease") : null
                };
            }

            var filename         = Path.GetFileNameWithoutExtension(desktopData.GetValueAsString("FilePath"));
            var typesToProcess   = desktopData.GetValueAsStringList("TypesToProcess");
            var formatsToProcess = desktopData.GetValueAsStringList("FormatsToProcess");

            return(new PsDefinition
            {
                ManifestHeader = new PsDefinitionHeader {
                    ModuleName = filename, Author = desktopData.GetValueAsString("Author")
                },
                ModuleVersion = NetCoreModuleVersion,
                CompatiblePsEditions = new List <string> {
                    NetCoreCompatiblePsEdition
                },
                Author = desktopData.GetValueAsString("Author"),
                CompanyName = desktopData.GetValueAsString("CompanyName"),
                Copyright = desktopData.GetValueAsString("Copyright"),
                Description = $"[PowerShell .Net Core] {desktopData.GetValueAsString("Description")}",
                PowerShellVersion = NetCorePsVersion,
                RequiredModules = new List <ModuleReference> {
                    new ModuleReference {
                        ModuleName = "AzureRM.Profile.Netcore", ModuleVersion = NetCoreModuleVersion
                    }
                },
                RequiredAssemblies = desktopData.GetValueAsStringList("RequiredAssemblies"),
                TypesToProcess = typesToProcess.Any() ? typesToProcess : null,
                FormatsToProcess = formatsToProcess.Any() ? formatsToProcess : null,
                NestedModules = desktopData.GetValueAsStringList("NestedModules").Select(m => new ModuleReference {
                    ModuleName = m
                }).ToList(),
                AliasesToExport = desktopData.GetValueAsStringList("AliasesToExport"),
                CmdletsToExport = desktopData.GetValueAsStringList("CmdletsToExport"),
                VariablesToExport = null,
                PrivateData = new PrivateData {
                    PsData = psData
                }
            });
        }
Beispiel #2
0
        public static PsDefinition CreateDefinitionFromExisting(Hashtable existingDefinition, PsDefinitionHeader existingHeader)
        {
            var psData         = new PsData();
            var existingPsData = existingDefinition.GetValueAsHashtable("PrivateData").GetValueAsHashtable("PSData");

            if (existingPsData.Any())
            {
                var licenseUri = existingPsData.GetValueAsStringOrDefault("LicenseUri");
                var projectUri = existingPsData.GetValueAsStringOrDefault("ProjectUri");
                var iconUri    = existingPsData.GetValueAsStringOrDefault("IconUri");
                var requireLicenseAcceptance = existingPsData.GetValueAsStringOrDefault("RequireLicenseAcceptance");
                psData = new PsData
                {
                    Tags                       = existingPsData.GetValueAsStringListOrDefault("Tags"),
                    LicenseUri                 = String.IsNullOrEmpty(licenseUri) ? null : new Uri(licenseUri),
                    ProjectUri                 = String.IsNullOrEmpty(projectUri) ? null : new Uri(projectUri),
                    IconUri                    = String.IsNullOrEmpty(iconUri) ? null : new Uri(iconUri),
                    ReleaseNotes               = existingPsData.GetValueAsStringOrDefault("ReleaseNotes"),
                    Prerelease                 = existingPsData.GetValueAsStringOrDefault("Prerelease"),
                    RequireLicenseAcceptance   = String.IsNullOrEmpty(requireLicenseAcceptance) ? (bool?)null : Boolean.Parse(requireLicenseAcceptance),
                    ExternalModuleDependencies = CreateModuleReferenceList(existingPsData, "ExternalModuleDependencies")
                };
            }

            var processorArchitecture = existingDefinition.GetValueAsStringOrDefault("ProcessorArchitecture");

            return(new PsDefinition
            {
                ManifestHeader = existingHeader,
                RootModule = existingDefinition.GetValueAsStringOrDefault("RootModule"),
                ModuleVersion = existingDefinition.GetValueAsVersionOrDefault("ModuleVersion"),
                CompatiblePsEditions = existingDefinition.GetValueAsStringListOrDefault("CompatiblePSEditions"),
                Guid = Guid.Parse(existingDefinition.GetValueAsStringOrDefault("GUID")),
                Author = existingDefinition.GetValueAsStringOrDefault("Author"),
                CompanyName = existingDefinition.GetValueAsStringOrDefault("CompanyName"),
                Copyright = existingDefinition.GetValueAsStringOrDefault("Copyright"),
                Description = existingDefinition.GetValueAsStringOrDefault("Description"),
                PowerShellVersion = existingDefinition.GetValueAsVersionOrDefault("PowerShellVersion"),
                PowerShellHostName = existingDefinition.GetValueAsStringOrDefault("PowerShellHostName"),
                PowerShellHostVersion = existingDefinition.GetValueAsVersionOrDefault("PowerShellHostVersion"),
                DotNetFrameworkVersion = existingDefinition.GetValueAsVersionOrDefault("DotNetFrameworkVersion"),
                ClrVersion = existingDefinition.GetValueAsVersionOrDefault("CLRVersion"),
                ProcessorArchitecture = processorArchitecture != null?Enum.Parse <ProcessorArchitecture>(processorArchitecture) : (ProcessorArchitecture?)null,
                                            RequiredModules = CreateModuleReferenceList(existingDefinition, "RequiredModules"),
                                            RequiredAssemblies = existingDefinition.GetValueAsStringListOrDefault("RequiredAssemblies"),
                                            ScriptsToProcess = existingDefinition.GetValueAsStringListOrDefault("ScriptsToProcess"),
                                            TypesToProcess = existingDefinition.GetValueAsStringListOrDefault("TypesToProcess"),
                                            FormatsToProcess = existingDefinition.GetValueAsStringListOrDefault("FormatsToProcess"),
                                            NestedModules = existingDefinition.GetValueAsStringListOrDefault("NestedModules")?.Select(m => new ModuleReference
                {
                    ModuleName = m
                }).ToList(),
                                            FunctionsToExport = existingDefinition.GetValueAsStringListOrDefault("FunctionsToExport"),
                                            CmdletsToExport = existingDefinition.GetValueAsStringListOrDefault("CmdletsToExport"),
                                            VariablesToExport = existingDefinition.GetValueAsStringListOrDefault("VariablesToExport"),
                                            AliasesToExport = existingDefinition.GetValueAsStringListOrDefault("AliasesToExport"),
                                            DscResourcesToExport = existingDefinition.GetValueAsStringListOrDefault("DscResourcesToExport"),
                                            ModuleList = CreateModuleReferenceList(existingDefinition, "ModuleList"),
                                            FileList = existingDefinition.GetValueAsStringListOrDefault("FileList"),
                                            PrivateData = new PrivateData {
                    PsData = psData
                },
                HelpInfoUri = existingDefinition.GetValueAsStringOrDefault("HelpInfoURI"),
                DefaultCommandPrefix = existingDefinition.GetValueAsStringOrDefault("DefaultCommandPrefix")
            });
        }