public async Task AddOrUpdatePackageReferenceAsync(LibraryDependency packageReference, CancellationToken _)
        {
            Assumes.Present(packageReference);

            await _threadingService.JoinableTaskFactory.SwitchToMainThreadAsync();

            var includeFlags      = packageReference.IncludeType;
            var privateAssetsFlag = packageReference.SuppressParent;
            var metadataElements  = new List <string>();
            var metadataValues    = new List <string>();

            if (includeFlags != LibraryIncludeFlags.All)
            {
                metadataElements.Add(ProjectItemProperties.IncludeAssets);
                metadataValues.Add(LibraryIncludeFlagUtils.GetFlagString(includeFlags).Replace(',', ';'));
            }

            if (privateAssetsFlag != LibraryIncludeFlagUtils.DefaultSuppressParent)
            {
                metadataElements.Add(ProjectItemProperties.PrivateAssets);
                metadataValues.Add(LibraryIncludeFlagUtils.GetFlagString(privateAssetsFlag).Replace(',', ';'));
            }

            AddOrUpdatePackageReference(
                packageReference.Name,
                packageReference.LibraryRange.VersionRange,
                metadataElements.ToArray(),
                metadataValues.ToArray());
        }
Ejemplo n.º 2
0
        private void UpdatePackageReferenceItems(IEnumerable <ProjectItem> packageReferencesItems,
                                                 LibraryDependency libraryDependency)
        {
            // We validate that the operation does not update any imported items
            // If it does then we throw a user friendly exception without making any changes
            ValidateNoImportedItemsAreUpdated(packageReferencesItems, libraryDependency, UPDATE_OPERATION);

            foreach (var packageReferenceItem in packageReferencesItems)
            {
                var packageVersion = libraryDependency.LibraryRange.VersionRange.OriginalString ??
                                     libraryDependency.LibraryRange.VersionRange.MinVersion.ToString();

                packageReferenceItem.SetMetadataValue(VERSION_TAG, packageVersion);

                if (libraryDependency.IncludeType != LibraryIncludeFlags.All)
                {
                    var includeFlags = MSBuildStringUtility.Convert(LibraryIncludeFlagUtils.GetFlagString(libraryDependency.IncludeType));
                    packageReferenceItem.SetMetadataValue(IncludeAssets, includeFlags);
                }

                if (libraryDependency.SuppressParent != LibraryIncludeFlagUtils.DefaultSuppressParent)
                {
                    var suppressParent = MSBuildStringUtility.Convert(LibraryIncludeFlagUtils.GetFlagString(libraryDependency.SuppressParent));
                    packageReferenceItem.SetMetadataValue(PrivateAssets, suppressParent);
                }

                Logger.LogInformation(string.Format(CultureInfo.CurrentCulture,
                                                    Strings.Info_AddPkgUpdated,
                                                    libraryDependency.Name,
                                                    packageVersion,
                                                    packageReferenceItem.Xml.ContainingProject.FullPath));
            }
        }
Ejemplo n.º 3
0
        private void AddPackageReferenceIntoItemGroup(ProjectItemGroupElement itemGroup,
                                                      LibraryDependency libraryDependency)
        {
            var packageVersion = libraryDependency.LibraryRange.VersionRange.OriginalString ??
                                 libraryDependency.LibraryRange.VersionRange.MinVersion.ToString();

            var item = itemGroup.AddItem(PACKAGE_REFERENCE_TYPE_TAG, libraryDependency.Name);

            item.AddMetadata(VERSION_TAG, packageVersion, expressAsAttribute: true);

            if (libraryDependency.IncludeType != LibraryIncludeFlags.All)
            {
                var includeFlags = MSBuildStringUtility.Convert(LibraryIncludeFlagUtils.GetFlagString(libraryDependency.IncludeType));
                item.AddMetadata(IncludeAssets, includeFlags, expressAsAttribute: false);
            }

            if (libraryDependency.SuppressParent != LibraryIncludeFlagUtils.DefaultSuppressParent)
            {
                var suppressParent = MSBuildStringUtility.Convert(LibraryIncludeFlagUtils.GetFlagString(libraryDependency.SuppressParent));
                item.AddMetadata(PrivateAssets, suppressParent, expressAsAttribute: false);
            }

            Logger.LogInformation(string.Format(CultureInfo.CurrentCulture,
                                                Strings.Info_AddPkgAdded,
                                                libraryDependency.Name,
                                                packageVersion,
                                                itemGroup.ContainingProject.FullPath));
        }
        public void IncludeFlag_RoundTrip(string expected, string flags)
        {
            // Arrange & Act
            var parsed = LibraryIncludeFlagUtils.GetFlags(flags.Split('|'));
            var actual = LibraryIncludeFlagUtils.GetFlagString(parsed);

            // Assert
            Assert.Equal(expected, actual);
        }
Ejemplo n.º 5
0
        private static void WriteMetadataTargetFrameworks(IObjectWriter writer, ProjectRestoreMetadata msbuildMetadata)
        {
            if (msbuildMetadata.TargetFrameworks?.Count > 0)
            {
                writer.WriteObjectStart("frameworks");

                var frameworkNames  = new HashSet <string>();
                var frameworkSorter = new NuGetFrameworkSorter();
                foreach (var framework in msbuildMetadata.TargetFrameworks.OrderBy(c => c.FrameworkName, frameworkSorter))
                {
                    var frameworkName = framework.FrameworkName.GetShortFolderName();

                    if (!frameworkNames.Contains(frameworkName))
                    {
                        frameworkNames.Add(frameworkName);

                        writer.WriteObjectStart(frameworkName);

                        SetValueIfNotNull(writer, "targetAlias", framework.TargetAlias);

                        writer.WriteObjectStart("projectReferences");

                        foreach (var project in framework.ProjectReferences.OrderBy(e => e.ProjectPath, PathUtility.GetStringComparerBasedOnOS()))
                        {
                            writer.WriteObjectStart(project.ProjectUniqueName);

                            writer.WriteNameValue("projectPath", project.ProjectPath);

                            if (project.IncludeAssets != LibraryIncludeFlags.All)
                            {
                                writer.WriteNameValue("includeAssets", LibraryIncludeFlagUtils.GetFlagString(project.IncludeAssets));
                            }

                            if (project.ExcludeAssets != LibraryIncludeFlags.None)
                            {
                                writer.WriteNameValue("excludeAssets", LibraryIncludeFlagUtils.GetFlagString(project.ExcludeAssets));
                            }

                            if (project.PrivateAssets != LibraryIncludeFlagUtils.DefaultSuppressParent)
                            {
                                writer.WriteNameValue("privateAssets", LibraryIncludeFlagUtils.GetFlagString(project.PrivateAssets));
                            }

                            writer.WriteObjectEnd();
                        }

                        writer.WriteObjectEnd();
                        writer.WriteObjectEnd();
                    }
                }

                writer.WriteObjectEnd();
            }
        }
Ejemplo n.º 6
0
        private static void WriteMetadataTargetFrameworks(IObjectWriter writer, ProjectRestoreMetadata msbuildMetadata)
        {
            if (msbuildMetadata.TargetFrameworks?.Count > 0)
            {
                writer.WriteObjectStart("frameworks");

                var frameworkNames = new HashSet <string>();

                foreach (var framework in msbuildMetadata.TargetFrameworks)
                {
                    var frameworkName = framework.FrameworkName.GetShortFolderName();

                    if (!frameworkNames.Contains(frameworkName))
                    {
                        frameworkNames.Add(frameworkName);

                        writer.WriteObjectStart(frameworkName);

                        writer.WriteObjectStart("projectReferences");

                        foreach (var project in framework.ProjectReferences)
                        {
                            writer.WriteObjectStart(project.ProjectUniqueName);

                            writer.WriteNameValue("projectPath", project.ProjectPath);

                            if (project.IncludeAssets != LibraryIncludeFlags.All)
                            {
                                writer.WriteNameValue("includeAssets", LibraryIncludeFlagUtils.GetFlagString(project.IncludeAssets));
                            }

                            if (project.ExcludeAssets != LibraryIncludeFlags.None)
                            {
                                writer.WriteNameValue("excludeAssets", LibraryIncludeFlagUtils.GetFlagString(project.ExcludeAssets));
                            }

                            if (project.PrivateAssets != LibraryIncludeFlagUtils.DefaultSuppressParent)
                            {
                                writer.WriteNameValue("privateAssets", LibraryIncludeFlagUtils.GetFlagString(project.PrivateAssets));
                            }

                            writer.WriteObjectEnd();
                        }

                        writer.WriteObjectEnd();
                        writer.WriteObjectEnd();
                    }
                }

                writer.WriteObjectEnd();
            }
        }
        private static async Task MigrateDependenciesAsync(LegacyCSProjPackageReferenceProject project, PackageSpec packageSpec)
        {
            ThreadHelper.ThrowIfNotOnUIThread();
            if (packageSpec.TargetFrameworks.Count > 1)
            {
                throw new InvalidOperationException(
                          string.Format(
                              CultureInfo.CurrentCulture,
                              Strings.Error_MultipleFrameworks,
                              project.MSBuildProjectPath));
            }

            var dependencies = new List <LibraryDependency>();

            foreach (var targetFramework in packageSpec.TargetFrameworks)
            {
                dependencies.AddRange(targetFramework.Dependencies);
            }

            dependencies.AddRange(packageSpec.Dependencies);
            foreach (var dependency in dependencies)
            {
                var includeFlags      = dependency.IncludeType;
                var privateAssetsFlag = dependency.SuppressParent;
                var metadataElements  = new List <string>();
                var metadataValues    = new List <string>();
                if (includeFlags != LibraryIncludeFlags.All)
                {
                    metadataElements.Add("IncludeAssets");
                    metadataValues.Add(LibraryIncludeFlagUtils.GetFlagString(includeFlags).Replace(',', ';'));
                }

                if (privateAssetsFlag != LibraryIncludeFlagUtils.DefaultSuppressParent)
                {
                    metadataElements.Add("PrivateAssets");
                    metadataValues.Add(LibraryIncludeFlagUtils.GetFlagString(privateAssetsFlag).Replace(',', ';'));
                }

                await project.InstallPackageWithMetadataAsync(dependency.Name, dependency.LibraryRange.VersionRange, metadataElements, metadataValues);
            }
        }
        public override async Task <bool> InstallPackageAsync(
            string packageId,
            VersionRange range,
            INuGetProjectContext nuGetProjectContext,
            BuildIntegratedInstallationContext installationContext,
            CancellationToken token)
        {
            var formattedRange = range.OriginalString ?? range.MinVersion.ToNormalizedString();

            nuGetProjectContext.Log(MessageLevel.Info, Strings.InstallingPackage, $"{packageId} {formattedRange}");

            if (installationContext.SuccessfulFrameworks.Any() && installationContext.UnsuccessfulFrameworks.Any())
            {
                // This is the "partial install" case. That is, install the package to only a subset of the frameworks
                // supported by this project.
                var conditionalService = _unconfiguredProject
                                         .Services
                                         .ExportProvider
                                         .GetExportedValue <IConditionalPackageReferencesService>();

                if (conditionalService == null)
                {
                    throw new InvalidOperationException(string.Format(
                                                            Strings.UnableToGetCPSPackageInstallationService,
                                                            ProjectFullPath));
                }

                foreach (var framework in installationContext.SuccessfulFrameworks)
                {
                    string originalFramework;
                    if (!installationContext.OriginalFrameworks.TryGetValue(framework, out originalFramework))
                    {
                        originalFramework = framework.GetShortFolderName();
                    }

                    var reference = await conditionalService.AddAsync(
                        packageId,
                        formattedRange,
                        TargetFrameworkCondition,
                        originalFramework);

                    // SuppressParent could be set to All if developmentDependency flag is true in package nuspec file.
                    if (installationContext.SuppressParent != LibraryIncludeFlagUtils.DefaultSuppressParent &&
                        installationContext.IncludeType != LibraryIncludeFlags.All)
                    {
                        await SetPackagePropertyValueAsync(
                            reference.Metadata,
                            ProjectItemProperties.PrivateAssets,
                            MSBuildStringUtility.Convert(LibraryIncludeFlagUtils.GetFlagString(installationContext.SuppressParent)));

                        await SetPackagePropertyValueAsync(
                            reference.Metadata,
                            ProjectItemProperties.IncludeAssets,
                            MSBuildStringUtility.Convert(LibraryIncludeFlagUtils.GetFlagString(installationContext.IncludeType)));
                    }
                }
            }
            else
            {
                // Install the package to all frameworks.
                var configuredProject = await _unconfiguredProject.GetSuggestedConfiguredProjectAsync();

                var result = await configuredProject
                             .Services
                             .PackageReferences
                             .AddAsync(packageId, formattedRange);

                // This is the update operation
                if (!result.Added)
                {
                    var existingReference = result.Reference;
                    await existingReference.Metadata.SetPropertyValueAsync("Version", formattedRange);
                }

                if (installationContext.SuppressParent != LibraryIncludeFlagUtils.DefaultSuppressParent &&
                    installationContext.IncludeType != LibraryIncludeFlags.All)
                {
                    await SetPackagePropertyValueAsync(
                        result.Reference.Metadata,
                        ProjectItemProperties.PrivateAssets,
                        MSBuildStringUtility.Convert(LibraryIncludeFlagUtils.GetFlagString(installationContext.SuppressParent)));

                    await SetPackagePropertyValueAsync(
                        result.Reference.Metadata,
                        ProjectItemProperties.IncludeAssets,
                        MSBuildStringUtility.Convert(LibraryIncludeFlagUtils.GetFlagString(installationContext.IncludeType)));
                }
            }

            return(true);
        }
Ejemplo n.º 9
0
        private static bool GenerateLockFile(string dir, string assetsFilePath)
        {
            if (!File.Exists(assetsFilePath))
            {
                // TODO auto-restore?
                Console.Error.WriteLine("Could not find project.assets.json. Make sure to run 'dotnet restore' first before locking the file");
                return(false);
            }

            var lockFilePath = Path.Combine(dir, LockFileName);
            var assetsFile   = LockFileUtilities.GetLockFile(assetsFilePath, NullLogger.Instance);

            var proj = new XElement("Project");
            var doc  = new XDocument(proj);

            // details
            var props = new XElement("PropertyGroup");

            props.Add(new XElement("MSBuildAllProjects", "$(MSBuildAllProjects);$(MSBuildThisFileFullPath)"));
            props.Add(new XElement("NuGetLockFileVersion", GetVersion()));
            props.Add(new XElement("NuGetLockFileImported", "true"));
            // force NuGet to error out if there are issues
            props.Add(new XElement("WarningsAsErrors", "$(WarningsAsErrors)" + FatalErrors.Aggregate(string.Empty, (sum, piece) => $"{sum};{piece}")));
            proj.Add(props);

            // clear all package reference items
            proj.Add(new XElement("ItemGroup",
                                  new XElement("PackageReference", new XAttribute("Remove", "@(PackageReference)"))));

            // also naive. Multiple targets make exist if there are runtime identifiers
            foreach (var target in assetsFile.Targets.OrderBy(t => t.TargetFramework.GetShortFolderName()))
            {
                var spec      = assetsFile.PackageSpec.GetTargetFramework(target.TargetFramework);
                var itemGroup = new XElement("ItemGroup", new XAttribute("Condition", $"'$(TargetFramework)' == '{target.TargetFramework.GetShortFolderName()}'"));
                proj.Add(itemGroup);

                foreach (var library in target.Libraries.OrderBy(l => l.Name).Where(l => !l.Type.Equals("project", StringComparison.Ordinal)))
                {
                    // TODO re-add PrivateAssets, ExcludeAssets, etc. where appropriate

                    var reference = new XElement("PackageReference", new XAttribute("Include", library.Name), new XAttribute("Version", library.Version.ToNormalizedString()));
                    var refSpec   = spec.Dependencies.FirstOrDefault(l => l.Name.Equals(library.Name, StringComparison.OrdinalIgnoreCase));
                    if (refSpec != null)
                    {
                        if (refSpec.AutoReferenced)
                        {
                            reference.Add(new XAttribute("IsImplicitlyDefined", "true"));
                        }

                        if (refSpec.NoWarn.Any())
                        {
                            reference.Add(new XAttribute("NoWarn", refSpec.NoWarn.Aggregate(string.Empty, (a, b) => $"{a};{b}")));
                        }

                        if (refSpec.SuppressParent == LibraryIncludeFlags.All)
                        {
                            reference.Add(new XAttribute("PrivateAssets", "All"));
                        }

                        if (refSpec.IncludeType != LibraryIncludeFlags.All)
                        {
                            reference.Add(
                                new XAttribute("IncludeAssets", LibraryIncludeFlagUtils.GetFlagString(refSpec.IncludeType).Replace(", ", ";")));
                        }
                    }
                    else
                    {
                        bool IsEmptyFile(LockFileItem item)
                        {
                            return(Path.GetFileName(item.Path).Equals("_._", StringComparison.Ordinal));
                        }

                        // Attempt to make this as similar to a transitive dependency as possible

                        // This info is just for us. No one uses it (yet).
                        reference.Add(new XAttribute("Transitive", "true"));

                        // Add PrivateAssets="All" to ensure only top-level dependencies end up in the generated nuspec
                        reference.Add(new XAttribute("PrivateAssets", "All"));

                        // in some cases, the parent package may exclude assets from their nuspec.
                        // We don't want to change the compile graph by lifting this to be a top-level PackageRef
                        var excludeFlags = LibraryIncludeFlags.None;
                        if (library.CompileTimeAssemblies.Count(IsEmptyFile) == 1)
                        {
                            excludeFlags |= LibraryIncludeFlags.Compile;
                        }

                        if (library.RuntimeAssemblies.Count(IsEmptyFile) == 1)
                        {
                            excludeFlags |= LibraryIncludeFlags.Runtime;
                        }

                        if (library.NativeLibraries.Count(IsEmptyFile) == 1)
                        {
                            excludeFlags |= LibraryIncludeFlags.Native;
                        }

                        if (library.Build.Count(IsEmptyFile) == 1 ||
                            library.BuildMultiTargeting.Count(IsEmptyFile) == 1)
                        {
                            excludeFlags |= LibraryIncludeFlags.Build;
                        }

                        reference.Add(new XAttribute("ExcludeAssets", LibraryIncludeFlagUtils.GetFlagString(excludeFlags)));
                    }

                    itemGroup.Add(reference);
                }
            }

#if NETCOREAPP1_0
            using (var stream = File.Open(lockFilePath, FileMode.Create))
            {
                doc.Save(stream);
            }
#elif NETCOREAPP2_0
            doc.Save(lockFilePath);
#else
#error Update target frameworks
#endif
            Console.ForegroundColor = ConsoleColor.Magenta;
            Console.Write($"Generated lock file: ");
            Console.ResetColor();
            Console.WriteLine(lockFilePath);
            Console.WriteLine("This file should be commited to source control.");
            return(true);
        }
Ejemplo n.º 10
0
        internal static void SetMetadataValue(this IPropertySet propertySet, string name, LibraryIncludeFlags flags)
        {
            string value = MSBuildStringUtility.Convert(LibraryIncludeFlagUtils.GetFlagString(flags));

            propertySet.SetValue(name, value);
        }
        public override Task <bool> InstallPackageAsync(string packageId, VersionRange range, INuGetProjectContext nuGetProjectContext, BuildIntegratedInstallationContext installationContext, CancellationToken token)
        {
            var formattedRange = range.MinVersion.ToNormalizedString();

            nuGetProjectContext.Log(MessageLevel.Info, "Installing {0}", $"{packageId} {formattedRange}");

            if (installationContext.SuccessfulFrameworks.Any() && installationContext.UnsuccessfulFrameworks.Any())
            {
                foreach (var framework in installationContext.SuccessfulFrameworks)
                {
                    if (!installationContext.OriginalFrameworks.TryGetValue(framework, out string originalFramework))
                    {
                        originalFramework = framework.GetShortFolderName();
                    }

                    var metadata = new Dictionary <string, string>();

                    // SuppressParent could be set to All if developmentDependency flag is true in package nuspec file.
                    if (installationContext.SuppressParent != LibraryIncludeFlagUtils.DefaultSuppressParent &&
                        installationContext.IncludeType != LibraryIncludeFlags.All)
                    {
                        metadata = new Dictionary <string, string> {
                            { ProjectItemProperties.PrivateAssets, MSBuildStringUtility.Convert(LibraryIncludeFlagUtils.GetFlagString(installationContext.SuppressParent)) },
                            { ProjectItemProperties.IncludeAssets, MSBuildStringUtility.Convert(LibraryIncludeFlagUtils.GetFlagString(installationContext.IncludeType)) }
                        };
                    }

                    AddOrUpdatePackageReference(packageId, formattedRange, metadata, TargetFrameworkCondition, originalFramework);
                }
            }
            else
            {
                // Install the package to all frameworks.

                var metadata = new Dictionary <string, string>();

                if (installationContext.SuppressParent != LibraryIncludeFlagUtils.DefaultSuppressParent &&
                    installationContext.IncludeType != LibraryIncludeFlags.All)
                {
                    metadata.Add(ProjectItemProperties.PrivateAssets, MSBuildStringUtility.Convert(LibraryIncludeFlagUtils.GetFlagString(installationContext.SuppressParent)));
                    metadata.Add(ProjectItemProperties.IncludeAssets, MSBuildStringUtility.Convert(LibraryIncludeFlagUtils.GetFlagString(installationContext.IncludeType)));
                }

                AddOrUpdatePackageReference(packageId, formattedRange, metadata, null, null);
            }

            return(Task.FromResult(true));
        }
Ejemplo n.º 12
0
        private static void SetMSBuildMetadata(IObjectWriter writer, PackageSpec packageSpec)
        {
            var msbuildMetadata = packageSpec.RestoreMetadata;

            if (msbuildMetadata == null)
            {
                return;
            }

            if (msbuildMetadata.ProjectUniqueName == null && msbuildMetadata.ProjectName == null &&
                msbuildMetadata.ProjectPath == null && msbuildMetadata.ProjectJsonPath == null &&
                msbuildMetadata.PackagesPath == null && msbuildMetadata.OutputPath == null)
            {
                return;
            }

            writer.WriteObjectStart(JsonPackageSpecReader.RestoreOptions);

            SetValue(writer, "projectUniqueName", msbuildMetadata.ProjectUniqueName);
            SetValue(writer, "projectName", msbuildMetadata.ProjectName);
            SetValue(writer, "projectPath", msbuildMetadata.ProjectPath);
            SetValue(writer, "projectJsonPath", msbuildMetadata.ProjectJsonPath);
            SetValue(writer, "packagesPath", msbuildMetadata.PackagesPath);
            SetValue(writer, "outputPath", msbuildMetadata.OutputPath);

            if (msbuildMetadata.ProjectStyle != ProjectStyle.Unknown)
            {
                SetValue(writer, "projectStyle", msbuildMetadata.ProjectStyle.ToString());
            }

            SetValueIfTrue(writer, "crossTargeting", msbuildMetadata.CrossTargeting);

            SetValueIfTrue(
                writer,
                "legacyPackagesDirectory",
                msbuildMetadata.LegacyPackagesDirectory);

            SetValueIfTrue(
                writer,
                "validateRuntimeAssets",
                msbuildMetadata.ValidateRuntimeAssets);

            SetValueIfTrue(
                writer,
                "skipContentFileWrite",
                msbuildMetadata.SkipContentFileWrite);

            SetArrayValue(writer, "fallbackFolders", msbuildMetadata.FallbackFolders);
            SetArrayValue(writer, "originalTargetFrameworks", msbuildMetadata.OriginalTargetFrameworks);

            if (msbuildMetadata.Sources?.Count > 0)
            {
                writer.WriteObjectStart("sources");

                foreach (var source in msbuildMetadata.Sources)
                {
                    // "source": {}
                    writer.WriteObjectStart(source.Source);
                    writer.WriteObjectEnd();
                }

                writer.WriteObjectEnd();
            }

            if (msbuildMetadata.Files?.Count > 0)
            {
                writer.WriteObjectStart("files");

                foreach (var file in msbuildMetadata.Files)
                {
                    SetValue(writer, file.PackagePath, file.AbsolutePath);
                }

                writer.WriteObjectEnd();
            }

            if (msbuildMetadata.TargetFrameworks?.Count > 0)
            {
                writer.WriteObjectStart("frameworks");

                var frameworkNames = new HashSet <string>();

                foreach (var framework in msbuildMetadata.TargetFrameworks)
                {
                    var frameworkName = framework.FrameworkName.GetShortFolderName();

                    if (!frameworkNames.Contains(frameworkName))
                    {
                        frameworkNames.Add(frameworkName);

                        writer.WriteObjectStart(frameworkName);

                        writer.WriteObjectStart("projectReferences");

                        foreach (var project in framework.ProjectReferences)
                        {
                            writer.WriteObjectStart(project.ProjectUniqueName);

                            writer.WriteNameValue("projectPath", project.ProjectPath);

                            if (project.IncludeAssets != LibraryIncludeFlags.All)
                            {
                                writer.WriteNameValue("includeAssets", LibraryIncludeFlagUtils.GetFlagString(project.IncludeAssets));
                            }

                            if (project.ExcludeAssets != LibraryIncludeFlags.None)
                            {
                                writer.WriteNameValue("excludeAssets", LibraryIncludeFlagUtils.GetFlagString(project.ExcludeAssets));
                            }

                            if (project.PrivateAssets != LibraryIncludeFlagUtils.DefaultSuppressParent)
                            {
                                writer.WriteNameValue("privateAssets", LibraryIncludeFlagUtils.GetFlagString(project.PrivateAssets));
                            }

                            writer.WriteObjectEnd();
                        }

                        writer.WriteObjectEnd();
                        writer.WriteObjectEnd();
                    }
                }

                writer.WriteObjectEnd();
            }

            writer.WriteObjectEnd();
        }