Example #1
0
        public void AddSkills()
        {
            // Simple skill, no slots
            _skillManifests.Add(ManifestUtilities.CreateSkill(
                                    "testskill",
                                    "testskill",
                                    "https://testskill.tempuri.org/api/skill",
                                    "testSkill/testAction"));

            // Simple skill, with one slot (param1)
            var slots = new List <Slot>();

            slots.Add(new Slot("param1", new List <string>()
            {
                "string"
            }));
            _skillManifests.Add(ManifestUtilities.CreateSkill(
                                    "testskillwithslots",
                                    "testskillwithslots",
                                    "https://testskillwithslots.tempuri.org/api/skill",
                                    "testSkill/testActionWithSlots",
                                    slots));

            // Simple skill, with two actions and multiple slots
            var multiParamSlots = new List <Slot>();

            multiParamSlots.Add(new Slot("param1", new List <string>()
            {
                "string"
            }));
            multiParamSlots.Add(new Slot("param2", new List <string>()
            {
                "string"
            }));
            multiParamSlots.Add(new Slot("param3", new List <string>()
            {
                "string"
            }));

            var multiActionSkill = ManifestUtilities.CreateSkill(
                "testskillwithmultipleactionsandslots",
                "testskillwithmultipleactionsandslots",
                "https://testskillwithslots.tempuri.org/api/skill",
                "testSkill/testAction1",
                multiParamSlots);

            multiActionSkill.Actions.Add(ManifestUtilities.CreateAction("testSkill/testAction2", multiParamSlots));
            _skillManifests.Add(multiActionSkill);

            // Each Skill has a number of actions, these actions are added as their own SkillDialog enabling
            // the SkillDialog to know which action is invoked and identify the slots as appropriate.
            foreach (var skill in _skillManifests)
            {
                Dialogs.Add(new SkillDialogTest(skill, _mockServiceClientCredentials, _mockTelemetryClient, UserState, _mockSkillTransport));
            }
        }
        private void ProcessManifest(ITaskItem taskItem, SwitchParser projectDefaultSettings)
        {
            // save the manifest folder - paths within the manifest will be relative to it
            // if there are no InputFolder or OutputFolder values
            var manifestFolder       = Path.GetDirectoryName(taskItem.ItemSpec);
            var manifestModifiedTime = File.GetLastWriteTimeUtc(taskItem.ItemSpec);

            // process the XML file into objects
            Manifest manifest = null;

            try
            {
                // read the manifest in
                manifest = ManifestUtilities.ReadManifestFile(taskItem.ItemSpec);

                // if an input folder was specified and it exists, use that as the root
                // for all input files. Otherwise use the manifest folder path.
                var inputFolder = (this.InputFolder.IsNullOrWhiteSpace() || !Directory.Exists(this.InputFolder))
                    ? manifestFolder
                    : this.InputFolder;

                // validate and normalize all paths.
                manifest.ValidateAndNormalize(inputFolder, this.OutputFolder, this.ThrowInputMissingErrors);
            }
            catch (FileNotFoundException ex)
            {
                Log.LogError(ex.Message + ex.FileName.IfNotNull(s => " " + s).IfNullOrWhiteSpace(string.Empty));
            }
            catch (XmlException ex)
            {
                Log.LogError(ex.Message);
            }

            if (manifest != null)
            {
                // create the default settings for this configuration, if there are any, based on
                // the project default settings.
                var defaultSettings = ParseConfigSettings(manifest.GetConfigArguments(this.Configuration), projectDefaultSettings);

                // for each output group
                foreach (var outputGroup in manifest.Outputs)
                {
                    // get the file info for the output file. It should already be normalized.
                    var outputFileInfo = new FileInfo(outputGroup.Path);

                    // the symbol map is an OPTIONAL output, so if we don't want one, we ignore it.
                    // but if we do, we need to check for its existence and filetimes, just like
                    // the regular output file
                    var symbolsFileInfo = outputGroup.SymbolMap.IfNotNull(sm => new FileInfo(sm.Path));

                    ProcessOutputGroup(outputGroup, outputFileInfo, symbolsFileInfo, defaultSettings, manifestModifiedTime);
                }
            }
        }
        public void AddSkillManifest()
        {
            // Simple skill, no slots
            _skillManifest = ManifestUtilities.CreateSkill(
                "testSkill",
                "testSkill",
                "https://testskill.tempuri.org/api/skill",
                "testSkill/testAction");

            // Add the SkillDialog to the available dialogs passing the initialized FakeSkill
            Dialogs.Add(new SkillDialogTest(
                            _skillManifest,
                            _mockServiceClientCredentials,
                            _mockTelemetryClient,
                            UserState,
                            _mockSkillTransport));
        }
Example #4
0
        public static int Execute(CreateLocalLayerOptions opts)
        {
            Console.WriteLine($"Creating runtime package store from manifest: {opts.Manifest}");

            if (opts.EnableOptimization)
            {
                if (!RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
                {
                    throw new Exception($"Package optimization is only possible on Amazon Linux. To use this feature execute the command in an Amazon Linux environment.");
                }
                else
                {
                    Console.WriteLine("Warning: Package optimization has been enabled. Be sure to run this on an Amazon Linux environment or the optimization might not be compatbile with the Lambda runtime.");
                }
            }

            if (!File.Exists(opts.Manifest))
            {
                throw new Exception($"Can not find package manifest {opts.Manifest}. Make sure to point to a file not a directory.");
            }

            var tempDirectoryName = $"{opts.StoreName}-{DateTime.UtcNow.Ticks}".ToLower();

            var tempRootPath         = Path.Combine(Path.GetTempPath(), tempDirectoryName);
            var storeOutputDirectory = Path.Combine(tempRootPath, Common.Constants.DEFAULT_LAYER_OPT_DIRECTORY);

            var convertResult = ManifestUtilities.ConvertManifestToSdkManifest(opts.Manifest);

            if (convertResult.ShouldDelete)
            {
                Console.WriteLine("Converted ASP.NET Core project file to temporary package manifest file.");
            }

            var cliWrapper  = new LambdaDotNetCLIWrapper(Directory.GetCurrentDirectory());
            var storeResult = cliWrapper.Store(
                !string.IsNullOrEmpty(opts.ProjectLocation) ? opts.ProjectLocation : Directory.GetCurrentDirectory(),
                storeOutputDirectory,
                opts.TargetFramework,
                convertResult.PackageManifest,
                opts.EnableOptimization);

            if (storeResult.exitCode != 0)
            {
                throw new Exception($"Error executing the 'dotnet store' command");
            }

            var manifest = ProjectUtilities.FindArtifactOutput(storeResult.filePath);

            //string[] files = Directory.GetFiles(storeResult.filePath, "artifact.xml", SearchOption.AllDirectories);

            var updatedContent = File.ReadAllText(manifest);
            var manifestPath   = Path.Combine(Directory.GetCurrentDirectory(), $"{opts.StoreName}.xml");

            File.WriteAllText(manifestPath, updatedContent);

            Console.WriteLine($"Created package manifest file ({manifestPath})");

            if (convertResult.ShouldDelete)
            {
                File.Delete(convertResult.PackageManifest);
            }

            var zipPath = Path.Combine(Directory.GetCurrentDirectory(), $"{opts.StoreName}.zip");

            if (File.Exists(zipPath))
            {
                File.Delete(zipPath);
            }

            LambdaPackager.BundleDirectory(zipPath, tempRootPath, false);

            return(0);
        }