public SdkProjectMetaData(ITaskItem project, TargetFrameworkMoniker fxMoniker, string fullProjectPath, bool isTargetFxSupported, SdkProjctType projectType = SdkProjctType.Sdk)
 {
     ProjectTaskItem     = project;
     FxMoniker           = fxMoniker;
     FullProjectPath     = fullProjectPath;
     IsTargetFxSupported = isTargetFxSupported;
     ProjectType         = projectType;
 }
Esempio n. 2
0
 public SdkProjectMetaData(ITaskItem project, Project msbuildProject, TargetFrameworkMoniker fxMoniker, string fxMonikerString, string fullProjectPath, string targetOutputPath, bool isTargetFxSupported, SdkProjctType projectType = SdkProjctType.Sdk)
 {
     ProjectTaskItem      = project;
     FxMoniker            = fxMoniker;
     FullProjectPath      = fullProjectPath;
     IsTargetFxSupported  = isTargetFxSupported;
     ProjectType          = projectType;
     TargetOutputFullPath = targetOutputPath;
     FxMonikerString      = fxMonikerString;
     MsBuildProject       = msbuildProject;
 }
Esempio n. 3
0
 public SdkProjectMetaData(ITaskItem project,
                           Project msbuildProject, TargetFrameworkMoniker fxMoniker, string fxMonikerString,
                           string fullProjectPath, string targetOutputPath, bool isTargetFxSupported,
                           SdkProjctType projectType,
                           bool isProjectDataPlaneProject,
                           bool isNonSdkProject = true)
 {
     ProjectTaskItem        = project;
     FxMoniker              = fxMoniker;
     FullProjectPath        = fullProjectPath;
     IsTargetFxSupported    = isTargetFxSupported;
     ProjectType            = projectType;
     TargetOutputFullPath   = targetOutputPath;
     FxMonikerString        = fxMonikerString;
     MsBuildProject         = msbuildProject;
     IsProjectDataPlane     = isProjectDataPlaneProject;
     IsFxFullDesktopVersion = IsExpectedFxCategory(fxMoniker, TargetFxCategory.FullDesktop);
     IsFxNetCore            = IsExpectedFxCategory(fxMoniker, TargetFxCategory.NetCore);
     IsNonSdkProject        = isNonSdkProject;
 }
Esempio n. 4
0
        public SdkProjctType GetProjectType(Project msbuildProj)
        {
            SdkProjctType             pType = SdkProjctType.Sdk;
            ICollection <ProjectItem> pkgs  = msbuildProj.GetItemsIgnoringCondition("PackageReference");

            if (pkgs.Any <ProjectItem>())
            {
                var testReference = pkgs.Where <ProjectItem>((p) => p.EvaluatedInclude.Equals("xunit", StringComparison.OrdinalIgnoreCase));
                if (testReference.Any <ProjectItem>())
                {
                    pType = SdkProjctType.Test;
                }
                else
                {
                    pType = SdkProjctType.Sdk;
                }
            }

            return(pType);
        }
        internal ConcurrentBag <SdkProjectMetaData> GetMetaData(List <string> projectList, ConcurrentBag <SdkProjectMetaData> supportedProjectBag)
        {
            SdkProjctType pType    = SdkProjctType.Sdk;
            var           projList = from p in projectList select new TaskItem(p);
            IBuildEngine  buildEng = this.BuildEngine;

            //Object obj = new object();

            //ThreadingTsk.Parallel.ForEach<ITaskItem>(projList, (proj) =>
            foreach (ITaskItem proj in projList)
            {
                //lock (obj)
                //{
                try
                {
                    Project loadedProj = new Project(proj.ItemSpec);

                    string targetFxList = loadedProj.GetPropertyValue("TargetFrameworks");
                    if (string.IsNullOrEmpty(targetFxList))
                    {
                        targetFxList = loadedProj.GetPropertyValue("TargetFramework");
                    }
                    ICollection <ProjectItem> pkgs = loadedProj.GetItemsIgnoringCondition("PackageReference");
                    if (pkgs.Any <ProjectItem>())
                    {
                        var testReference = pkgs.Where <ProjectItem>((p) => p.EvaluatedInclude.Equals("xunit", StringComparison.OrdinalIgnoreCase));
                        if (testReference.Any <ProjectItem>())
                        {
                            pType = SdkProjctType.Test;
                        }
                        else
                        {
                            pType = SdkProjctType.Sdk;
                        }
                    }

                    var fxNames = targetFxList?.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries)?.ToList <string>();
                    foreach (string fx in fxNames)
                    {
                        bool isFxSupported    = IsTargetFxSupported(fx, out TargetFrameworkMoniker tfxMoniker);
                        SdkProjectMetaData sp = new SdkProjectMetaData(project: proj, fxMoniker: tfxMoniker, fullProjectPath: proj.ItemSpec, isTargetFxSupported: isFxSupported, projectType: pType);
                        supportedProjectBag.Add(sp);
                    }
                }
                catch (Exception ex)
                {
                    if (buildEng != null)
                    {
                        Log.LogWarningFromException(ex);
                    }
                    else
                    {
                        Debug.WriteLine(ex.Message);
                    }
                }
                //}
                //loadedProj = null;
            }
            //);

            return(supportedProjectBag);
        }