Exemplo n.º 1
0
        public IEnumerable <VersionUpdateResult> UpdateVersion(string projectFile,
                                                               string nameFilter, string versionFilter, string newVersion)
        {
            var doc   = XDocument.Parse(File.ReadAllText(projectFile));
            var items = new PackageReferenceXmlReader(doc)
                        .GetPackageReferenceElements(nameFilter, versionFilter);

            if (!items.Any())
            {
                return(null);
            }

            var pr = _mapper.Map(items);

            var simpleExec = new SimpleExec();

            var versionUpdResults = new List <VersionUpdateResult>();

            foreach (var i in pr)
            {
                // use dotnet to upgrade package, takes care of dependencies than
                var args      = $"add \"{projectFile}\" package \"{i.Name}\" -v \"{newVersion}\"";
                var resulting = simpleExec.Exec("dotnet", args);

                versionUpdResults.Add(new VersionUpdateResult()
                {
                    Name            = i.Name,
                    OriginalVersion = i.Version,
                    NewVersion      = newVersion,
                    Message         = $"ExitCode:{resulting}"
                });
            }

            return(versionUpdResults);
        }
Exemplo n.º 2
0
        public IEnumerable <VersionUpdateResult> UpdateVersion(XDocument doc, string nameFilter, string versionFilter,
                                                               string newVersion)
        {
            var xmlReader  = new PackageReferenceXmlReader(doc);
            var fndResults = xmlReader.GetPackageReferenceElements(nameFilter, versionFilter);
            var result     = SetPackageVersion(fndResults, newVersion, out var updResults);

            return(updResults);
        }