Beispiel #1
0
        public CompareResult CompareVersions(Upset package, DependencyDefinition dependencyDefinition)
        {
            VersionStruct packageVersion    = ParseVersion(package);
            VersionStruct dependencyVersion = ParseVersion(dependencyDefinition);

            return(CompareVersions(packageVersion, dependencyVersion));
        }
Beispiel #2
0
 public void ListPackagesFromDirectoriesTest()
 {
     try
     {
         Directory.CreateDirectory(fr_path);
         string package_dir    = Path.Combine(fr_path, "DirectoryA");
         string no_package_dir = Path.Combine(fr_path, "DirectoryB");
         Directory.CreateDirectory(package_dir);
         Directory.CreateDirectory(no_package_dir);
         string upset_path = Path.Combine(package_dir, "Upset.xml");
         File.Create(upset_path).Dispose();
         Upset test_package = new Upset()
         {
             PackageLicense = "foo",
             PackageName    = "bar",
             PackageVersion = "baz"
         };
         XmlSerializer serializer = new XmlSerializer(typeof(Upset));
         using (FileStream file = new FileStream(upset_path, FileMode.Create))
         {
             serializer.Serialize(file, test_package);
         }
         Upset[] result = fr.ListPackages();
         Assert.AreEqual(1, result.Length);
         Assert.AreEqual("foo", result[0].PackageLicense);
         Assert.AreEqual("bar", result[0].PackageName);
         Assert.AreEqual("baz", result[0].PackageVersion);
     }
     finally
     {
         Directory.Delete(fr_path, true);
     }
 }
Beispiel #3
0
 public void DownloadPackageFromDirectoryTest()
 {
     try
     {
         Directory.CreateDirectory(fr_path);
         string inside_dir  = "InsideDirectory";
         string inside_path = Path.Combine(fr_path, inside_dir);
         Directory.CreateDirectory(inside_path);
         Upset test_package = new Upset()
         {
             PackageLicense = "foo",
             PackageName    = "bar",
             PackageVersion = "baz"
         };
         test_package.MetaInformation.dirName = inside_dir;
         string file_dummy = "Testing.foobar";
         File.Create(Path.Combine(inside_path, file_dummy)).Dispose();
         TemporaryDirectory result = fr.DownloadPackage(test_package);
         Assert.IsTrue(Directory.Exists(result.Path));
         CollectionAssert.Contains(Directory.GetFiles(result.Path).Select(Path.GetFileName).ToArray(), file_dummy);
     }
     finally
     {
         Directory.Delete(fr_path, true);
     }
 }
Beispiel #4
0
        private void GenerateLockfile(LockfileSnapshot snapshot)
        {
            string result = "# UPFILE DEPENDENCIES\n";

            foreach (DependencyDefinition def in snapshot.upfileDependencies)
            {
                result += string.Format("{0} ({1})\n", def.Name, def.Version);
            }

            result += "\n# SOLVED DEPENDENCIES\n";

            foreach (PackageRepo pr in snapshot.installableDependencies)
            {
                Upset package = pr.Package;
                result += string.Format("{0} ({1})\n", package.PackageName, package.PackageVersion);
                if (package.Dependencies != null && package.Dependencies.Length != 0)
                {
                    foreach (DependencyDefinition dependency in package.Dependencies)
                    {
                        result += string.Format("\t{0} ({1})\n", dependency.Name, dependency.Version);
                    }
                }
            }

            using (StreamWriter file = new StreamWriter(lockfilePath, false))
            {
                file.WriteLine(result);
            }
        }
Beispiel #5
0
 private void CheckGUIDConflicts(string sourceDirectory, Upset package)
 {
     foreach (string file in Uplift.Common.FileSystemUtil.RecursivelyListFiles(sourceDirectory))
     {
         if (!file.EndsWith(".meta"))
         {
             continue;
         }
         string guid     = LoadGUID(file);
         string guidPath = AssetDatabase.GUIDToAssetPath(guid);
         if (!string.IsNullOrEmpty(guidPath))
         {
             if (File.Exists(guidPath) || Directory.Exists(guidPath))
             {
                 // the guid is cached and the associated file/directory exists
                 Directory.Delete(sourceDirectory, true);
                 throw new ApplicationException(
                           string.Format(
                               "The guid {0} is already used and tracks {1}. Uplift was trying to import a file with meta at {2} for package {3}. Uplift cannot install this package, please clean your project before trying again.",
                               guid,
                               guidPath,
                               file,
                               package.PackageName
                               )
                           );
             }
             // else, the guid is cached but there are no longer anything linked with it
         }
     }
 }
Beispiel #6
0
 public void DownloadPackageFromUnityPackageTest()
 {
     try
     {
         Directory.CreateDirectory(fr_path);
         Upset test_package = new Upset()
         {
             PackageLicense = "foo",
             PackageName    = "bar",
             PackageVersion = "baz"
         };
         string package_name = "bar-baz.unitypackage";
         test_package.MetaInformation.dirName = package_name;
         string package_path = Helper.GetLocalFilePath(new string[] { "TestData", "FileRepositoryTest", "testpackage.unitypackage" });
         UnityEngine.Debug.Log(package_path);
         File.Copy(package_path, Path.Combine(fr_path, package_name));
         TemporaryDirectory result = fr.DownloadPackage(test_package);
         Assert.IsTrue(Directory.Exists(result.Path));
         string asset_path = Path.Combine(result.Path, "Assets");
         Assert.IsTrue(Directory.Exists(asset_path));
         CollectionAssert.Contains(Directory.GetFiles(asset_path), Path.Combine(asset_path, "TestScript.cs"));
         CollectionAssert.Contains(Directory.GetFiles(asset_path), Path.Combine(asset_path, "TestMat.mat"));
     }
     finally
     {
         Directory.Delete(fr_path, true);
     }
 }
Beispiel #7
0
        private void UpdatePackage(Upset package, TemporaryDirectory td)
        {
            NukePackage(package.PackageName);

            DependencyDefinition definition = Upfile.Instance().Dependencies.First(dep => dep.Name == package.PackageName);

            InstallPackage(package, td, definition, true);
        }
Beispiel #8
0
        public void OnGUI()
        {
            titleContent.text = "Export Utility";

            for (int i = 0; i < packageInfos.Length; i++)
            {
                expanded[i] = EditorGUILayout.Foldout(expanded[i], packageInfos[i].path, true);
                if (expanded[i])
                {
                    packageInfos[i].selected = EditorGUILayout.Toggle("Export?", packageInfos[i].selected);
                    GUI.enabled             = packageInfos[i].selected;
                    packageInfos[i].name    = EditorGUILayout.TextField("Package Name", packageInfos[i].name);
                    packageInfos[i].version = EditorGUILayout.TextField("Package Version", packageInfos[i].version);
                    packageInfos[i].license = EditorGUILayout.TextField("Package License", packageInfos[i].license);
                    GUI.enabled             = true;
                }

                EditorGUILayout.Space();
            }

            if (GUILayout.Button("Export selected packages"))
            {
                foreach (PackageInfo pInfo in packageInfos)
                {
                    if (!pInfo.selected)
                    {
                        continue;
                    }
                    string[] files = System.IO.Directory.GetFiles(pInfo.path, "*.*", System.IO.SearchOption.AllDirectories);
                    string   name  = string.Format(packageFormat, pInfo.name, pInfo.version);

                    // Create Upset file for the package
                    Upset file = new Upset()
                    {
                        UnityVersion = new VersionSpec()
                        {
                            Item = Application.unityVersion
                        },
                        PackageName    = pInfo.name,
                        PackageLicense = pInfo.license,
                        PackageVersion = pInfo.version
                    };

                    XmlSerializer serializer = new XmlSerializer(typeof(Upset));
                    using (FileStream fs = new FileStream(name + ".Upset.xml", FileMode.Create))
                    {
                        using (StreamWriter sw = new StreamWriter(fs, System.Text.Encoding.UTF8))
                        {
                            serializer.Serialize(sw, file);
                        }
                    }

                    // Export .unitypackage
                    AssetDatabase.ExportPackage(files, name + ".unitypackage", ExportPackageOptions.Default);
                }
            }
        }
Beispiel #9
0
        public void UpdatePackage(Upset package, TemporaryDirectory td)
        {
            Upbring upbring = Upbring.Instance();

            // Nuking previous version
            InstalledPackage installedPackage = upbring.GetInstalledPackage(package.PackageName);

            installedPackage.Nuke();

            DependencyDefinition definition = Upfile.Instance().Dependencies.First(dep => dep.Name == package.PackageName);

            InstallPackage(package, td, definition);
        }
Beispiel #10
0
        private void TryUpringAddGUID(Upbring upbring, string file, Upset package, InstallSpecType type, string destination)
        {
            if (file.EndsWith(".meta"))
            {
                return;
            }
            string metaPath = Path.Combine(destination, file + ".meta");

            if (!File.Exists(metaPath))
            {
                upbring.AddLocation(package, type, Path.Combine(destination, file));
                return;
            }
            string guid = LoadGUID(metaPath);

            upbring.AddGUID(package, type, guid);
        }
Beispiel #11
0
        private void UpdatePackage(Upset package, TemporaryDirectory td, bool updateLockfile)
        {
            NukePackage(package.PackageName);

            // First or default returns the first DependencyDefinition which satistfies dep.Name == package.PackageName
            // If no elements meets this condition a Default value for DependencyDefinition is returned which, for our implementation, is null.
            DependencyDefinition definition = Upfile.Instance().Dependencies.FirstOrDefault(dep => dep.Name == package.PackageName);

            if (definition == null)
            {
                definition = new DependencyDefinition()
                {
                    Name = package.PackageName, Version = package.PackageVersion
                };
            }

            InstallPackage(package, td, definition, updateLockfile);
        }
Beispiel #12
0
        protected void WriteUpsetFile(string file)
        {
            var upset = new Upset()
            {
                UnityVersion   = Application.unityVersion,
                PackageName    = exportSpec.packageName,
                PackageLicense = exportSpec.license,
                PackageVersion = exportSpec.packageVersion
            };

            XmlSerializer serializer = new XmlSerializer(typeof(Upset));

            using (FileStream fs = new FileStream(file, FileMode.Create))
            {
                using (StreamWriter sw = new StreamWriter(fs, System.Text.Encoding.UTF8))
                {
                    serializer.Serialize(sw, upset);
                }
            }
        }
        public void GetLatestPackageTest()
        {
            Mock <Repository> repo_mock       = new Mock <Repository>();
            Upset             package_dummy_1 = new Upset();

            package_dummy_1.PackageName    = "package 1";
            package_dummy_1.PackageVersion = "0.0.0";
            Upset package_dummy_2 = new Upset();

            package_dummy_2.PackageName    = "package 1";
            package_dummy_2.PackageVersion = "1.1.1";
            Upset package_dummy_3 = new Upset();

            package_dummy_3.PackageName    = "not package 1";
            package_dummy_3.PackageVersion = "2.0.0";

            repo_mock.Setup(repo => repo.ListPackages()).Returns(new Upset[] { package_dummy_1, package_dummy_2, package_dummy_3 });
            (pl as PackageListTester).SetPackages(new List <PackageRepo>
            {
                new PackageRepo
                {
                    Package    = package_dummy_1,
                    Repository = repo_mock.Object
                },
                new PackageRepo
                {
                    Package    = package_dummy_2,
                    Repository = repo_mock.Object
                },
                new PackageRepo
                {
                    Package    = package_dummy_3,
                    Repository = repo_mock.Object
                }
            });
            PackageRepo result = pl.GetLatestPackage("package 1");

            Assert.AreEqual(new PackageRepo {
                Package = package_dummy_2, Repository = repo_mock.Object
            }, result);
        }
Beispiel #14
0
        public void FilterTest()
        {
            CandidateSelectionStrategy css       = new LatestSelectionStrategy();
            Mock <Repository>          repo_mock = new Mock <Repository>();
            Upset package_A = new Upset();

            package_A.PackageVersion = "0.0.0";
            Upset package_B = new Upset();

            package_B.PackageVersion = "1.1.1";
            PackageRepo pr_A = new PackageRepo {
                Package = package_A, Repository = repo_mock.Object
            };
            PackageRepo pr_B = new PackageRepo {
                Package = package_B, Repository = repo_mock.Object
            };

            PackageRepo[] result = css.Filter(new PackageRepo[] { pr_A, pr_B });

            Assert.AreEqual(result[0], pr_B);
        }
Beispiel #15
0
 public void DownloadPackageFromBadFormatTest()
 {
     try
     {
         Directory.CreateDirectory(fr_path);
         Upset test_package = new Upset()
         {
             PackageLicense = "foo",
             PackageName    = "bar",
             PackageVersion = "baz"
         };
         test_package.MetaInformation.dirName = "Bad.format";
         TemporaryDirectory result = fr.DownloadPackage(test_package);
         Assert.IsTrue(Directory.Exists(result.Path));
         Assert.IsEmpty(Directory.GetFiles(result.Path));
     }
     finally
     {
         Directory.Delete(fr_path, true);
     }
 }
        public void LoadPackagesForceRefreshTest()
        {
            Mock <Repository> repo_mock_A      = new Mock <Repository>();
            Mock <Repository> repo_mock_B      = new Mock <Repository>();
            Mock <Upset>      package_dummy_A1 = new Mock <Upset>();
            Mock <Upset>      package_dummy_A2 = new Mock <Upset>();
            Mock <Upset>      package_dummy_B  = new Mock <Upset>();
            PackageRepo       pr_A1            = new PackageRepo
            {
                Package    = package_dummy_A1.Object,
                Repository = repo_mock_A.Object
            };
            PackageRepo pr_A2 = new PackageRepo
            {
                Package    = package_dummy_A2.Object,
                Repository = repo_mock_A.Object
            };
            PackageRepo pr_B = new PackageRepo
            {
                Package    = package_dummy_B.Object,
                Repository = repo_mock_B.Object
            };

            Upset[] test = new Upset[] { package_dummy_A1.Object, package_dummy_A2.Object };
            repo_mock_A.Setup(repo => repo.ListPackages()).Returns(new Upset[] { package_dummy_A1.Object, package_dummy_A2.Object });
            repo_mock_B.Setup(repo => repo.ListPackages()).Returns(new Upset[] { package_dummy_B.Object });

            (pl as PackageListTester).SetPackages(new List <PackageRepo> {
                pr_B
            });
            (pl as PackageListTester).SetRepositories(new Repository[] { repo_mock_B.Object });

            pl.LoadPackages(new Repository[] { repo_mock_A.Object }, true);
            PackageRepo[] result = pl.GetAllPackages();

            Assert.AreEqual(2, result.Length);
            CollectionAssert.Contains(result, pr_A1);
            CollectionAssert.Contains(result, pr_A2);
            CollectionAssert.DoesNotContain(result, pr_B);
        }
Beispiel #17
0
        public void LoadDependencies(DependencyDefinition dependency, PackageList packageList, DependencyHelper.ConflictChecker checkConflict, out DependencyNode node)
        {
            node = new DependencyNode(dependency);

            if (Contains(dependency.Name))
            {
                DependencyNode existing = FindByName(dependency.Name);
                checkConflict(ref existing, node);
            }
            else
            {
                nodeList.Add(node);

                Upset package = packageList.FindPackageAndRepository(dependency).Package;
                if (package == null)
                {
                    throw new MissingDependencyException(string.Format(" depends on {0} ({1}) but it is not present in any of your specified repository", dependency.Name, dependency.Requirement));
                }

                if (package.Dependencies != null)
                {
                    DependencyNode child;
                    foreach (DependencyDefinition packageDependency in package.Dependencies)
                    {
                        child = null;
                        try
                        {
                            LoadDependencies(packageDependency, packageList, checkConflict, out child);
                            AddDependency(node, child);
                        }
                        catch (MissingDependencyException e)
                        {
                            throw new MissingDependencyException(dependency.Name + e.Message);
                        }
                    }
                }
            }
        }
Beispiel #18
0
        protected void WriteUpsetFile(string file)
        {
            XmlSerializer serializer = new XmlSerializer(typeof(Upset));

            Upset template;

            if (string.IsNullOrEmpty(exportSpec.templateUpsetFile))
            {
                Debug.LogWarning("No template Upset specified, dependencies and configuration will not follow through");
                template = new Upset();
            }
            else
            {
                using (FileStream fs = new FileStream(exportSpec.templateUpsetFile, FileMode.Open))
                {
                    template = serializer.Deserialize(fs) as Upset;
                }
            }

            var upset = new Upset()
            {
                UnityVersion   = Application.unityVersion,
                PackageName    = exportSpec.packageName,
                PackageLicense = exportSpec.license,
                PackageVersion = exportSpec.packageVersion,
                Dependencies   = template.Dependencies,
                Configuration  = template.Configuration
            };

            using (FileStream fs = new FileStream(file, FileMode.Create))
            {
                using (StreamWriter sw = new StreamWriter(fs, System.Text.Encoding.UTF8))
                {
                    serializer.Serialize(sw, upset);
                }
            }
        }
Beispiel #19
0
        //FIXME: This is super unsafe right now, as we can copy down into the FS.
        // This should be contained using kinds of destinations.
        private void InstallPackage(Upset package, TemporaryDirectory td, DependencyDefinition dependencyDefinition, bool updateLockfile = false)
        {
            GitIgnorer VCSHandler = new GitIgnorer();

            using (LogAggregator LA = LogAggregator.InUnity(
                       "Package {0} was successfully installed",
                       "Package {0} was successfully installed but raised warnings",
                       "An error occured while installing package {0}",
                       package.PackageName
                       ))
            {
                Upbring upbring = Upbring.Instance();

                // Note: Full package is ALWAYS copied to the upackages directory right now
                string localPackagePath = GetRepositoryInstallPath(package);
                upbring.AddPackage(package);
                if (!Directory.Exists(localPackagePath))
                {
                    Directory.CreateDirectory(localPackagePath);
                }

                Uplift.Common.FileSystemUtil.CopyDirectory(td.Path, localPackagePath);
                upbring.AddLocation(package, InstallSpecType.Root, localPackagePath);

                VCSHandler.HandleDirectory(upfile.GetPackagesRootPath());

                InstallSpecPath[] specArray;
                if (package.Configuration == null)
                {
                    // If there is no Configuration present we assume
                    // that the whole package is wrapped in "InstallSpecType.Base"
                    InstallSpecPath wrapSpec = new InstallSpecPath
                    {
                        Path = "",
                        Type = InstallSpecType.Base
                    };

                    specArray = new[] { wrapSpec };
                }
                else
                {
                    specArray = package.Configuration;
                }

                foreach (InstallSpecPath spec in specArray)
                {
                    if (dependencyDefinition.SkipInstall != null && dependencyDefinition.SkipInstall.Any(skip => skip.Type == spec.Type))
                    {
                        continue;
                    }

                    var sourcePath = Uplift.Common.FileSystemUtil.JoinPaths(td.Path, spec.Path);

                    PathConfiguration PH = upfile.GetDestinationFor(spec);
                    if (dependencyDefinition.OverrideDestination != null && dependencyDefinition.OverrideDestination.Any(over => over.Type == spec.Type))
                    {
                        PH.Location = Uplift.Common.FileSystemUtil.MakePathOSFriendly(dependencyDefinition.OverrideDestination.First(over => over.Type == spec.Type).Location);
                    }

                    var packageStructurePrefix =
                        PH.SkipPackageStructure ? "" : GetPackageDirectory(package);

                    var destination = Path.Combine(PH.Location, packageStructurePrefix);

                    // Working with single file
                    if (File.Exists(sourcePath))
                    {
                        // Working with singular file
                        if (!Directory.Exists(destination))
                        {
                            Directory.CreateDirectory(destination);
                            VCSHandler.HandleFile(destination);
                        }
                        if (Directory.Exists(destination))
                        { // we are copying a file into a directory
                            destination = System.IO.Path.Combine(destination, System.IO.Path.GetFileName(sourcePath));
                        }
                        File.Copy(sourcePath, destination);
                        Uplift.Common.FileSystemUtil.TryCopyMeta(sourcePath, destination);

                        if (destination.StartsWith("Assets"))
                        {
                            TryUpringAddGUID(upbring, sourcePath, package, spec.Type, destination);
                        }
                        else
                        {
                            upbring.AddLocation(package, spec.Type, destination);
                        }
                    }

                    // Working with directory
                    if (Directory.Exists(sourcePath))
                    {
                        // Working with directory
                        Uplift.Common.FileSystemUtil.CopyDirectoryWithMeta(sourcePath, destination);
                        if (!PH.SkipPackageStructure)
                        {
                            VCSHandler.HandleDirectory(destination);
                        }

                        bool useGuid = destination.StartsWith("Assets");
                        foreach (var file in Uplift.Common.FileSystemUtil.RecursivelyListFiles(sourcePath, true))
                        {
                            if (useGuid)
                            {
                                TryUpringAddGUID(upbring, file, package, spec.Type, destination);
                            }
                            else
                            {
                                upbring.AddLocation(package, spec.Type, Path.Combine(destination, file));
                            }

                            if (PH.SkipPackageStructure)
                            {
                                VCSHandler.HandleFile(Path.Combine(destination, file));
                            }
                        }
                    }
                }

                upbring.SaveFile();

                if (updateLockfile)
                {
                    LockfileSnapshot snapshot = LoadLockfile();
                    int  index;
                    bool found = false;
                    for (index = 0; index < snapshot.installableDependencies.Length; index++)
                    {
                        if (snapshot.installableDependencies[index].Package.PackageName == package.PackageName)
                        {
                            found = true;
                            break;
                        }
                    }
                    if (found)
                    {
                        snapshot.installableDependencies[index].Package = package;
                    }
                    else
                    {
                        Array.Resize <PackageRepo>(ref snapshot.installableDependencies, snapshot.installableDependencies.Length + 1);
                        snapshot.installableDependencies[snapshot.installableDependencies.Length] = new PackageRepo {
                            Package = package
                        };
                    }
                    GenerateLockfile(snapshot);
                }

                td.Dispose();
                UnityHacks.BuildSettingsEnforcer.EnforceAssetSave();
            }
        }
Beispiel #20
0
 public string GetRepositoryInstallPath(Upset package)
 {
     return(Path.Combine(upfile.GetPackagesRootPath(), GetPackageDirectory(package)));
 }
Beispiel #21
0
 public string GetPackageDirectory(Upset package)
 {
     return(package.PackageName + "~" + package.PackageVersion);
 }
Beispiel #22
0
 public VersionStruct ParseVersion(Upset package)
 {
     return(ParseVersion(package.PackageVersion));
 }
Beispiel #23
0
 public bool GreaterThan(Upset package, DependencyDefinition definition)
 {
     return(IsComparisonGreater(CompareVersions(package, definition)));
 }
Beispiel #24
0
        //FIXME: This is super unsafe right now, as we can copy down into the FS.
        // This should be contained using kinds of destinations.
        public void InstallPackage(Upset package, TemporaryDirectory td, DependencyDefinition dependencyDefinition)
        {
            Upbring upbring = Upbring.Instance();
            // Note: Full package is ALWAYS copied to the upackages directory right now
            string localPackagePath = GetRepositoryInstallPath(package);

            upbring.AddPackage(package);
            FileSystemUtil.CopyDirectory(td.Path, localPackagePath);
            upbring.AddLocation(package, InstallSpecType.Root, localPackagePath);

            InstallSpecPath[] specArray;
            if (package.Configuration == null)
            {
                // If there is no Configuration present we assume
                // that the whole package is wrapped in "InstallSpecType.Base"
                InstallSpecPath wrapSpec = new InstallSpecPath
                {
                    Path = "",
                    Type = InstallSpecType.Base
                };

                specArray = new[] { wrapSpec };
            }
            else
            {
                specArray = package.Configuration;
            }

            foreach (InstallSpecPath spec in specArray)
            {
                if (dependencyDefinition.SkipInstall != null && dependencyDefinition.SkipInstall.Any(skip => skip.Type == spec.Type))
                {
                    continue;
                }

                var sourcePath = Uplift.Common.FileSystemUtil.JoinPaths(td.Path, spec.Path);

                PathConfiguration PH = upfile.GetDestinationFor(spec);
                if (dependencyDefinition.OverrideDestination != null && dependencyDefinition.OverrideDestination.Any(over => over.Type == spec.Type))
                {
                    PH.Location = Uplift.Common.FileSystemUtil.MakePathOSFriendly(dependencyDefinition.OverrideDestination.First(over => over.Type == spec.Type).Location);
                }

                var packageStructurePrefix =
                    PH.SkipPackageStructure ? "" : GetPackageDirectory(package);

                var destination = Path.Combine(PH.Location, packageStructurePrefix);

                // Working with single file
                if (File.Exists(sourcePath))
                {
                    // Working with singular file
                    if (!Directory.Exists(destination))
                    {
                        Directory.CreateDirectory(destination);
                    }
                    File.Copy(sourcePath, destination);
                    FileSystemUtil.TryCopyMeta(sourcePath, destination);

                    if (destination.StartsWith("Assets"))
                    {
                        TryUpringAddGUID(upbring, sourcePath, package, spec.Type, destination);
                    }
                    else
                    {
                        upbring.AddLocation(package, spec.Type, destination);
                    }
                }

                // Working with directory
                if (Directory.Exists(sourcePath))
                {
                    // Working with directory
                    Uplift.Common.FileSystemUtil.CopyDirectoryWithMeta(sourcePath, destination);

                    if (destination.StartsWith("Assets"))
                    {
                        foreach (var file in Uplift.Common.FileSystemUtil.RecursivelyListFiles(sourcePath, true))
                        {
                            TryUpringAddGUID(upbring, file, package, spec.Type, destination);
                        }
                    }
                    else
                    {
                        foreach (var file in Uplift.Common.FileSystemUtil.RecursivelyListFiles(sourcePath, true))
                        {
                            upbring.AddLocation(package, spec.Type, Path.Combine(destination, file));
                        }
                    }
                }
            }

            upbring.SaveFile();

            td.Dispose();
        }