Exemple #1
0
        private static int Main(string[] args)
        {
            Console.WriteLine(@"Bootstrapping: " + args[0]);

            var xenkoDir     = Environment.GetEnvironmentVariable("SiliconStudioXenkoDir");
            var xenkoPkgPath = UPath.Combine(xenkoDir, new UFile("Xenko.xkpkg"));

            var session = PackageSession.Load(xenkoPkgPath);

            var generator = TemplateSampleGenerator.Default;

            var logger = new LoggerResult();

            var parameters = new SessionTemplateGeneratorParameters {
                Session = session.Session
            };

            TemplateSampleGenerator.SetDontAskForPlatforms(parameters, true);
            TemplateSampleGenerator.SetPlatforms(parameters, AssetRegistry.SupportedPlatforms.ToList());

            var outputPath = UPath.Combine(new UDirectory(xenkoDir), new UDirectory("samplesGenerated"));

            outputPath = UPath.Combine(outputPath, new UDirectory(args[0]));

            var xenkoTemplates = session.Session.Packages.First().Templates;

            parameters.Description     = xenkoTemplates.First(x => x.Group.StartsWith("Samples") && x.Id == new Guid(args[1]));
            parameters.Name            = args[0];
            parameters.Namespace       = args[0];
            parameters.OutputDirectory = outputPath;
            parameters.Logger          = logger;

            if (!generator.PrepareForRun(parameters))
            {
                logger.Error("PrepareForRun returned false for the TemplateSampleGenerator");
            }

            if (!generator.Run(parameters))
            {
                logger.Error("Run returned false for the TemplateSampleGenerator");
            }

            var updaterTemplate = xenkoTemplates.First(x => x.FullPath.ToString().EndsWith("UpdatePlatforms.xktpl"));

            parameters.Description = updaterTemplate;

            Console.WriteLine(logger.ToText());

            return(logger.HasErrors ? 1 : 0);
        }
Exemple #2
0
        private static PackageSession GenerateSample(UDirectory outputPath, Guid templateGuid, string sampleName, LoggerResult logger)
        {
            // Make output path absolute
            if (!outputPath.IsAbsolute)
            {
                outputPath = UPath.Combine(Environment.CurrentDirectory, outputPath);
            }

            Console.WriteLine(@"Bootstrapping: " + sampleName);

            var session   = new PackageSession();
            var generator = TemplateSampleGenerator.Default;

            // Ensure progress is shown while it is happening.
            logger.MessageLogged += (sender, eventArgs) => Console.WriteLine(eventArgs.Message.Text);

            var parameters = new SessionTemplateGeneratorParameters {
                Session = session
            };

            parameters.Unattended = true;
            TemplateSampleGenerator.SetParameters(
                parameters,
                AssetRegistry.SupportedPlatforms.Where(x => x.Type == Core.PlatformType.Windows).Select(x => new SelectedSolutionPlatform(x, x.Templates.FirstOrDefault())).ToList(),
                addGamesTesting: true);

            session.SolutionPath = UPath.Combine <UFile>(outputPath, sampleName + ".sln");

            // Properly delete previous version
            if (Directory.Exists(outputPath))
            {
                try
                {
                    Directory.Delete(outputPath, true);
                }
                catch (Exception)
                {
                    logger.Warning($"Unable to delete directory [{outputPath}]");
                }
            }

            // Load templates
            StrideDefaultAssetsPlugin.LoadDefaultTemplates();
            var strideTemplates = TemplateManager.FindTemplates(session);

            parameters.Description     = strideTemplates.First(x => x.Id == templateGuid);
            parameters.Name            = sampleName;
            parameters.Namespace       = sampleName;
            parameters.OutputDirectory = outputPath;
            parameters.Logger          = logger;

            if (!generator.PrepareForRun(parameters).Result)
            {
                logger.Error("PrepareForRun returned false for the TemplateSampleGenerator");
            }

            if (!generator.Run(parameters))
            {
                logger.Error("Run returned false for the TemplateSampleGenerator");
            }

            var updaterTemplate = strideTemplates.First(x => x.FullPath.ToString().EndsWith("UpdatePlatforms.sdtpl"));

            parameters.Description = updaterTemplate;

            if (logger.HasErrors)
            {
                throw new InvalidOperationException($"Error generating sample {sampleName} from template:\r\n{logger.ToText()}");
            }

            return(session);
        }
Exemple #3
0
        private static int Main(string[] args)
        {
            if (args.Length < 2)
            {
                Console.WriteLine("Invalid number of arguments.\n");
                Console.WriteLine("Usage: Xenko.SamplesBootstrapper.exe SampleName SampleGuid");
                return(1);
            }

            PackageSessionPublicHelper.FindAndSetMSBuildVersion();

            Console.WriteLine(@"Bootstrapping: " + args[0]);

            var session  = new PackageSession();
            var xenkoPkg = PackageStore.Instance.DefaultPackage;

            Console.WriteLine("Using Xenko from " + xenkoPkg.FullPath + "...");
            var xenkoDir = Path.GetDirectoryName(xenkoPkg.FullPath);

            var generator = TemplateSampleGenerator.Default;

            var logger = new LoggerResult();

            // Ensure progress is shown while it is happening.
            logger.MessageLogged += (sender, eventArgs) => Console.WriteLine(eventArgs.Message.Text);

            var parameters = new SessionTemplateGeneratorParameters {
                Session = session
            };

            parameters.Unattended = true;
            TemplateSampleGenerator.SetParameters(parameters, AssetRegistry.SupportedPlatforms.Select(x => new SelectedSolutionPlatform(x, x.Templates.FirstOrDefault())).ToList());

            var outputPath = UPath.Combine(new UDirectory(xenkoDir), new UDirectory("samplesGenerated"));

            outputPath           = UPath.Combine(outputPath, new UDirectory(args[0]));
            session.SolutionPath = UPath.Combine <UFile>(outputPath, args[0] + ".sln");

            // Properly delete previous version
            if (Directory.Exists(outputPath))
            {
                try
                {
                    Directory.Delete(outputPath, true);
                }
                catch (Exception)
                {
                    logger.Warning($"Unable to delete directory [{outputPath}]");
                }
            }

            var xenkoTemplates = xenkoPkg.Templates;

            parameters.Description     = xenkoTemplates.First(x => x.Id == new Guid(args[1]));
            parameters.Name            = args[0];
            parameters.Namespace       = args[0];
            parameters.OutputDirectory = outputPath;
            parameters.Logger          = logger;

            if (!generator.PrepareForRun(parameters).Result)
            {
                logger.Error("PrepareForRun returned false for the TemplateSampleGenerator");
            }

            if (!generator.Run(parameters))
            {
                logger.Error("Run returned false for the TemplateSampleGenerator");
            }

            var updaterTemplate = xenkoTemplates.First(x => x.FullPath.ToString().EndsWith("UpdatePlatforms.xktpl"));

            parameters.Description = updaterTemplate;

            return(logger.HasErrors ? 1 : 0);
        }
Exemple #4
0
        private static int Main(string[] args)
        {
            if (args.Length < 2)
            {
                Console.WriteLine("Invalid number of arguments.\n");
                Console.WriteLine("Usage: Xenko.SamplesBootstrapper.exe SampleName SampleGuid");
                return(1);
            }

            Console.WriteLine(@"Bootstrapping: " + args[0]);

            // When running the SamplesBootstrapper from within Visual Studio and XenkoDir
            // points to your installation of Xenko and not the development checkout, make sure to override
            // the environment variable properly otherwise it will get the samples from the Xenko installation.
            var xenkoDir     = Environment.GetEnvironmentVariable("XenkoDir");
            var xenkoPkgPath = UPath.Combine(xenkoDir, new UFile("Xenko.xkpkg"));

            Console.WriteLine("Loading " + xenkoPkgPath + "...");
            var session = new PackageSession();

            var xenkoPkg = PackageStore.Instance.DefaultPackage;

            var generator = TemplateSampleGenerator.Default;

            var logger = new LoggerResult();

            // Ensure progress is shown while it is happening.
            logger.MessageLogged += (sender, eventArgs) => Console.WriteLine(eventArgs.Message.Text);

            var parameters = new SessionTemplateGeneratorParameters {
                Session = session
            };

            parameters.Unattended = true;
            TemplateSampleGenerator.SetParameters(parameters, AssetRegistry.SupportedPlatforms.Select(x => new SelectedSolutionPlatform(x, x.Templates.FirstOrDefault())).ToList());

            var outputPath = UPath.Combine(new UDirectory(xenkoDir), new UDirectory("samplesGenerated"));

            outputPath = UPath.Combine(outputPath, new UDirectory(args[0]));

            var xenkoTemplates = xenkoPkg.Templates;

            parameters.Description     = xenkoTemplates.First(x => x.Id == new Guid(args[1]));
            parameters.Name            = args[0];
            parameters.Namespace       = args[0];
            parameters.OutputDirectory = outputPath;
            parameters.Logger          = logger;

            if (!generator.PrepareForRun(parameters).Result)
            {
                logger.Error("PrepareForRun returned false for the TemplateSampleGenerator");
            }

            if (!generator.Run(parameters))
            {
                logger.Error("Run returned false for the TemplateSampleGenerator");
            }

            var updaterTemplate = xenkoTemplates.First(x => x.FullPath.ToString().EndsWith("UpdatePlatforms.xktpl"));

            parameters.Description = updaterTemplate;

            return(logger.HasErrors ? 1 : 0);
        }