private void AddAssets(string key, RuntimeAssetGroup group, ref UnifiedJsonWriter jsonWriter)
        {
            if (group == null || !group.RuntimeFiles.Any())
            {
                return;
            }

            WriteAssetList(key, group.RuntimeFiles, ref jsonWriter);
        }
Ejemplo n.º 2
0
 private void AddAssets(JObject libraryObject, string key, RuntimeAssetGroup group)
 {
     if (group == null || !group.AssetPaths.Any())
     {
         return;
     }
     libraryObject.Add(new JProperty(key,
                                     WriteAssetList(group.AssetPaths))
                       );
 }
Ejemplo n.º 3
0
        private static IEnumerable <RuntimeFile> SelectRuntimeFiles(IEnumerable <string> rids, IEnumerable <RuntimeAssetGroup> groups)
        {
            foreach (string rid in rids)
            {
                RuntimeAssetGroup group = groups.FirstOrDefault(g => g.Runtime == rid);
                if (group != null)
                {
                    return(group.RuntimeFiles);
                }
            }

            // Return the RID-agnostic group
            return(groups.GetDefaultRuntimeFileAssets());
        }
Ejemplo n.º 4
0
        private static bool AddRuntimeSpecificAssetGroups(string assetType, IEnumerable <RuntimeAssetGroup> assetGroups, bool wroteObjectStart, Utf8JsonWriter jsonWriter)
        {
            using IEnumerator <RuntimeAssetGroup> groups = assetGroups.Where(g => !string.IsNullOrEmpty(g.Runtime)).GetEnumerator();

            if (groups.MoveNext())
            {
                if (!wroteObjectStart)
                {
                    jsonWriter.WriteStartObject(DependencyContextStrings.RuntimeTargetsPropertyName);
                    wroteObjectStart = true;
                }

                do
                {
                    RuntimeAssetGroup group = groups.Current;

                    if (group.RuntimeFiles.Count != 0)
                    {
                        AddRuntimeSpecificAssets(group.RuntimeFiles, group.Runtime, assetType, jsonWriter);
                    }
                    else
                    {
                        // Add a placeholder item
                        // We need to generate a pseudo-path because there could be multiple different asset groups with placeholders
                        // Only the last path segment matters, the rest is basically just a GUID.
                        string pseudoPathFolder = assetType == DependencyContextStrings.RuntimeAssetType ?
                                                  "lib" :
                                                  "native";

                        jsonWriter.WriteStartObject($"runtime/{group.Runtime}/{pseudoPathFolder}/_._");
                        jsonWriter.WriteString(DependencyContextStrings.RidPropertyName, group.Runtime);
                        jsonWriter.WriteString(DependencyContextStrings.AssetTypePropertyName, assetType);
                        jsonWriter.WriteEndObject();
                    }
                }while (groups.MoveNext());
            }

            return(wroteObjectStart);
        }