mirror of https://github.com/abpframework/abp.git
12 changed files with 97 additions and 58 deletions
@ -0,0 +1,36 @@ |
|||||
|
using System.IO; |
||||
|
using System.Xml; |
||||
|
using Volo.Abp.Cli.Utils; |
||||
|
using Volo.Abp.DependencyInjection; |
||||
|
|
||||
|
namespace Volo.Abp.Cli.ProjectModification |
||||
|
{ |
||||
|
public class SolutionAbpVersionFinder : ITransientDependency |
||||
|
{ |
||||
|
public string Find(string solutionFile) |
||||
|
{ |
||||
|
var projectFilesUnderSrc = Directory.GetFiles(Path.GetDirectoryName(solutionFile), |
||||
|
"*.csproj", |
||||
|
SearchOption.AllDirectories); |
||||
|
|
||||
|
foreach (var projectFile in projectFilesUnderSrc) |
||||
|
{ |
||||
|
var content = File.ReadAllText(projectFile); |
||||
|
var doc = new XmlDocument() { PreserveWhitespace = true }; |
||||
|
|
||||
|
doc.Load(StreamHelper.GenerateStreamFromString(content)); |
||||
|
|
||||
|
var nodes = doc.SelectNodes("/Project/ItemGroup/PackageReference[starts-with(@Include, 'Volo.Abp')]"); |
||||
|
|
||||
|
var value = nodes?[0]?.Attributes?["Version"]?.Value; |
||||
|
|
||||
|
if (value != null) |
||||
|
{ |
||||
|
return value; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
return null; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,20 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.IO; |
||||
|
using System.Text; |
||||
|
|
||||
|
namespace Volo.Abp.Cli.Utils |
||||
|
{ |
||||
|
public static class StreamHelper |
||||
|
{ |
||||
|
public static Stream GenerateStreamFromString(string s) |
||||
|
{ |
||||
|
var stream = new MemoryStream(); |
||||
|
var writer = new StreamWriter(stream); |
||||
|
writer.Write(s); |
||||
|
writer.Flush(); |
||||
|
stream.Position = 0; |
||||
|
return stream; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue