Beispiel #1
0
        public static IPackageFile CreatePackageFile(string name)
        {
            var file = new Mock <IPackageFile>();

            file.SetupGet(f => f.Path).Returns(name);
            file.Setup(f => f.GetStream()).Returns(new MemoryStream());

            string effectivePath;
            var    fx = FrameworkNameUtility.ParseNuGetFrameworkFromFilePath(name, out effectivePath);

            file.SetupGet(f => f.EffectivePath).Returns(effectivePath);
            file.SetupGet(f => f.NuGetFramework).Returns(fx);

            return(file.Object);
        }
        protected PackageFileBase(string path)
        {
            Path = path;

            // make sure we switch to the directory char per platform for this check as ParseNuGetFrameworkFromFilePath looks for that
            var nuf = FrameworkNameUtility.ParseNuGetFrameworkFromFilePath(path?.Replace('\\', System.IO.Path.DirectorySeparatorChar), out var effectivePath);

            EffectivePath = effectivePath;

            NuGetFramework = nuf;
            if (nuf != null)
            {
                TargetFramework = new FrameworkName(NuGetFramework.DotNetFrameworkName);
            }
        }
Beispiel #3
0
        internal static bool IsValidFrameworkName(string path)
        {
            NuGetFramework fx;

            try
            {
                string effectivePath;
                fx = FrameworkNameUtility.ParseNuGetFrameworkFromFilePath(path, out effectivePath);
            }
            catch (ArgumentException)
            {
                fx = null;
            }

            // return false if the framework is Null or Unsupported
            return(fx != null && fx.Framework != NuGetFramework.UnsupportedFramework.Framework);
        }
        private static IPackageFile CreatePackageFile(string name)
        {
            var file = new InMemoryFile
            {
                Path   = name,
                Stream = new MemoryStream()
            };

            string effectivePath;
            var    fx = FrameworkNameUtility.ParseNuGetFrameworkFromFilePath(name, out effectivePath);

            file.EffectivePath = effectivePath;
            if (fx != null)
            {
                file.NuGetFramework = fx;
                if (fx.Version.Major < 5)
                {
                    file.TargetFramework = new FrameworkName(fx.DotNetFrameworkName);
                }
            }

            return(file);
        }