Esempio n. 1
0
        public override bool Execute()
        {
            string solutionDir = SolutionDir.GetMetadata("FullPath");

            if (string.IsNullOrWhiteSpace(solutionDir) || !Directory.Exists(solutionDir))
            {
                Log.LogError($"SolutionDir not found: '{SolutionDir.ItemSpec}'");
                return(false);
            }

            foreach (ITaskItem prjFile in Projects)
            {
                string prjPath = prjFile.GetMetadata("FullPath");
                if (string.IsNullOrWhiteSpace(prjPath) || !File.Exists(prjPath))
                {
                    Log.LogError($"Project not found: '{prjFile.ItemSpec}'");
                    continue;
                }

                Log.LogMessage($"Converting project references to nuget dependency packages for '{prjFile.ItemSpec}'");
                ProjectMigrator mgrt = new ProjectMigrator(Log, prjFile, AllProjects, PackageVersion);
                mgrt.PackageIdPrefix = PackageIdPrefix;
                mgrt.MigrateProjectReferences();
            }

            return(true);
        }
        private string QuotedIncludePaths()
        {
            string sd  = SolutionDir.ToLower();
            string rtn = "";

            string[] includes = IncludePaths.Split(new char[1] {
                ';'
            });
            foreach (string p in includes)
            {
                rtn += """;
                if (p.Length > sd.Length && p.Substring(0, sd.Length).ToLower() == sd)
                {
                    string rp = p.Substring(sd.Length); // relative path
                    if (rp[0] == '\\')
                    {
                        rp = rp.Substring(1);
                    }
                    rtn += "$(SolutionDir)" + rp;
                }
                else
                {
                    rtn += p;
                }
                rtn += "";";
            }
            // strip off the last semicolon to match VS
            if (rtn.Length > 0)
            {
                rtn = rtn.Substring(0, rtn.Length - 1);
            }
            return(rtn);
        }