/// <summary>
        /// Gets the trait values from the Category attribute.
        /// </summary>
        /// <param name="traitAttribute">The trait attribute containing the trait values.</param>
        /// <returns>The trait values.</returns>
        public IEnumerable <KeyValuePair <string, string> > GetTraits(IAttributeInfo traitAttribute)
        {
            IEnumerable <object> ctorArgs = traitAttribute.GetConstructorArguments();

            Debug.Assert(ctorArgs.Count() >= 2);

            string                  issue      = ctorArgs.First().ToString();
            TestPlatforms           platforms  = TestPlatforms.Any;
            TargetFrameworkMonikers frameworks = (TargetFrameworkMonikers)0;

            foreach (object arg in ctorArgs.Skip(1)) // First argument is the issue number.
            {
                if (arg is TestPlatforms)
                {
                    platforms = (TestPlatforms)arg;
                }
                else if (arg is TargetFrameworkMonikers)
                {
                    frameworks = (TargetFrameworkMonikers)arg;
                }
            }

            if ((platforms.HasFlag(TestPlatforms.FreeBSD) && RuntimeInformation.IsOSPlatform(OSPlatform.Create("FREEBSD"))) ||
                (platforms.HasFlag(TestPlatforms.Linux) && RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) ||
                (platforms.HasFlag(TestPlatforms.NetBSD) && RuntimeInformation.IsOSPlatform(OSPlatform.Create("NETBSD"))) ||
                (platforms.HasFlag(TestPlatforms.OSX) && RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) ||
                (platforms.HasFlag(TestPlatforms.Windows) && RuntimeInformation.IsOSPlatform(OSPlatform.Windows)))
            {
                if (frameworks.HasFlag(TargetFrameworkMonikers.NetFramework))
                {
                    yield return(new KeyValuePair <string, string>(XunitConstants.Category, XunitConstants.NonNetfxTest));
                }
                if (frameworks.HasFlag(TargetFrameworkMonikers.Mono))
                {
                    yield return(new KeyValuePair <string, string>(XunitConstants.Category, XunitConstants.NonMonoTest));
                }
                if (frameworks.HasFlag(TargetFrameworkMonikers.Netcoreapp))
                {
                    yield return(new KeyValuePair <string, string>(XunitConstants.Category, XunitConstants.NonNetcoreappTest));
                }
                if (frameworks.HasFlag(TargetFrameworkMonikers.UapNotUapAot))
                {
                    yield return(new KeyValuePair <string, string>(XunitConstants.Category, XunitConstants.NonUapTest));
                }
                if (frameworks.HasFlag(TargetFrameworkMonikers.UapAot))
                {
                    yield return(new KeyValuePair <string, string>(XunitConstants.Category, XunitConstants.NonUapAotTest));
                }
                if (frameworks.HasFlag(TargetFrameworkMonikers.NetcoreCoreRT))
                {
                    yield return(new KeyValuePair <string, string>(XunitConstants.Category, XunitConstants.NonNetcoreCoreRTTest));
                }
                if (frameworks == (TargetFrameworkMonikers)0)
                {
                    yield return(new KeyValuePair <string, string>(XunitConstants.Category, XunitConstants.Failing));
                }

                yield return(new KeyValuePair <string, string>(XunitConstants.ActiveIssue, issue));
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Gets the trait values from the Category attribute.
        /// </summary>
        /// <param name="traitAttribute">The trait attribute containing the trait values.</param>
        /// <returns>The trait values.</returns>
        public IEnumerable <KeyValuePair <string, string> > GetTraits(IAttributeInfo traitAttribute)
        {
            TargetFrameworkMonikers frameworks = (TargetFrameworkMonikers)traitAttribute.GetConstructorArguments().First();

            return(DiscovererHelpers.TestFrameworkApplies(frameworks) ?
                   new[] { new KeyValuePair <string, string>(XunitConstants.Category, XunitConstants.Failing) } :
                   Array.Empty <KeyValuePair <string, string> >());
        }
Exemplo n.º 3
0
        /// <summary>
        /// Gets the trait values from the Category attribute.
        /// </summary>
        /// <param name="traitAttribute">The trait attribute containing the trait values.</param>
        /// <returns>The trait values.</returns>
        public IEnumerable <KeyValuePair <string, string> > GetTraits(IAttributeInfo traitAttribute)
        {
            IEnumerable <object> ctorArgs = traitAttribute.GetConstructorArguments();

            Debug.Assert(ctorArgs.Count() >= 2);

            string                  issue      = ctorArgs.First().ToString();
            TestPlatforms           platforms  = TestPlatforms.Any;
            TargetFrameworkMonikers frameworks = TargetFrameworkMonikers.Any;
            TestRuntimes            runtimes   = TestRuntimes.Any;
            Type calleeType = null;

            string[] conditionMemberNames = null;

            foreach (object arg in ctorArgs.Skip(1)) // First argument is the issue number.
            {
                if (arg is TestPlatforms)
                {
                    platforms = (TestPlatforms)arg;
                }
                else if (arg is TargetFrameworkMonikers)
                {
                    frameworks = (TargetFrameworkMonikers)arg;
                }
                else if (arg is TestRuntimes)
                {
                    runtimes = (TestRuntimes)arg;
                }
                else if (arg is Type)
                {
                    calleeType = (Type)arg;
                }
                else if (arg is string[])
                {
                    conditionMemberNames = (string[])arg;
                }
            }

            if (calleeType != null && conditionMemberNames != null)
            {
                if (!DiscovererHelpers.Evaluate(calleeType, conditionMemberNames))
                {
                    yield return(new KeyValuePair <string, string>(XunitConstants.Category, XunitConstants.Failing));
                }
            }
            else if (DiscovererHelpers.TestPlatformApplies(platforms) &&
                     DiscovererHelpers.TestRuntimeApplies(runtimes) &&
                     DiscovererHelpers.TestFrameworkApplies(frameworks))
            {
                yield return(new KeyValuePair <string, string>(XunitConstants.Category, XunitConstants.Failing));
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Gets the trait values from the Category attribute.
        /// </summary>
        /// <param name="traitAttribute">The trait attribute containing the trait values.</param>
        /// <returns>The trait values.</returns>
        public IEnumerable <KeyValuePair <string, string> > GetTraits(IAttributeInfo traitAttribute)
        {
            TargetFrameworkMonikers frameworks = (TargetFrameworkMonikers)traitAttribute.GetConstructorArguments().First();

            if (frameworks.HasFlag(TargetFrameworkMonikers.Netcoreapp))
            {
                yield return(new KeyValuePair <string, string>(XunitConstants.Category, XunitConstants.NonNetcoreappTest));
            }
            if (frameworks.HasFlag(TargetFrameworkMonikers.NetFramework))
            {
                yield return(new KeyValuePair <string, string>(XunitConstants.Category, XunitConstants.NonNetfxTest));
            }
        }
        /// <summary>
        /// Gets the trait values from the Category attribute.
        /// </summary>
        /// <param name="traitAttribute">The trait attribute containing the trait values.</param>
        /// <returns>The trait values.</returns>
        public IEnumerable <KeyValuePair <string, string> > GetTraits(IAttributeInfo traitAttribute)
        {
            TargetFrameworkMonikers platform = (TargetFrameworkMonikers)traitAttribute.GetConstructorArguments().First();

            if (platform.HasFlag(TargetFrameworkMonikers.Net45))
            {
                yield return(new KeyValuePair <string, string>(XunitConstants.Category, XunitConstants.NonNet45Test));
            }
            if (platform.HasFlag(TargetFrameworkMonikers.Net451))
            {
                yield return(new KeyValuePair <string, string>(XunitConstants.Category, XunitConstants.NonNet451Test));
            }
            if (platform.HasFlag(TargetFrameworkMonikers.Net452))
            {
                yield return(new KeyValuePair <string, string>(XunitConstants.Category, XunitConstants.NonNet452Test));
            }
            if (platform.HasFlag(TargetFrameworkMonikers.Net46))
            {
                yield return(new KeyValuePair <string, string>(XunitConstants.Category, XunitConstants.NonNet46Test));
            }
            if (platform.HasFlag(TargetFrameworkMonikers.Net461))
            {
                yield return(new KeyValuePair <string, string>(XunitConstants.Category, XunitConstants.NonNet461Test));
            }
            if (platform.HasFlag(TargetFrameworkMonikers.Net462))
            {
                yield return(new KeyValuePair <string, string>(XunitConstants.Category, XunitConstants.NonNet462Test));
            }
            if (platform.HasFlag(TargetFrameworkMonikers.Net463))
            {
                yield return(new KeyValuePair <string, string>(XunitConstants.Category, XunitConstants.NonNet463Test));
            }
            if (platform.HasFlag(TargetFrameworkMonikers.Netcore50))
            {
                yield return(new KeyValuePair <string, string>(XunitConstants.Category, XunitConstants.NonNetcore50Test));
            }
            if (platform.HasFlag(TargetFrameworkMonikers.Netcore50aot))
            {
                yield return(new KeyValuePair <string, string>(XunitConstants.Category, XunitConstants.NonNetcore50aotTest));
            }
            if (platform.HasFlag(TargetFrameworkMonikers.Netcoreapp1_0))
            {
                yield return(new KeyValuePair <string, string>(XunitConstants.Category, XunitConstants.NonNetcoreapp1_0Test));
            }
            if (platform.HasFlag(TargetFrameworkMonikers.Netcoreapp1_1))
            {
                yield return(new KeyValuePair <string, string>(XunitConstants.Category, XunitConstants.NonNetcoreapp1_1Test));
            }
        }
Exemplo n.º 6
0
        internal static IEnumerable <KeyValuePair <string, string> > EvaluateArguments(IEnumerable <object> ctorArgs, string category, int skipFirst = 1)
        {
            Debug.Assert(ctorArgs.Count() >= 2);

            TestPlatforms           platforms  = TestPlatforms.Any;
            TargetFrameworkMonikers frameworks = TargetFrameworkMonikers.Any;
            TestRuntimes            runtimes   = TestRuntimes.Any;
            Type calleeType = null;

            string[] conditionMemberNames = null;

            foreach (object arg in ctorArgs.Skip(skipFirst)) // First argument is the issue number or reason.
            {
                if (arg is TestPlatforms)
                {
                    platforms = (TestPlatforms)arg;
                }
                else if (arg is TargetFrameworkMonikers)
                {
                    frameworks = (TargetFrameworkMonikers)arg;
                }
                else if (arg is TestRuntimes)
                {
                    runtimes = (TestRuntimes)arg;
                }
                else if (arg is Type)
                {
                    calleeType = (Type)arg;
                }
                else if (arg is string[])
                {
                    conditionMemberNames = (string[])arg;
                }
            }

            if (calleeType != null && conditionMemberNames != null)
            {
                if (DiscovererHelpers.Evaluate(calleeType, conditionMemberNames))
                {
                    yield return(new KeyValuePair <string, string>(XunitConstants.Category, category));
                }
            }
            else if (DiscovererHelpers.TestPlatformApplies(platforms) &&
                     DiscovererHelpers.TestRuntimeApplies(runtimes) &&
                     DiscovererHelpers.TestFrameworkApplies(frameworks))
            {
                yield return(new KeyValuePair <string, string>(XunitConstants.Category, category));
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// Gets the trait values from the Category attribute.
        /// </summary>
        /// <param name="traitAttribute">The trait attribute containing the trait values.</param>
        /// <returns>The trait values.</returns>
        public IEnumerable <KeyValuePair <string, string> > GetTraits(IAttributeInfo traitAttribute)
        {
            IEnumerable <object> ctorArgs = traitAttribute.GetConstructorArguments();

            Debug.Assert(ctorArgs.Count() >= 2);

            string                  issue      = ctorArgs.First().ToString();
            TestPlatforms           platforms  = TestPlatforms.Any;
            TargetFrameworkMonikers frameworks = (TargetFrameworkMonikers)0;

            foreach (object arg in ctorArgs.Skip(1)) // First argument is the issue number.
            {
                if (arg is TestPlatforms)
                {
                    platforms = (TestPlatforms)arg;
                }
                else if (arg is TargetFrameworkMonikers)
                {
                    frameworks = (TargetFrameworkMonikers)arg;
                }
            }

            if (DiscovererHelpers.TestPlatformApplies(platforms))
            {
                if (frameworks.HasFlag(TargetFrameworkMonikers.Netcoreapp))
                {
                    yield return(new KeyValuePair <string, string>(XunitConstants.Category, XunitConstants.NonNetcoreappTest));
                }
                if (frameworks.HasFlag(TargetFrameworkMonikers.NetFramework))
                {
                    yield return(new KeyValuePair <string, string>(XunitConstants.Category, XunitConstants.NonNetfxTest));
                }
                if (frameworks.HasFlag(TargetFrameworkMonikers.Uap))
                {
                    yield return(new KeyValuePair <string, string>(XunitConstants.Category, XunitConstants.NonUapTest));
                }
                if (frameworks.HasFlag(TargetFrameworkMonikers.Mono))
                {
                    yield return(new KeyValuePair <string, string>(XunitConstants.Category, XunitConstants.NonMonoTest));
                }
                if (frameworks == (TargetFrameworkMonikers)0)
                {
                    yield return(new KeyValuePair <string, string>(XunitConstants.Category, XunitConstants.Failing));
                }

                yield return(new KeyValuePair <string, string>(XunitConstants.ActiveIssue, issue));
            }
        }
Exemplo n.º 8
0
        public static ProjectName Create(string name)
        {
            if (name.EndsWith(")"))
            {
                int openParenToken = name.LastIndexOf('(');

                if (openParenToken > 0)
                {
                    string moniker = name.Substring(openParenToken + 1, name.Length - 2 - openParenToken);

                    Debug.Assert(TargetFrameworkMonikers.Contains(moniker), moniker);

                    if (TargetFrameworkMonikers.Contains(moniker))
                    {
                        string nameWithoutMoniker = name.Remove(name.Length - 2 - moniker.Length);

                        return(new ProjectName(name, nameWithoutMoniker, moniker));
                    }
                }
            }

            return(new ProjectName(name));
        }
        private SelectionCriteria GetSelectionCriteria()
        {
            var criteria = new SelectionCriteria();

            criteria.Entries.Add(new SelectionCriteriaEntry
            {
                Properties = new Dictionary <string, object>
                {
                    { "tpm", NuGetFramework.Parse(TargetPlatformMonikers.First()) },
                    { "tfm", NuGetFramework.Parse(TargetFrameworkMonikers.First()) },
                    { "arch", Architecture }
                }
            });

            criteria.Entries.Add(new SelectionCriteriaEntry
            {
                Properties = new Dictionary <string, object>
                {
                    { "tfm", NuGetFramework.Parse(TargetFrameworkMonikers.First()) }
                }
            });

            return(criteria);
        }
Exemplo n.º 10
0
        /// <summary>
        /// Gets the trait values from the Category attribute.
        /// </summary>
        /// <param name="traitAttribute">The trait attribute containing the trait values.</param>
        /// <returns>The trait values.</returns>
        public IEnumerable <KeyValuePair <string, string> > GetTraits(IAttributeInfo traitAttribute)
        {
            IEnumerable <object> ctorArgs = traitAttribute.GetConstructorArguments();

            Debug.Assert(ctorArgs.Count() >= 2);

            string                  issue      = ctorArgs.First().ToString();
            TestPlatforms           platforms  = TestPlatforms.Any;
            TargetFrameworkMonikers frameworks = TargetFrameworkMonikers.Any;
            TestRuntimes            runtimes   = TestRuntimes.Any;

            foreach (object arg in ctorArgs.Skip(1)) // First argument is the issue number.
            {
                if (arg is TestPlatforms)
                {
                    platforms = (TestPlatforms)arg;
                }
                else if (arg is TargetFrameworkMonikers)
                {
                    frameworks = (TargetFrameworkMonikers)arg;
                }
                else if (arg is TestRuntimes)
                {
                    runtimes = (TestRuntimes)arg;
                }
            }

            if (DiscovererHelpers.TestPlatformApplies(platforms) &&
                DiscovererHelpers.TestRuntimeApplies(runtimes) &&
                DiscovererHelpers.TestFrameworkApplies(frameworks))
            {
                return(new[] { new KeyValuePair <string, string>(XunitConstants.Category, XunitConstants.Failing) });
            }

            return(Array.Empty <KeyValuePair <string, string> >());
        }
 public ActiveIssueAttribute(int issueNumber, TestPlatforms platforms = TestPlatforms.Any, TargetFrameworkMonikers framework = (TargetFrameworkMonikers)0)
 {
 }
 public ActiveIssueAttribute(string issue, TestPlatforms platforms = TestPlatforms.Any, TargetFrameworkMonikers framework = (TargetFrameworkMonikers)0)
 {
 }
 public ActiveIssueAttribute(int issueNumber, TargetFrameworkMonikers framework)
 {
 }
 public ActiveIssueAttribute(string issue, TargetFrameworkMonikers framework)
 {
 }
Exemplo n.º 15
0
 public ActiveIssueAttribute(string issue, TestPlatforms platforms = TestPlatforms.Any, TargetFrameworkMonikers framework = TargetFrameworkMonikers.Any, TestRuntimes runtimes = TestRuntimes.Any)
 {
 }
Exemplo n.º 16
0
 public SkipOnTargetFrameworkAttribute(TargetFrameworkMonikers platform, string reason = null)
 {
 }
Exemplo n.º 17
0
        /// <summary>
        /// Gets the trait values from the Category attribute.
        /// </summary>
        /// <param name="traitAttribute">The trait attribute containing the trait values.</param>
        /// <returns>The trait values.</returns>
        public IEnumerable <KeyValuePair <string, string> > GetTraits(IAttributeInfo traitAttribute)
        {
            TargetFrameworkMonikers frameworks = (TargetFrameworkMonikers)traitAttribute.GetConstructorArguments().First();

            if (frameworks.HasFlag(TargetFrameworkMonikers.Net45))
            {
                yield return(new KeyValuePair <string, string>(XunitConstants.Category, XunitConstants.NonNet45Test));
            }
            if (frameworks.HasFlag(TargetFrameworkMonikers.Net451))
            {
                yield return(new KeyValuePair <string, string>(XunitConstants.Category, XunitConstants.NonNet451Test));
            }
            if (frameworks.HasFlag(TargetFrameworkMonikers.Net452))
            {
                yield return(new KeyValuePair <string, string>(XunitConstants.Category, XunitConstants.NonNet452Test));
            }
            if (frameworks.HasFlag(TargetFrameworkMonikers.Net46))
            {
                yield return(new KeyValuePair <string, string>(XunitConstants.Category, XunitConstants.NonNet46Test));
            }
            if (frameworks.HasFlag(TargetFrameworkMonikers.Net461))
            {
                yield return(new KeyValuePair <string, string>(XunitConstants.Category, XunitConstants.NonNet461Test));
            }
            if (frameworks.HasFlag(TargetFrameworkMonikers.Net462))
            {
                yield return(new KeyValuePair <string, string>(XunitConstants.Category, XunitConstants.NonNet462Test));
            }
            if (frameworks.HasFlag(TargetFrameworkMonikers.Net463))
            {
                yield return(new KeyValuePair <string, string>(XunitConstants.Category, XunitConstants.NonNet463Test));
            }
            if (frameworks.HasFlag(TargetFrameworkMonikers.Netcore50))
            {
                yield return(new KeyValuePair <string, string>(XunitConstants.Category, XunitConstants.NonNetcore50Test));
            }
            if (frameworks.HasFlag(TargetFrameworkMonikers.Netcore50aot))
            {
                yield return(new KeyValuePair <string, string>(XunitConstants.Category, XunitConstants.NonNetcore50aotTest));
            }
            if (frameworks.HasFlag(TargetFrameworkMonikers.Netcoreapp1_0))
            {
                yield return(new KeyValuePair <string, string>(XunitConstants.Category, XunitConstants.NonNetcoreapp1_0Test));
            }
            if (frameworks.HasFlag(TargetFrameworkMonikers.Netcoreapp1_1))
            {
                yield return(new KeyValuePair <string, string>(XunitConstants.Category, XunitConstants.NonNetcoreapp1_1Test));
            }
            if (frameworks.HasFlag(TargetFrameworkMonikers.NetFramework))
            {
                yield return(new KeyValuePair <string, string>(XunitConstants.Category, XunitConstants.NonNetfxTest));
            }
            if (frameworks.HasFlag(TargetFrameworkMonikers.Mono))
            {
                yield return(new KeyValuePair <string, string>(XunitConstants.Category, XunitConstants.NonMonoTest));
            }
            if (frameworks.HasFlag(TargetFrameworkMonikers.Netcoreapp))
            {
                yield return(new KeyValuePair <string, string>(XunitConstants.Category, XunitConstants.NonNetcoreappTest));
            }
            if (frameworks.HasFlag(TargetFrameworkMonikers.UapNotUapAot))
            {
                yield return(new KeyValuePair <string, string>(XunitConstants.Category, XunitConstants.NonUapTest));
            }
            if (frameworks.HasFlag(TargetFrameworkMonikers.UapAot))
            {
                yield return(new KeyValuePair <string, string>(XunitConstants.Category, XunitConstants.NonUapAotTest));
            }
            if (frameworks.HasFlag(TargetFrameworkMonikers.NetcoreCoreRT))
            {
                yield return(new KeyValuePair <string, string>(XunitConstants.Category, XunitConstants.NonNetcoreCoreRTTest));
            }
        }
Exemplo n.º 18
0
 public OuterLoopAttribute(string reason, TargetFrameworkMonikers framework)
 {
 }
Exemplo n.º 19
0
 public OuterLoopAttribute(string reason, TestPlatforms platforms = TestPlatforms.Any, TargetFrameworkMonikers framework = TargetFrameworkMonikers.Any, TestRuntimes runtimes = TestRuntimes.Any)
 {
 }
Exemplo n.º 20
0
        /// <summary>
        /// Performs the NuGet package resolution.
        /// </summary>
        public override bool Execute()
        {
            JObject lockFile;

            using (var streamReader = new StreamReader(ProjectLockFile))
            {
                lockFile = JObject.Load(new JsonTextReader(streamReader));
            }

            var targets = (JObject)lockFile["targets"];

            string tfm = TargetFrameworkMonikers.First().Replace(" ", "");
            string rid = "win7";

            if (!String.IsNullOrEmpty(Architecture))
            {
                rid += "-" + Architecture;
            }

            if (UseDotNetNativeToolchain)
            {
                rid += "-aot";
            }

            var target = (JObject)targets[tfm + "/" + rid];

            if (target == null)
            {
                // we don't yet have proper portable support, so fake it for now.
                target = (JObject)targets[tfm];
            }

            if (target == null)
            {
                Log.LogError("Couldn't find the required information in the lock file. Make sure you have {0} in your frameworks list and {1} in your runtimes list.", tfm, rid);
                return(false);
            }

            foreach (var package in target)
            {
                var packageNameParts = package.Key.Split('/');
                var packageName      = packageNameParts[0];
                var packageVersion   = packageNameParts[1];

                Log.LogMessage(MessageImportance.Low, "Resolved references from {0}:", packageName);

                foreach (var referenceItem in CreateItems(packageName, packageVersion, package.Value, "compile"))
                {
                    Log.LogMessage(MessageImportance.Low, "    Build time reference: {0}", referenceItem.ItemSpec);
                    _references.Add(referenceItem);
                }

                foreach (var copyLocalItem in CreateItems(packageName, packageVersion, package.Value, "runtime"))
                {
                    Log.LogMessage(MessageImportance.Low, "    Copy local reference: {0}", copyLocalItem.ItemSpec);
                    _copyLocalItems.Add(copyLocalItem);
                }

                foreach (var copyLocalItem in CreateItems(packageName, packageVersion, package.Value, "native"))
                {
                    Log.LogMessage(MessageImportance.Low, "    Copy local reference: {0}", copyLocalItem.ItemSpec);
                    _copyLocalItems.Add(copyLocalItem);
                }
            }

            return(true);
        }
        /// <summary>
        /// Performs the NuGet package resolution.
        /// </summary>
        public override bool Execute()
        {
            var analyzers      = new List <ITaskItem>();
            var copyLocalItems = new List <ITaskItem>();
            var references     = new List <ITaskItem>();

            var providers = new List <IDependencyProvider>();

            if (!String.IsNullOrEmpty(PackageRoot))
            {
                providers.Add(new NuGetDependencyResolver(PackageRoot));
            }
            else
            {
                // Find and add all our package folders
                var parentDirectory = new DirectoryInfo(Environment.CurrentDirectory);

                while (parentDirectory != null)
                {
                    if (parentDirectory.GetDirectories("packages").Any())
                    {
                        providers.Add(new NuGetDependencyResolver(Path.Combine(parentDirectory.FullName, "packages")));
                    }

                    parentDirectory = parentDirectory.Parent;
                }

                providers.Add(new NuGetDependencyResolver(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".dnx", "packages")));
            }

            providers.Add(new MSBuildDependencyProvider(ProjectFile, NuGetPackageReferences));

            var walker = new DependencyWalker(providers);
            var root   = walker.Walk(ProjectFile, new NuGetVersion(new Version()), NuGetFramework.Parse(TargetFrameworkMonikers.First()));

            root.TryResolveConflicts();

            var resolvedItems = new Dictionary <string, Library>();

            // Pick the relevant versions of the package after conflict
            // resolution
            root.ForEach(true, (node, state) =>
            {
                if (node.Disposition != Disposition.Accepted ||
                    node.Item == null)
                {
                    return(false);
                }

                if (!resolvedItems.ContainsKey(node.Key.Name))
                {
                    resolvedItems[node.Key.Name] = node.Item.Data;
                }

                return(true);
            });

            var patternDefinitions = new PatternDefinitions();

            if (UseDotNetNativeToolchain)
            {
                var directoriesToPrep = new[] { IlcTargetFrameworkPath, IlcTargetFrameworkFacadesPath };
                foreach (var directoryToPrep in directoriesToPrep)
                {
                    var directoryInfoToPrep = new DirectoryInfo(directoryToPrep);
                    directoryInfoToPrep.Create();
                    foreach (var file in directoryInfoToPrep.GetFiles())
                    {
                        file.Delete();
                    }
                }
            }

            foreach (var library in resolvedItems.Values)
            {
                if (library.Identity.Type != LibraryTypes.Package)
                {
                    continue;
                }

                Log.LogMessage(MessageImportance.Low, "Resolved references from {0}:", library.Identity.ToString());

                LoadContents(library);

                var compileTimeReferences     = TryGetTaskItemsFromLibrary(library, patternDefinitions.CompileTimeAssemblies);
                var copyLocalReferences       = TryGetTaskItemsFromLibrary(library, patternDefinitions.ManagedAssemblies) ?? Enumerable.Empty <ITaskItem>();
                var copyLocalNativeReferences = TryGetTaskItemsFromLibrary(library, patternDefinitions.NativeLibraries) ?? Enumerable.Empty <ITaskItem>();
                var itemsInAot = TryGetTaskItemsFromLibrary(library, patternDefinitions.AheadOfTimeAssemblies) ?? Enumerable.Empty <ITaskItem>();

                if (compileTimeReferences == null)
                {
                    // Then the "copy local" references are actually our compile-time references
                    compileTimeReferences = copyLocalReferences;
                }

                if (compileTimeReferences != null)
                {
                    ApplyCompileTimeReferenceMetadata(compileTimeReferences, library);

                    foreach (var compileTimeReference in compileTimeReferences)
                    {
                        Log.LogMessage(MessageImportance.Low, "    Build time reference: {0}", compileTimeReference.ItemSpec);
                        references.Add(compileTimeReference);
                    }
                }

                if (UseDotNetNativeToolchain)
                {
                    var frameworkAotItems = itemsInAot.Any() ? itemsInAot : copyLocalReferences;
                    foreach (var frameworkAotItem in frameworkAotItems)
                    {
                        File.Copy(frameworkAotItem.ItemSpec, Path.Combine(IlcTargetFrameworkFacadesPath, Path.GetFileName(frameworkAotItem.ItemSpec)), overwrite: true);
                    }

                    foreach (var referenceItem in compileTimeReferences)
                    {
                        File.Copy(referenceItem.ItemSpec, Path.Combine(IlcTargetFrameworkPath, Path.GetFileName(referenceItem.ItemSpec)), overwrite: true);
                    }
                }
                else
                {
                    foreach (var copyLocalReference in copyLocalReferences.Concat(copyLocalNativeReferences))
                    {
                        Log.LogMessage(MessageImportance.Low, "    Copy local reference: {0}", copyLocalReference.ItemSpec);
                        copyLocalItems.Add(copyLocalReference);
                    }
                }
            }

            ResolvedAnalyzers      = analyzers.ToArray();
            ResolvedCopyLocalItems = copyLocalItems.ToArray();
            ResolvedReferences     = references.ToArray();

            return(true);
        }
Exemplo n.º 22
0
        (runtimes.HasFlag(TestRuntimes.CoreCLR) && !IsMonoRuntime);         // assume CoreCLR if it's not Mono

        public static bool TestFrameworkApplies(TargetFrameworkMonikers frameworks) =>
        (frameworks.HasFlag(TargetFrameworkMonikers.Netcoreapp) && IsRunningOnNetCoreApp) ||
        (frameworks.HasFlag(TargetFrameworkMonikers.NetFramework) && IsRunningOnNetFramework);
 public SkipOnTargetFrameworkAttribute(TargetFrameworkMonikers platform, string reason = null) { }