コード例 #1
0
 // Trying to fetch a property value from tfm property bags.
 // If defined the property should have identical values in all of the occurances.
 private static TValue GetSingleNonEvaluatedPropertyOrNull <TValue>(
     IVsTargetFrameworks tfms,
     string propertyName,
     Func <string, TValue> valueFactory)
 {
     return(GetNonEvaluatedPropertyOrNull(tfms, propertyName, valueFactory).SingleOrDefault());
 }
コード例 #2
0
        /// <summary>
        /// The result will contain CLEAR and no sources specified in RestoreFallbackFolders if the clear keyword is in it.
        /// If there are additional fallback folders specified, the value AdditionalValue will be set in the result and then all the additional fallback folders will follow
        /// </summary>
        private static IEnumerable <string> GetRestoreFallbackFolders(IVsTargetFrameworks tfms)
        {
            var folders = HandleClear(MSBuildStringUtility.Split(GetNonEvaluatedPropertyOrNull(tfms, RestoreFallbackFolders, e => e)));

            var additional = MSBuildStringUtility.Split(GetNonEvaluatedPropertyOrNull(tfms, RestoreAdditionalProjectFallbackFolders, e => e));

            return(VSRestoreSettingsUtilities.GetEntriesWithAdditional(folders, additional));
        }
コード例 #3
0
        private static IEnumerable <NuGetLogCode> GetSingleOrDefaultNuGetLogCodes(
            IVsTargetFrameworks tfms,
            string propertyName,
            Func <string, IEnumerable <NuGetLogCode> > valueFactory)
        {
            var logCodeProperties = GetNonEvaluatedPropertyOrNull(tfms, propertyName, valueFactory);

            return(MSBuildStringUtility.GetDistinctNuGetLogCodesOrDefault(logCodeProperties));
        }
コード例 #4
0
        private static TValue GetSingleOrDefaultPropertyValue <TValue>(
            IVsTargetFrameworks tfms,
            string propertyName,
            Func <string, TValue> valueFactory)
        {
            var properties = GetNonEvaluatedPropertyOrNull(tfms, propertyName, valueFactory);

            return(properties.Count() > 1 ? default(TValue) : properties.SingleOrDefault());
        }
コード例 #5
0
        private static NuGetVersion GetPackageVersion(IVsTargetFrameworks tfms)
        {
            // $(PackageVersion) property if set overrides the $(Version)
            var versionPropertyValue =
                GetNonEvaluatedPropertyOrNull(tfms, PackageVersion, NuGetVersion.Parse)
                ?? GetNonEvaluatedPropertyOrNull(tfms, Version, NuGetVersion.Parse);

            return(versionPropertyValue ?? PackageSpec.DefaultVersion);
        }
コード例 #6
0
 /// <summary>
 /// Fetch all property values from each target framework and combine them.
 /// </summary>
 private static IEnumerable <string> GetAggregatePropertyValues(
     IVsTargetFrameworks tfms,
     string propertyName)
 {
     // Only non-null values are added to the list as part of the split.
     return(tfms
            .Cast <IVsTargetFrameworkInfo>()
            .SelectMany(tfm => MSBuildStringUtility.Split(GetPropertyValueOrNull(tfm.Properties, propertyName))));
 }
コード例 #7
0
        private static IEnumerable <string> GetRestoreFallbackFolders(IVsTargetFrameworks tfms)
        {
            var folders = MSBuildStringUtility.Split(GetNonEvaluatedPropertyOrNull(tfms, RestoreFallbackFolders, e => e));

            folders = HandleClear(folders);

            var additional = MSBuildStringUtility.Split(GetNonEvaluatedPropertyOrNull(tfms, RestoreAdditionalProjectFallbackFolders, e => e));

            return(folders.Concat(additional));
        }
コード例 #8
0
        private static void LogTargetFrameworks(IProjectLoggerBatch logger, IVsTargetFrameworks targetFrameworks)
        {
            logger.WriteLine($"Target Frameworks ({targetFrameworks.Count})");
            logger.IndentLevel++;

            foreach (IVsTargetFrameworkInfo tf in targetFrameworks)
            {
                LogTargetFramework(logger, tf);
            }
            logger.IndentLevel--;
        }
コード例 #9
0
        public ProjectRestoreInfo(string msbuildProjectExtensionsPath, string originalTargetFrameworks, IVsTargetFrameworks targetFrameworks, IVsReferenceItems toolReferences)
        {
            Requires.NotNull(msbuildProjectExtensionsPath, nameof(msbuildProjectExtensionsPath));
            Requires.NotNull(originalTargetFrameworks, nameof(originalTargetFrameworks));
            Requires.NotNull(targetFrameworks, nameof(targetFrameworks));
            Requires.NotNull(toolReferences, nameof(toolReferences));

            MSBuildProjectExtensionsPath = msbuildProjectExtensionsPath;
            OriginalTargetFrameworks     = originalTargetFrameworks;
            TargetFrameworks             = targetFrameworks;
            ToolReferences = toolReferences;
        }
コード例 #10
0
        /// <summary>
        /// The result will contain CLEAR and no sources specified in RestoreSources if the clear keyword is in it.
        /// If there are additional sources specified, the value AdditionalValue will be set in the result and then all the additional sources will follow
        /// </summary>
        private static IEnumerable <string> GetRestoreSources(IVsTargetFrameworks tfms)
        {
            var sources = HandleClear(MSBuildStringUtility.Split(GetNonEvaluatedPropertyOrNull(tfms, RestoreSources, e => e)));

            // Read RestoreAdditionalProjectSources from the inner build, these may be different between frameworks.
            // Exclude is not allowed for sources
            var additional = MSBuildRestoreUtility.AggregateSources(
                values: GetAggregatePropertyValues(tfms, RestoreAdditionalProjectSources),
                excludeValues: Enumerable.Empty <string>());

            return(VSRestoreSettingsUtilities.GetEntriesWithAdditional(sources, additional.ToArray()));
        }
コード例 #11
0
        /// <summary>
        /// The result will contain CLEAR and no sources specified in RestoreFallbackFolders if the clear keyword is in it.
        /// If there are additional fallback folders specified, the value AdditionalValue will be set in the result and then all the additional fallback folders will follow
        /// </summary>
        private static IEnumerable <string> GetRestoreFallbackFolders(IVsTargetFrameworks tfms)
        {
            var folders = HandleClear(MSBuildStringUtility.Split(GetNonEvaluatedPropertyOrNull(tfms, RestoreFallbackFolders, e => e)));

            // Read RestoreAdditionalProjectFallbackFolders from the inner build.
            // Remove all excluded fallback folders listed in RestoreAdditionalProjectFallbackFoldersExcludes.
            var additional = MSBuildRestoreUtility.AggregateSources(
                values: GetAggregatePropertyValues(tfms, RestoreAdditionalProjectFallbackFolders),
                excludeValues: GetAggregatePropertyValues(tfms, RestoreAdditionalProjectFallbackFoldersExcludes));

            return(VSRestoreSettingsUtilities.GetEntriesWithAdditional(folders, additional.ToArray()));
        }
コード例 #12
0
        private static string[] GetRestoreSources(IVsTargetFrameworks tfms)
        {
            var sources = MSBuildStringUtility.Split(GetNonEvaluatedPropertyOrNull(tfms, RestoreSources, e => e));

            sources = HandleClear(sources);

            var additional = MSBuildStringUtility.Split(GetNonEvaluatedPropertyOrNull(tfms, RestoreAdditionalProjectSources, e => e));

            sources = sources.Concat(additional).ToArray();

            return(sources);
        }
コード例 #13
0
        public ProjectRestoreInfo(string baseIntermediatePath, string originalTargetFrameworks, IVsTargetFrameworks targetFrameworks, IVsReferenceItems toolReferences)
        {
            Requires.NotNullOrEmpty(baseIntermediatePath, nameof(baseIntermediatePath));
            Requires.NotNull(originalTargetFrameworks, nameof(originalTargetFrameworks));
            Requires.NotNull(targetFrameworks, nameof(targetFrameworks));
            Requires.NotNull(toolReferences, nameof(toolReferences));

            BaseIntermediatePath     = baseIntermediatePath;
            OriginalTargetFrameworks = originalTargetFrameworks;
            TargetFrameworks         = targetFrameworks;
            ToolReferences           = toolReferences;
        }
コード例 #14
0
 // Trying to fetch a list of property value from all tfm property bags.
 private static IEnumerable <TValue> GetNonEvaluatedPropertyOrNull <TValue>(
     IVsTargetFrameworks tfms,
     string propertyName,
     Func <string, TValue> valueFactory)
 {
     return(tfms
            .Cast <IVsTargetFrameworkInfo>()
            .Select(tfm =>
     {
         var val = GetPropertyValueOrNull(tfm.Properties, propertyName);
         return val != null ? valueFactory(val) : default(TValue);
     })
            .Distinct());
 }
コード例 #15
0
        public VsProjectRestoreInfo(
            string baseIntermediatePath,
            IVsTargetFrameworks targetFrameworks)
        {
            if (string.IsNullOrEmpty(baseIntermediatePath))
            {
                throw new ArgumentException(ProjectManagement.Strings.Argument_Cannot_Be_Null_Or_Empty, nameof(baseIntermediatePath));
            }

            if (targetFrameworks == null)
            {
                throw new ArgumentNullException(nameof(targetFrameworks));
            }

            BaseIntermediatePath = baseIntermediatePath;
            TargetFrameworks     = targetFrameworks;
        }
コード例 #16
0
        public VsProjectRestoreInfo(
            string baseIntermediatePath,
            IVsTargetFrameworks targetFrameworks)
        {
            if (string.IsNullOrEmpty(baseIntermediatePath))
            {
                throw new ArgumentException("Argument cannot be null or empty", nameof(baseIntermediatePath));
            }

            if (targetFrameworks == null)
            {
                throw new ArgumentNullException(nameof(targetFrameworks));
            }

            BaseIntermediatePath = baseIntermediatePath;
            TargetFrameworks     = targetFrameworks;
        }
コード例 #17
0
        private IVsProjectRestoreInfo MergeRestoreData(IReadOnlyCollection <ProjectRestoreUpdate> updates)
        {
            // We have no active configuration
            if (updates.Count == 0)
            {
                return(null);
            }

            // We need to combine the snapshots from each implicitly active configuration (ie per TFM),
            // resolving any conflicts, which we'll report to the user.

            string              msbuildProjectExtensionsPath = ResolveMSBuildProjectExtensionsPathConflicts(updates);
            string              originalTargetFrameworks     = ResolveOriginalTargetFrameworksConflicts(updates);
            IVsReferenceItems   toolReferences   = ResolveToolReferenceConflicts(updates);
            IVsTargetFrameworks targetFrameworks = GetAllTargetFrameworks(updates);

            return(new ProjectRestoreInfo(
                       msbuildProjectExtensionsPath,
                       originalTargetFrameworks,
                       targetFrameworks,
                       toolReferences));
        }
コード例 #18
0
 private static string GetRestorePackagesWithLockFile(IVsTargetFrameworks tfms)
 {
     return(GetSingleNonEvaluatedPropertyOrNull(tfms, RestorePackagesWithLockFile, v => v));
 }
コード例 #19
0
 private static string GetRestoreProjectPath(IVsTargetFrameworks tfms)
 {
     return(GetNonEvaluatedPropertyOrNull(tfms, RestorePackagesPath, e => e));
 }
コード例 #20
0
 private static string GetNuGetLockFilePath(IVsTargetFrameworks tfms)
 {
     return(GetSingleNonEvaluatedPropertyOrNull(tfms, NuGetLockFilePath, v => v));
 }
コード例 #21
0
        private static string GetPackageId(ProjectNames projectNames, IVsTargetFrameworks tfms)
        {
            var packageId = GetNonEvaluatedPropertyOrNull(tfms, PackageId, v => v);

            return(packageId ?? projectNames.ShortName);
        }
コード例 #22
0
 private static bool IsLockFileFreezeOnRestore(IVsTargetFrameworks tfms)
 {
     return(GetSingleNonEvaluatedPropertyOrNull(tfms, RestoreLockedMode, MSBuildStringUtility.IsTrue));
 }