int RestrictFrameworkReferences(ProjectInfo item)
        {
            string targetFrmWrk = item.TargetFrameworkVersion;

            if (!String.IsNullOrEmpty(targetFrmWrk))
            {
                Version targetVer = new Version(targetFrmWrk.TrimStart('v'));
                foreach (ProjectRef r in item.GetReferences())
                {
                    if (!String.IsNullOrEmpty(r.RequiresVersion))
                    {
                        if (new Version(r.RequiresVersion) > targetVer)
                        {
                            item.RemoveReference(r);
                            continue;
                        }
                    }
                    if (r.Assembly.Version != null && r.Assembly.Name.StartsWith("System.", StringComparison.OrdinalIgnoreCase))
                    {
                        Version ver = new Version(r.Assembly.Version.Major, r.Assembly.Version.Minor);
                        if (r.Assembly.Version > targetVer)
                        {
                            item.RemoveReference(r);
                        }
                    }
                }
            }
            return(0);
        }
        int RebindProjectReferences(ProjectInfo item)
        {
            if (GetReferenceFolders().Length == 0)
            {
                return(0);
            }

            string file = null;

            if (__mscorlibPath == null)
            {
                __mscorlibPath = FindPath(__mscorlib);
            }
            item.AddReference(null, __mscorlib, null, __mscorlibPath, false, false);

            int errors             = 0;
            List <ProjectRef> refs = new List <ProjectRef>(item.GetReferences());

            foreach (ProjectRef r in refs)
            {
                if (!_foundReferences.TryGetValue(r.Assembly.Name, out file))
                {
                    if (r.Resolved)
                    {
                        ProjectInfo proj = _build.GetReference(r);
                        if (proj == null)
                        {
                            throw new ApplicationException(String.Format("Unable to remove unkown project reference {0}", r.Assembly));
                        }

                        file = proj.AbsoluteOutputPath;
                    }
                    else
                    {
                        file = FindPath(r.Assembly);
                    }
                    _foundReferences[r.Assembly.Name] = file;
                }
                if (file != null)
                {
                    item.ResolveReference(r, file, r.CopyLocal, r.SpecificVersion);
                    Log.Verbose("Project reference {0} changed to file {1}", r.Assembly.Name, file);
                }
                else
                {
                    Log.Error("Unable to locate reference {0}", r.Assembly);
                    errors++;
                }
            }
            return(errors);
        }
예제 #3
0
        int RebindProjectReferences(ProjectInfo item)
		{
            if (GetReferenceFolders().Length == 0)
                return 0;

            string file = null;
            if (__mscorlibPath == null)
                __mscorlibPath = FindPath(__mscorlib);
            item.AddReference(null, __mscorlib, null, __mscorlibPath, false, false);

            int errors = 0;
            List<ProjectRef> refs = new List<ProjectRef>(item.GetReferences());
			foreach (ProjectRef r in refs)
			{
                if (!_foundReferences.TryGetValue(r.Assembly.Name, out file))
                {
                    if (r.Resolved)
                    {
                        ProjectInfo proj = _build.GetReference(r);
                        if (proj == null)
                            throw new ApplicationException(String.Format("Unable to remove unkown project reference {0}", r.Assembly));

                        file = proj.AbsoluteOutputPath;
                    }
                    else
                    {
                        file = FindPath(r.Assembly);
                    }
                    _foundReferences[r.Assembly.Name] = file;
                }
                if (file != null)
                {
                    item.ResolveReference(r, file, r.CopyLocal, r.SpecificVersion);
                    Log.Verbose("Project reference {0} changed to file {1}", r.Assembly.Name, file);
                }
                else
                {
                    Log.Error("Unable to locate reference {0}", r.Assembly);
                    errors++;
                }
			}
            return errors;
		}
예제 #4
0
        int RestrictFrameworkReferences(ProjectInfo item)
		{
			string targetFrmWrk = item.TargetFrameworkVersion;
			if (!String.IsNullOrEmpty(targetFrmWrk))
			{
				Version targetVer = new Version(targetFrmWrk.TrimStart('v'));
				foreach (ProjectRef r in item.GetReferences())
				{
					if (!String.IsNullOrEmpty(r.RequiresVersion))
					{
						if (new Version(r.RequiresVersion) > targetVer)
						{
							item.RemoveReference(r);
							continue;
						}
					}
					if (r.Assembly.Version != null &&r.Assembly.Name.StartsWith("System.", StringComparison.OrdinalIgnoreCase))
					{
						Version ver = new Version(r.Assembly.Version.Major, r.Assembly.Version.Minor);
						if (r.Assembly.Version > targetVer)
						{
							item.RemoveReference(r);
						}
					}
				}
			}
            return 0;
		}