コード例 #1
0
ファイル: XamlCodeGeneration.cs プロジェクト: uzbekdev1/uno
        /// <summary>
        /// Get the file location as seen in the IDE, used for ResourceDictionary.Source resolution.
        /// </summary>
        private string GetSourceLink(MSBuildItem projectItemInstance)
        {
            var link = projectItemInstance.GetMetadataValue("Link");
            var definingProjectFullPath = projectItemInstance.GetMetadataValue("DefiningProjectFullPath");
            var fullPath = projectItemInstance.GetMetadataValue("FullPath");

            // Reproduce the logic from https://github.com/dotnet/msbuild/blob/e70a3159d64f9ed6ec3b60253ef863fa883a99b1/src/Tasks/AssignLinkMetadata.cs
            if (link.IsNullOrEmpty())
            {
                if (definingProjectFullPath.IsNullOrEmpty())
                {
                    // Both Uno.SourceGeneration uses relative paths and Roslyn Generators provide
                    // full paths. Dependents need specific portions so adjust the paths here for now.
                    // For the case of Roslyn generators, DefiningProjectFullPath is not populated on purpose
                    // so that we can adjust paths properly.
                    if (link.IsNullOrEmpty())
                    {
                        return(Path.IsPathRooted(projectItemInstance.Identity)
                                                        ? projectItemInstance.Identity.TrimStart(_projectDirectory).TrimStart(Path.DirectorySeparatorChar)
                                                        : projectItemInstance.Identity);
                    }
                }
                else
                {
                    var definingProjectDirectory = Path.GetDirectoryName(definingProjectFullPath) + Path.DirectorySeparatorChar;

                    if (fullPath.StartsWith(definingProjectDirectory, StringComparison.OrdinalIgnoreCase))
                    {
                        link = fullPath.Substring(definingProjectDirectory.Length);
                    }
                }
            }

            return(link);
        }
コード例 #2
0
        // added to make sure our key output is picked up properly
        protected override void Refresh()
        {
            // Let MSBuild know which configuration we are working with
            this.Project.SetConfiguration(this.ProjectCfg.ConfigCanonicalName);
            ThreadHelper.ThrowIfNotOnUIThread();

            // Generate dependencies if such a task exist
            if (this.Project.ProjectInstance.Targets.ContainsKey(ProjectFileConstants.AllProjectOutputGroups))
            {
                bool succeeded = false;
                this.Project.BuildTarget(ProjectFileConstants.AllProjectOutputGroups, out succeeded);
                if (!succeeded)
                {
                    if (System.Diagnostics.Debugger.IsAttached)
                    {
                        Debug.WriteLine("Failed to build target {0}", this.TargetName);
                    }
                    this.Outputs.Clear();
                    return;
                }
            }
            // Rebuild the content of our list of output
            string outputType = this.TargetName + "Output";

            if (TargetName == "BuiltProjectOutputGroup")
            {
                outputType = this.TargetName + "KeyOutput";
            }
            this.Outputs.Clear();
            foreach (MSBuildExecution.ProjectItemInstance item in MSBuildProjectInstance.GetItems(this.Project.ProjectInstance, outputType))
            {
                Output output = new Output(this.Project, item);
                this.Outputs.Add(output);

                // See if it is our key output
                if (String.Compare(MSBuildItem.GetMetadataValue(item, "IsKeyOutput"), true.ToString(), StringComparison.OrdinalIgnoreCase) == 0)
                {
                    KeyOutput = output;
                }
            }

            this.Project.SetCurrentConfiguration();

            // Now that the group is built we have to check if it is invalidated by a property
            // change on the project.
            this.Project.OnProjectPropertyChanged += new EventHandler <ProjectPropertyChangedArgs>(OnProjectPropertyChanged);
        }
コード例 #3
0
        /// <summary>
        /// Get the file location as seen in the IDE, used for ResourceDictionary.Source resolution.
        /// </summary>
        private string GetSourceLink(MSBuildItem projectItemInstance)
        {
            var value = projectItemInstance.GetMetadataValue("Link");

#if NETSTANDARD
            // Both Uno.SourceGeneration uses relative pathrs and Roslyn Generators provide
            // full paths. Dependents need specific portions so adjust the paths here for now.

            if (value.IsNullOrEmpty())
            {
                return(Path.IsPathRooted(projectItemInstance.Identity)
                                        ? projectItemInstance.Identity.TrimStart(_projectDirectory).TrimStart(Path.DirectorySeparatorChar)
                                        : projectItemInstance.Identity);
            }

            return(value);
#else
            return(value.IsNullOrEmpty() ? projectItemInstance.Identity : value);
#endif
        }
コード例 #4
0
        /// <summary>
        /// Get the file location as seen in the IDE, used for ResourceDictionary.Source resolution.
        /// </summary>
        private string GetSourceLink(MSBuildItem projectItemInstance)
        {
            var value = projectItemInstance.GetMetadataValue("Link");

            return(value.IsNullOrEmpty() ? projectItemInstance.Identity : value);
        }