public void ItCanOverrideDefaultValues()
        {
            WorkloadManifest   manifest   = Create("WorkloadManifest.json");
            WorkloadDefinition definition = manifest.Workloads.FirstOrDefault().Value;

            ITaskItem[] resources = new ITaskItem[]
            {
                new TaskItem("microsoft-net-sdk-blazorwebassembly-aot", new Dictionary <string, string> {
                    { "Title", "AOT" },
                    { "Description", "A long wordy description." },
                    { "Category", "Compilers, build tools, and runtimes" }
                })
            };

            VisualStudioComponent component = VisualStudioComponent.Create(null, manifest, definition, "1.2.3.4", NoItems, resources, NoItems);

            string swixProjDirectory = RandomPath;

            Directory.CreateDirectory(swixProjDirectory);
            component.Generate(swixProjDirectory);

            string componentResSwr = File.ReadAllText(Path.Combine(swixProjDirectory, "component.res.swr"));

            Assert.Contains(@"title=""AOT""", componentResSwr);
            Assert.Contains(@"description=""A long wordy description.""", componentResSwr);
            Assert.Contains(@"category=""Compilers, build tools, and runtimes""", componentResSwr);
        }
        /// <summary>
        /// Extracts the workload manifest from the manifest package and generate a SWIX project for a Visual Studio component
        /// matching the manifests dependencies.
        /// </summary>
        /// <param name="workloadManifestPackage">The path of the workload package containing the manifest.</param>
        /// <returns>A set of items containing the generated SWIX projects.</returns>
        internal IEnumerable <ITaskItem> ProcessWorkloadManifest(string workloadManifestPackage)
        {
            NugetPackage workloadPackage = new(workloadManifestPackage, Log);

            string packageContentPath = Path.Combine(PackageDirectory, $"{workloadPackage.Identity}");

            workloadPackage.Extract(packageContentPath, Enumerable.Empty <string>());
            string workloadManifestJsonPath = Directory.GetFiles(packageContentPath, "WorkloadManifest.json").FirstOrDefault();

            if (string.IsNullOrWhiteSpace(workloadManifestJsonPath))
            {
                throw new FileNotFoundException($"Unable to locate WorkloadManifest.json under '{packageContentPath}'.");
            }

            WorkloadManifest manifest = WorkloadManifestReader.ReadWorkloadManifest(File.OpenRead(workloadManifestJsonPath));

            List <TaskItem> swixProjects = new();

            foreach (WorkloadDefinition workloadDefinition in manifest.Workloads.Values)
            {
                VisualStudioComponent component = VisualStudioComponent.Create(manifest, workloadDefinition);
                swixProjects.Add(component.Generate(Path.Combine(SourceDirectory, $"{workloadDefinition.Id}.{manifest.Version}.0")));
            }

            return(swixProjects);
        }
        public void ItCreatesSafeComponentIds()
        {
            WorkloadManifest      manifest   = Create("WorkloadManifest.json");
            WorkloadDefinition    definition = manifest.Workloads.FirstOrDefault().Value;
            VisualStudioComponent component  = VisualStudioComponent.Create(null, manifest, definition, "1.2.3.4", NoItems, NoItems, NoItems);

            string swixProjDirectory = RandomPath;

            Directory.CreateDirectory(swixProjDirectory);
            component.Generate(swixProjDirectory);

            string componentSwr = File.ReadAllText(Path.Combine(swixProjDirectory, "component.swr"));

            Assert.Contains(@"microsoft.net.sdk.blazorwebassembly.aot", componentSwr);
        }
Example #4
0
        public void ItCreatesComponentsWhenWorkloadsDoNotIncludePacks()
        {
            WorkloadManifest      manifest   = Create("mauiWorkloadManifest.json");
            WorkloadDefinition    definition = (WorkloadDefinition)manifest.Workloads.FirstOrDefault().Value;
            VisualStudioComponent component  = VisualStudioComponent.Create(null, manifest, definition, NoItems, NoItems, NoItems, NoItems);

            string swixProjDirectory = RandomPath;

            Directory.CreateDirectory(swixProjDirectory);
            component.Generate(swixProjDirectory);

            string componentSwr = File.ReadAllText(Path.Combine(swixProjDirectory, "component.swr"));

            Assert.Contains(@"vs.dependency id=maui.mobile", componentSwr);
            Assert.Contains(@"vs.dependency id=maui.desktop", componentSwr);
        }
        public void ItAssignsDefaultValues()
        {
            WorkloadManifest      manifest   = Create("WorkloadManifest.json");
            WorkloadDefinition    definition = manifest.Workloads.FirstOrDefault().Value;
            VisualStudioComponent component  = VisualStudioComponent.Create(null, manifest, definition, "1.2.3.4", NoItems, NoItems, NoItems);

            string swixProjDirectory = RandomPath;

            Directory.CreateDirectory(swixProjDirectory);
            component.Generate(swixProjDirectory);

            string componentResSwr = File.ReadAllText(Path.Combine(swixProjDirectory, "component.res.swr"));

            Assert.Contains(@"title=""Blazor WebAssembly AOT workload""", componentResSwr);
            Assert.Contains(@"description=""Blazor WebAssembly AOT workload""", componentResSwr);
            Assert.Contains(@"category="".NET""", componentResSwr);
        }