コード例 #1
0
ファイル: GraphBuilder.cs プロジェクト: Nirmal4G/msbuild
        private ParsedProject ParseProject(ConfigurationMetadata configurationMetadata)
        {
            // TODO: ProjectInstance just converts the dictionary back to a PropertyDictionary, so find a way to directly provide it.
            var globalProperties = configurationMetadata.GlobalProperties.ToDictionary();
            ProjectGraphNode graphNode;
            ProjectInstance  projectInstance;
            var negotiatePlatform = PlatformNegotiationEnabled && !configurationMetadata.IsSetPlatformHardCoded;

            projectInstance = _projectInstanceFactory(
                configurationMetadata.ProjectFullPath,
                negotiatePlatform ? null : globalProperties,                 // Platform negotiation requires an evaluation with no global properties first
                _projectCollection);

            if (ConversionUtilities.ValidBooleanTrue(projectInstance.GetPropertyValue(EnableDynamicPlatformResolutionMetadataName)))
            {
                PlatformNegotiationEnabled = true;
            }

            if (projectInstance == null)
            {
                throw new InvalidOperationException(ResourceUtilities.GetResourceString("NullReferenceFromProjectInstanceFactory"));
            }

            if (negotiatePlatform)
            {
                var selectedPlatform = PlatformNegotiation.GetNearestPlatform(projectInstance.GetPropertyValue(PlatformMetadataName), projectInstance.GetPropertyValue(PlatformsMetadataName), projectInstance.GetPropertyValue(PlatformLookupTableMetadataName), configurationMetadata.PreviousPlatformLookupTable, projectInstance.FullPath, configurationMetadata.PreviousPlatform);

                if (selectedPlatform.Equals(String.Empty))
                {
                    globalProperties.Remove(PlatformMetadataName);
                }
                else
                {
                    globalProperties[PlatformMetadataName] = selectedPlatform;
                }
                projectInstance = _projectInstanceFactory(
                    configurationMetadata.ProjectFullPath,
                    globalProperties,
                    _projectCollection);
            }

            graphNode = new ProjectGraphNode(projectInstance);

            var referenceInfos = ParseReferences(graphNode);

            return(new ParsedProject(configurationMetadata, graphNode, referenceInfos));
        }
コード例 #2
0
        public override bool Execute()
        {
            AssignedProjectsWithPlatform = new ITaskItem[AnnotatedProjects.Length];
            for (int i = 0; i < AnnotatedProjects.Length; i++)
            {
                AssignedProjectsWithPlatform[i] = new TaskItem(AnnotatedProjects[i]);

                string referencedProjectPlatform           = AssignedProjectsWithPlatform[i].GetMetadata("Platform");
                string projectReferencePlatformsMetadata   = AssignedProjectsWithPlatform[i].GetMetadata("Platforms");
                string projectReferenceLookupTableMetadata = AssignedProjectsWithPlatform[i].GetMetadata("PlatformLookupTable");

                string?buildProjectReferenceAs = PlatformNegotiation.GetNearestPlatform(referencedProjectPlatform, projectReferencePlatformsMetadata, projectReferenceLookupTableMetadata, PlatformLookupTable, AssignedProjectsWithPlatform[i].ItemSpec, CurrentProjectPlatform, Log);

                AssignedProjectsWithPlatform[i].SetMetadata("NearestPlatform", buildProjectReferenceAs);
                Log.LogMessageFromResources(MessageImportance.Low, "GetCompatiblePlatform.DisplayChosenPlatform", AssignedProjectsWithPlatform[i].ItemSpec, buildProjectReferenceAs);
            }

            return(!Log.HasLoggedErrors);
        }