コード例 #1
0
        internal static int Process(Options options)
        {
            var targetPath = Path.Combine(options.OutputDirectory ?? ".", options.ProjectName);

            if (Directory.Exists(targetPath) == false)
            {
                Directory.CreateDirectory(targetPath);
            }

            var templateZip = (string)null;

            if (string.IsNullOrEmpty(options.TemplatePath))
            {
                templateZip = Path.ChangeExtension(Assembly.GetEntryAssembly().Location, "zip");
            }
            else if (File.Exists(options.TemplatePath))
            {
                templateZip = options.TemplatePath;
            }

            var srcPath = options.TemplatePath;

            if (string.IsNullOrEmpty(templateZip) == false)
            {
                srcPath = PackageUtil.CreateTemporaryDirectory();
                ZipFile.ExtractToDirectory(templateZip, srcPath);
            }

            Console.WriteLine("* BuildGuidMappingTable");
            BuildGuidMappingTable(options, srcPath);

            Console.WriteLine("* Populate");
            Populate(options, srcPath, targetPath);

            if (string.IsNullOrEmpty(templateZip) == false)
            {
                Directory.Delete(srcPath, true);
            }

            Console.WriteLine("* RestorePackage");
            RestorePackages(options, targetPath);

            return(0);
        }
コード例 #2
0
        private static void RestorePackages(Options options, string dstPath)
        {
            foreach (var file in Directory.GetFiles(dstPath, "*.sln", SearchOption.AllDirectories))
            {
                Console.WriteLine("- nuget restore: " + file);
                PackageUtil.RunNuGet("restore", file).Wait();
            }

            foreach (var file in Directory.GetFiles(dstPath, "UnityPackages.json", SearchOption.AllDirectories))
            {
                var dir = Path.GetDirectoryName(file);
                if (Directory.Exists(Path.Combine(dir, "Assets")) == false)
                {
                    continue;
                }

                Console.WriteLine("- uniget restore: " + file);
                PackageUtil.RunUniGet("restore", file, "-o", dir).Wait();
            }
        }