Example #1
0
        private void WriteMonolithicModuleFile(string filePath, bool netStandard)
        {
            var fileContents = ManifestFileTemplate.Generate(
                netStandard ? "AWSPowerShell.NetCore" : "AWSPowerShell",
                netStandard ? "AWSPowerShell.NetCore.dll" : "AWSPowerShell.dll",
                netStandard ? AWSPowerShellNetCoreGuid : AWSPowerShellGuid,
                ModuleVersionNumber,
                netStandard ?
                "The AWS Tools for PowerShell lets developers and administrators manage their AWS services from the PowerShell scripting environment." + Environment.NewLine +
                "This version of AWS Tools for PowerShell is compatible with Windows PowerShell 3+ and PowerShell Core 6+ on Windows, Linux and macOS. When running on Windows PowerShell, .NET Framework 4.7.2 or newer is required. An alternative module, AWSPowerShell, provides support for older versions of Windows PowerShell and .NET Framework." + Environment.NewLine +
                "This product provides support for all AWS services in a single module. As an alternative, a modular variant is also available: separate smaller modules (e.g. AWS.Tools.EC2, AWS.Tools.S3...) allow managing each AWS Service." :
                "The AWS Tools for Windows PowerShell lets developers and administrators manage their AWS services from the Windows PowerShell scripting environment." + Environment.NewLine +
                "This version of AWS Tools for Windows PowerShell is compatible with Windows PowerShell 2-5.1. An alternative module, AWSPowerShell.NetCore, provides support for Windows PowerShell 3+ and PowerShell Core 6+ on Windows, Linux and macOS." + Environment.NewLine +
                "This product provides support for all AWS services in a single module. As an alternative, a modular variant is also available: separate smaller modules (e.g. AWS.Tools.EC2, AWS.Tools.S3...) allow managing each AWS Service.",
                compatiblePowerShellVersion: netStandard ? 3 : 2,
                compatibleFrameworkVersion: netStandard ? "4.7.2" : "3.5",
                netStandard: netStandard,
                assemblies: Assemblies.Keys,
                typesToProcessFiles: new string[] { "AWSPowerShell.TypeExtensions.ps1xml" },
                formatsToProcessFiles: new string[] { $"AWSPowerShell{(netStandard ? ".NetCore" : "")}.Format.ps1xml" },
                nestedModulesFiles: new string[] { "AWSPowerShellCompleters.psm1",
                                                   "AWSPowerShellLegacyAliases.psm1" },
                scriptsToProcess: new string[] { "ImportGuard.ps1" },
                fileList: new string[] { $"AWSPowerShell{(netStandard ? ".NetCore" : "")}.dll-Help.xml",
                                         "CHANGELOG.txt" });

            File.WriteAllText(filePath, fileContents);
        }
Example #2
0
        public void WriteCommonModule(IEnumerable <string> commonAdvancedCmdlets, Dictionary <string, HashSet <string> > commonLegacyAliases)
        {
            var projectFile = Path.Combine(AwsPowerShellModuleFolder, AWSPowerShellCommonModuleFilename);

            var fileContents = ManifestFileTemplate.Generate(
                "AWS.Tools.Common",
                "AWS.Tools.Common.dll",
                AWSPowerShellCommonGuid,
                ModuleVersionNumber,
                "The AWS Tools for PowerShell lets developers and administrators manage their AWS services from the PowerShell scripting environment. In order to manage each AWS service, install the corresponding module (e.g. AWS.Tools.EC2, AWS.Tools.S3...)." + Environment.NewLine +
                "The module AWS.Tools.Installer (https://www.powershellgallery.com/packages/AWS.Tools.Installer/) makes it easier to install, update and uninstall the AWS.Tools modules." + Environment.NewLine +
                "This version of AWS Tools for PowerShell is compatible with Windows PowerShell 5.1+ and PowerShell Core 6+ on Windows, Linux and macOS. When running on Windows PowerShell, .NET Framework 4.7.2 or newer is required." + Environment.NewLine +
                "Alternative modules, AWSPowerShell.NetCore and AWSPowerShell, provide support for all AWS services from a single module and also support older versions of Windows PowerShell and .NET Framework.",
                compatiblePowerShellVersion: 5,
                compatiblePowerShellMinorVersion: 1,
                assemblies: AwsToolsCommonSdkAssemblies,
                nestedModulesFiles: new string[] { "AWS.Tools.Common.Completers.psm1",
                                                   "AWS.Tools.Common.Aliases.psm1" },
                fileList: new string[] { "AWS.Tools.Common.dll-Help.xml" },
                scriptsToProcess: new string[] { "ImportGuard.ps1" },
                aliasesToExport: commonLegacyAliases.SelectMany(cmdlet => cmdlet.Value),
                cmdletsToExport: commonAdvancedCmdlets);

            File.WriteAllText(projectFile, fileContents);
        }
Example #3
0
        public void WriteModularManifestFiles(IEnumerable <ConfigModel> services, Dictionary <string, Dictionary <string, string> > legacyAliases)
        {
            foreach (var project in services.GroupBy(service => service.AssemblyName)
                     .Where(project => project.Any((service) => !string.IsNullOrWhiteSpace(service.ServiceModuleGuid))))
            {
                try
                {
                    if (!legacyAliases.TryGetValue(project.Key, out var projectAliases))
                    {
                        projectAliases = new Dictionary <string, string>();
                    }

                    var dependencies = services
                                       .Where(service => !string.IsNullOrWhiteSpace(service.ServiceModuleGuid) &&
                                              project.First().SDKDependencies.Contains(service.AssemblyName))
                                       .ToArray();

                    var mainServiceConfig = project.Single(service => !string.IsNullOrEmpty(service.ServiceModuleGuid));

                    var fileContents = ManifestFileTemplate.Generate(
                        $"AWS.Tools.{project.Key}",
                        $"AWS.Tools.{project.Key}.dll",
                        mainServiceConfig.ServiceModuleGuid,
                        ModuleVersionNumber,
                        $"The {mainServiceConfig.AssemblyName} module of AWS Tools for PowerShell lets developers and administrators manage {mainServiceConfig.ServiceName} from the PowerShell scripting environment. In order to manage each AWS service, install the corresponding module (e.g. AWS.Tools.EC2, AWS.Tools.S3...)." + Environment.NewLine +
                        "The module AWS.Tools.Installer (https://www.powershellgallery.com/packages/AWS.Tools.Installer/) makes it easier to install, update and uninstall the AWS.Tools modules." + Environment.NewLine +
                        "This version of AWS Tools for PowerShell is compatible with Windows PowerShell 5.1+ and PowerShell Core 6+ on Windows, Linux and macOS. When running on Windows PowerShell, .NET Framework 4.7.2 or newer is required. Alternative modules AWSPowerShell.NetCore and AWSPowerShell, provide support for all AWS services from a single module and also support older versions of Windows PowerShell and .NET Framework.",
                        compatiblePowerShellVersion: 5,
                        compatiblePowerShellMinorVersion: 1,
                        assemblies: new string[] { $"AWSSDK.{project.Key}" }.Except(AwsToolsCommonSdkAssemblies),
                        formatsToProcessFiles: new string[] { $"AWS.Tools.{project.Key}.Format.ps1xml" },
                        fileList: new string[] { $"AWS.Tools.{project.Key}.dll-Help.xml" },
                        nestedModulesFiles: new string[] { $"AWS.Tools.{project.Key}.Completers.psm1",
                                                           $"AWS.Tools.{project.Key}.Aliases.psm1" },
                        requiredModules: dependencies
                        .Select(service => new ManifestFileTemplate.DependencyModule($"AWS.Tools.{service.AssemblyName}", service.ServiceModuleGuid))
                        .Concat(new ManifestFileTemplate.DependencyModule[] {
                        new ManifestFileTemplate.DependencyModule("AWS.Tools.Common", AWSPowerShellCommonGuid)
                    }),
                        cmdletsToExport: project
                        .SelectMany(service => service.ServiceOperationsList
                                    .Where(operation => !operation.Exclude))
                        .Select(operation => $"{operation.SelectedVerb}-{operation.SelectedNoun}")
                        .Concat(project
                                .SelectMany(service => service.AdvancedCmdlets.Keys))
                        .OrderBy(name => name),
                        aliasesToExport: projectAliases.Keys);

                    File.WriteAllText(Path.Combine(AwsPowerShellModuleFolder, CmdletGenerator.CmdletsOutputSubFoldername, project.Key, $"AWS.Tools.{project.Key}.psd1"), fileContents);
                }
                catch (Exception e)
                {
                    foreach (var service in project)
                    {
                        AnalysisError.ExceptionWhileWritingServiceProjectFile(service, e);
                    }
                }
            }
        }