Exemple #1
0
        public Version GetPackageVersionForAssemblyVersion(Version assemblyVersion)
        {
            Version packageVersion = null;

            if (assemblyVersion != null)
            {
                // prefer an explicit mapping
                if (!AssemblyVersionInPackageVersion.TryGetValue(assemblyVersion, out packageVersion))
                {
                    // if not found assume 1:1 with assembly version
                    packageVersion = VersionUtility.As3PartVersion(assemblyVersion);
                }
            }

            return(packageVersion);
        }
Exemple #2
0
        public void AddAssemblyVersionInPackage(Version assemblyVersion, Version packageVersion)
        {
            Version existingPackageVersion;

            if (AssemblyVersionInPackageVersion.TryGetValue(assemblyVersion, out existingPackageVersion))
            {
                bool existingStable = StableVersions.Contains(existingPackageVersion);
                bool updateStable   = StableVersions.Contains(packageVersion);

                // always prefer a stable package over unstable package
                // use the highest unstable package version
                // use the lowest stable package version
                if ((updateStable && !existingStable) ||                                           // update to stable from unstable
                    (updateStable && existingStable && packageVersion < existingPackageVersion) || // update to lower stable
                    (!updateStable && !existingStable && packageVersion > existingPackageVersion)) // update to higher non-stable version
                {
                    AssemblyVersionInPackageVersion[assemblyVersion] = packageVersion;
                }
            }
            else
            {
                AssemblyVersionInPackageVersion[assemblyVersion] = packageVersion;
            }
        }