public void UpdateFromProject()
        {
            Hashtable fs = new Hashtable();

            foreach (ProjectFile file in project.Files)
            {
                if (GetFile(file.Name) == null)
                {
                    AddFile(file.Name);
                }
                fs [file.Name] = null;
            }

            foreach (string file in files.Keys.ToArray())
            {
                if (!fs.Contains(file))
                {
                    RemoveFile(file);
                }
            }

            fs.Clear();
            if (project is DotNetProject)
            {
                DotNetProject netProject = (DotNetProject)project;
                foreach (SolutionItem pr in netProject.GetReferencedItems(ConfigurationSelector.Default))
                {
                    if (pr is Project)
                    {
                        string refId = "Project:" + ((Project)pr).FileName;
                        fs[refId] = null;
                        if (!HasReference(refId))
                        {
                            AddReference(refId);
                        }
                    }
                }

                // Get the assembly references throught the project, since it may have custom references
                foreach (string file in netProject.GetReferencedAssemblies(ConfigurationSelector.Default, false))
                {
                    string refId = "Assembly:" + netProject.TargetRuntime.Id + ":" + Path.GetFullPath(file);
                    fs[refId] = null;
                    if (!HasReference(refId))
                    {
                        AddReference(refId);
                    }
                }
            }

            foreach (ReferenceEntry re in References)
            {
                // Don't delete corlib references. They are implicit to projects, but not to pidbs.
                if (!fs.Contains(re.Uri) && !IsCorlibReference(re))
                {
                    RemoveReference(re.Uri);
                }
            }
            UpdateCorlibReference();
        }
Beispiel #2
0
        async Task <BuildResult> Pack(ProgressMonitor monitor, ConfigurationSelector configuration, bool buildReferencedTargets, OperationContext operationContext)
        {
            var result = new BuildResult();

            // Build the project and any dependencies first.
            if (buildReferencedTargets && project.GetReferencedItems(configuration).Any())
            {
                result = await project.Build(monitor, configuration, buildReferencedTargets, operationContext);

                if (result.Failed)
                {
                    return(result);
                }
            }

            // Generate the NuGet package by calling the Pack target.
            var packResult = (await project.RunTarget(monitor, "Pack", configuration, new TargetEvaluationContext(operationContext))).BuildResult;

            return(result.Append(packResult));
        }