diff --git a/InstallTool.bat b/InstallTool.bat
index e1f0e4d47..83f7cc95c 100644
--- a/InstallTool.bat
+++ b/InstallTool.bat
@@ -1,3 +1,3 @@
-dotnet tool update -g --add-source .\nupkgs Materal.Tools.Command
-dotnet tool update -g --add-source .\nupkgs Materal.Logger.LoggerTrace
+dotnet tool update -g --add-source .\NugetPackages Materal.Tools.Command
+dotnet tool update -g --add-source .\NugetPackages Materal.Logger.LoggerTrace
pause
\ No newline at end of file
diff --git a/Materal/Packable.props b/Materal/Packable.props
index 048a88ba2..997fabd29 100644
--- a/Materal/Packable.props
+++ b/Materal/Packable.props
@@ -9,7 +9,7 @@
Materal
Materal
zh-CN
- 1.1.77
+ 1.1.78
https://github.com/MateralCMX/Materal
README.md
LICENSE
diff --git a/Materal/Src/Materal.Tools.Command/Materal.Tools.Command.csproj b/Materal/Src/Materal.Tools.Command/Materal.Tools.Command.csproj
index bca0f5bc1..a20b059c7 100644
--- a/Materal/Src/Materal.Tools.Command/Materal.Tools.Command.csproj
+++ b/Materal/Src/Materal.Tools.Command/Materal.Tools.Command.csproj
@@ -3,12 +3,13 @@
Exe
net6.0;net8.0
+ true
Materal工具
Materal命令行工具
MateralTools
-
+
diff --git a/Materal/Src/Materal.Tools.Command/Program.MateralPublish.cs b/Materal/Src/Materal.Tools.Command/Program.MateralPublish.cs
deleted file mode 100644
index b67e0fca3..000000000
--- a/Materal/Src/Materal.Tools.Command/Program.MateralPublish.cs
+++ /dev/null
@@ -1,65 +0,0 @@
-using Materal.Tools.Core.MateralPublish;
-using Microsoft.Extensions.DependencyInjection;
-using System.CommandLine;
-using SubCommand = System.CommandLine.Command;
-
-namespace Materal.Tools.Command
-{
- public partial class Program
- {
- ///
- /// 添加MateralPublish命令
- ///
- ///
- [AddSubCommand]
- public void AddMateralPublishCommand(RootCommand rootCommand)
- {
- SubCommand command = new("MateralPublish", "发布Materal项目");
-
- Option pathOption = new("--Path", "指定路径");
- pathOption.AddAlias("-p");
- pathOption.IsRequired = false;
- pathOption.SetDefaultValue(null);
- command.AddOption(pathOption);
-
- Option versionOption = new("--Version", "指定路径");
- versionOption.AddAlias("-v");
- versionOption.IsRequired = false;
- versionOption.SetDefaultValue(null);
- command.AddOption(versionOption);
-
- command.SetHandler(MateralPublishAsync, pathOption, versionOption);
- rootCommand.AddCommand(command);
- }
- private async Task MateralPublishAsync(string? path, string? version)
- {
- if (string.IsNullOrWhiteSpace(path))
- {
- path = Environment.CurrentDirectory;
- }
- IMateralPublishService service = _serviceProvider.GetRequiredService();
- DirectoryInfo directoryInfo = new(path);
- DirectoryInfo rootDirectoryInfo = service.GetMateralProjectRootPath(directoryInfo.FullName);
- version ??= service.GetNowVersion(rootDirectoryInfo.FullName);
- ICollection allProjects = service.GetAllProjects();
- if (directoryInfo.FullName == rootDirectoryInfo.FullName)//发布所有项目
- {
- await service.PublishAsync(directoryInfo.FullName, version, allProjects);
- }
- else if (directoryInfo.Parent?.FullName == rootDirectoryInfo.FullName && directoryInfo.Name.StartsWith("Level"))//发布一个等级的项目
- {
- int level = Convert.ToInt32(directoryInfo.Name[5..]);
- ICollection levelProjects = allProjects.Where(m => m.Level == level).ToList();
- await service.PublishAsync(rootDirectoryInfo.FullName, version, levelProjects);
- }
- else if (directoryInfo.Parent?.Parent?.FullName == rootDirectoryInfo.FullName)//发布一个独立的项目
- {
- string name = directoryInfo.Name;
- int level = Convert.ToInt32(directoryInfo.Parent.Name[5..]);
- IMateralProject? project = allProjects.FirstOrDefault(m => m.Level == level && m.Name == name);
- if (project is null) return;
- await service.PublishAsync(rootDirectoryInfo.FullName, version, [project]);
- }
- }
- }
-}
diff --git a/Materal/Src/Materal.Tools.Command/Program.MateralVersion.cs b/Materal/Src/Materal.Tools.Command/Program.MateralVersion.cs
deleted file mode 100644
index 4f19073d0..000000000
--- a/Materal/Src/Materal.Tools.Command/Program.MateralVersion.cs
+++ /dev/null
@@ -1,51 +0,0 @@
-using Materal.Tools.Core.MateralVersion;
-using Microsoft.Extensions.DependencyInjection;
-using System.CommandLine;
-using SubCommand = System.CommandLine.Command;
-
-namespace Materal.Tools.Command
-{
- public partial class Program
- {
- ///
- /// 添加MateralVersion命令
- ///
- ///
- [AddSubCommand]
- public void AddMateralVersionCommand(RootCommand rootCommand)
- {
- SubCommand command = new("MateralVersion", "更改Materal的版本");
-
- Option pathOption = new("--Path", "指定路径");
- pathOption.AddAlias("-p");
- pathOption.IsRequired = false;
- pathOption.SetDefaultValue(null);
- command.AddOption(pathOption);
-
- Option versionOption = new("--Version", "指定版本");
- versionOption.AddAlias("-v");
- versionOption.IsRequired = false;
- versionOption.SetDefaultValue(null);
- command.AddOption(versionOption);
-
- command.SetHandler(MateralVersion, pathOption, versionOption);
- rootCommand.AddCommand(command);
- }
- private void MateralVersion(string? path, string? version)
- {
- if (string.IsNullOrWhiteSpace(path))
- {
- path = Environment.CurrentDirectory;
- }
- IMateralVersionService service = _serviceProvider.GetRequiredService();
- if (string.IsNullOrWhiteSpace(version))
- {
- service.UpdateVersionAsync(path);
- }
- else
- {
- service.UpdateVersionAsync(path, version);
- }
- }
- }
-}
diff --git a/Materal/Src/Materal.Tools.Command/Properties/launchSettings.json b/Materal/Src/Materal.Tools.Command/Properties/launchSettings.json
index 55daa7e32..0d9bce5e4 100644
--- a/Materal/Src/Materal.Tools.Command/Properties/launchSettings.json
+++ b/Materal/Src/Materal.Tools.Command/Properties/launchSettings.json
@@ -2,7 +2,7 @@
"profiles": {
"Materal.Tools.Command": {
"commandName": "Project",
- "commandLineArgs": "MateralPublish"
+ "commandLineArgs": "ProjectClear"
}
}
}
\ No newline at end of file
diff --git a/Materal/Src/Materal.Tools.Core/DIExtensions.cs b/Materal/Src/Materal.Tools.Core/DIExtensions.cs
index d58d5061c..993f469cf 100644
--- a/Materal/Src/Materal.Tools.Core/DIExtensions.cs
+++ b/Materal/Src/Materal.Tools.Core/DIExtensions.cs
@@ -1,8 +1,6 @@
using Materal.Tools.Core.ChangeEncoding;
using Materal.Tools.Core.LFConvert;
using Materal.Tools.Core.Logger;
-using Materal.Tools.Core.MateralPublish;
-using Materal.Tools.Core.MateralVersion;
using Materal.Tools.Core.ProjectClear;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
@@ -23,8 +21,6 @@ public static IServiceCollection AddMateralTools(this IServiceCollection service
{
services.AddSingleton();
services.AddSingleton();
- services.AddSingleton();
- services.AddSingleton();
services.AddSingleton();
#region AddLogger
services.AddLogging(builder =>
diff --git a/Materal/Src/Materal.Tools.Core/MateralPublish/IMateralProject.cs b/Materal/Src/Materal.Tools.Core/MateralPublish/IMateralProject.cs
deleted file mode 100644
index 5fe11e1c1..000000000
--- a/Materal/Src/Materal.Tools.Core/MateralPublish/IMateralProject.cs
+++ /dev/null
@@ -1,36 +0,0 @@
-namespace Materal.Tools.Core.MateralPublish
-{
- ///
- /// Materal项目
- ///
- public interface IMateralProject
- {
- ///
- /// 等级
- ///
- int Level { get; }
- ///
- /// 位序
- ///
- int Index { get; }
- ///
- /// 名称
- ///
- string Name { get; }
- ///
- /// 获取根目录信息
- ///
- ///
- ///
- DirectoryInfo GetRootDirectoryInfo(DirectoryInfo projectDirectoryInfo);
- ///
- /// 发布
- ///
- ///
- ///
- ///
- ///
- ///
- Task PublishAsync(DirectoryInfo projectDirectoryInfo, string version, DirectoryInfo? nugetDirectoryInfo = null, DirectoryInfo? publishDirectoryInfo = null);
- }
-}
diff --git a/Materal/Src/Materal.Tools.Core/MateralPublish/IMateralPublishService.cs b/Materal/Src/Materal.Tools.Core/MateralPublish/IMateralPublishService.cs
deleted file mode 100644
index 67654939f..000000000
--- a/Materal/Src/Materal.Tools.Core/MateralPublish/IMateralPublishService.cs
+++ /dev/null
@@ -1,40 +0,0 @@
-namespace Materal.Tools.Core.MateralPublish
-{
- ///
- /// Materal发布服务
- ///
- public interface IMateralPublishService
- {
- ///
- /// 获取所有项目
- ///
- ///
- ICollection GetAllProjects();
- ///
- /// 获得当前版本号
- ///
- ///
- ///
- string GetNowVersion(string projectPath);
- ///
- /// 发布
- ///
- ///
- ///
- ///
- ///
- Task PublishAsync(string projectPath, string version, ICollection projects);
- ///
- /// 是Materal项目路径
- ///
- ///
- ///
- bool IsMateralProjectPath(string projectPath);
- ///
- /// 获得Materal项目根路径
- ///
- ///
- ///
- DirectoryInfo GetMateralProjectRootPath(string projectPath);
- }
-}
diff --git a/Materal/Src/Materal.Tools.Core/MateralPublish/MateralProjects/BaseMateralProject.cs b/Materal/Src/Materal.Tools.Core/MateralPublish/MateralProjects/BaseMateralProject.cs
deleted file mode 100644
index 41a45c295..000000000
--- a/Materal/Src/Materal.Tools.Core/MateralPublish/MateralProjects/BaseMateralProject.cs
+++ /dev/null
@@ -1,462 +0,0 @@
-using Microsoft.Extensions.Logging;
-using System.Diagnostics;
-using System.Text;
-using System.Xml;
-
-namespace Materal.Tools.Core.MateralPublish.MateralProjects
-{
- ///
- /// 基础Materal项目
- ///
- public abstract class BaseMateralProject : IMateralProject
- {
- ///
- /// 等级
- ///
- public int Level { get; }
- ///
- /// 位序
- ///
- public int Index { get; }
- ///
- /// 名称
- ///
- public string Name { get; }
- ///
- /// 日志对象
- ///
- protected ILogger? Logger { get; }
- ///
- /// 构造方法
- ///
- ///
- ///
- ///
- ///
- public BaseMateralProject(int level, int index, string name, ILoggerFactory? loggerFactory = null)
- {
- Level = level;
- Index = index;
- Name = name;
- Logger = loggerFactory?.CreateLogger(GetType());
- }
- ///
- /// 获得根目录信息
- ///
- ///
- ///
- public DirectoryInfo GetRootDirectoryInfo(DirectoryInfo projectDirectoryInfo)
- {
- string rootPath = Path.Combine(projectDirectoryInfo.FullName, $"Level{Level}", Name);
- DirectoryInfo rootDirectoryInfo = new(rootPath);
- return rootDirectoryInfo;
- }
- ///
- /// 发布
- ///
- ///
- ///
- ///
- ///
- ///
- public virtual async Task PublishAsync(DirectoryInfo projectDirectoryInfo, string version, DirectoryInfo? nugetDirectoryInfo = null, DirectoryInfo? publishDirectoryInfo = null)
- {
- nugetDirectoryInfo ??= Path.Combine(projectDirectoryInfo.FullName, "Nupkgs").GetNewDirectoryInfo();
- publishDirectoryInfo ??= Path.Combine(projectDirectoryInfo.FullName, "Publish").GetNewDirectoryInfo();
- DirectoryInfo rootDirectoryInfo = GetRootDirectoryInfo(projectDirectoryInfo);
- await UpdateVersionAsync(version, rootDirectoryInfo);
- await PackageAsync(rootDirectoryInfo, nugetDirectoryInfo);
- await PublishAsync(rootDirectoryInfo, publishDirectoryInfo);
- }
- #region 版本更新
- ///
- /// 更新版本
- ///
- ///
- ///
- ///
- protected virtual async Task UpdateVersionAsync(string version, DirectoryInfo directoryInfo)
- {
- if (!directoryInfo.Exists) throw new ToolsException($"{directoryInfo.FullName}不存在");
- FileInfo? csprojFileInfo = directoryInfo.GetFiles().FirstOrDefault(m => m.Extension == ".csproj");
- FileInfo? vsixmanifestFileInfo = directoryInfo.GetFiles().FirstOrDefault(m => m.Name == "source.extension.vsixmanifest");
- if (vsixmanifestFileInfo != null)
- {
- await UpdateVsixVersionAsync(version, vsixmanifestFileInfo);
- }
- else if (csprojFileInfo != null)
- {
- await UpdateCsprojVersionAsync(version, csprojFileInfo);
- }
- else
- {
- IEnumerable subDirectoryInfos = directoryInfo.GetDirectories();
- foreach (DirectoryInfo subDirectoryInfo in subDirectoryInfos)
- {
- await UpdateVersionAsync(version, subDirectoryInfo);
- }
- }
- }
- ///
- /// 更新版本
- ///
- ///
- ///
- ///
- protected virtual async Task UpdateVsixVersionAsync(string version, FileInfo fileInfo)
- {
- string projectName = Path.GetFileNameWithoutExtension(fileInfo.Name);
- XmlDocument xmlDocument = new();
- xmlDocument.Load(fileInfo.FullName);
- XmlNamespaceManager nsmgr = new(xmlDocument.NameTable);
- nsmgr.AddNamespace("vsx", "http://schemas.microsoft.com/developer/vsx-schema/2011");
- XmlNode identityNode = xmlDocument.SelectSingleNode("//vsx:Identity", nsmgr) ?? throw new ToolsException($"{fileInfo.FullName}文件格式错误");
- if (identityNode.Attributes is null || identityNode.Attributes.Count <= 0) return;
- XmlAttribute? versionAttribute = identityNode.Attributes["Version"];
- if (versionAttribute is null) return;
- if (!versionAttribute.Value.StartsWith(version))
- {
- string newVersion = $"{version}.1";
- Logger?.LogInformation($"正在更新{projectName}版本到{newVersion}");
- versionAttribute.Value = newVersion;
- }
- string xmlContent = xmlDocument.GetFormatXmlContent();
- xmlContent = xmlContent.Trim();
- await File.WriteAllTextAsync(fileInfo.FullName, xmlContent, Encoding.UTF8);
- }
- ///
- /// 更新版本
- ///
- ///
- ///
- ///
- protected virtual async Task UpdateCsprojVersionAsync(string version, FileInfo fileInfo)
- {
- string projectName = Path.GetFileNameWithoutExtension(fileInfo.Name);
- XmlDocument xmlDocument = new();
- xmlDocument.Load(fileInfo.FullName);
- XmlNode? projectNode = xmlDocument.SelectSingleNode("//Project");
- if (projectNode is null) return;
- foreach (XmlNode node in projectNode.ChildNodes)
- {
- switch (node.Name)
- {
- case "PropertyGroup":
- UpdateCsprojPropertyGroupVersion(projectName, version, node);
- break;
- case "ItemGroup":
- UpdateCsprojItemGroupVersion(projectName, version, node);
- break;
- }
- }
- string xmlContent = xmlDocument.GetFormatXmlContent();
- xmlContent = xmlContent.StartsWith(" xmlContent[(xmlContent.IndexOf("?>", StringComparison.Ordinal) + 2)..],
- false => xmlContent
- };
- xmlContent = xmlContent.Trim();
- await File.WriteAllTextAsync(fileInfo.FullName, xmlContent, Encoding.UTF8);
- }
- ///
- /// 更新Csproj PropertyGroup版本
- ///
- ///
- ///
- ///
- protected virtual void UpdateCsprojPropertyGroupVersion(string projectName, string version, XmlNode node)
- {
- foreach (XmlNode childNode in node.ChildNodes)
- {
- if (childNode.Name != "Version") continue;
- if (childNode.InnerText == version) return;
- Logger?.LogInformation($"正在更新{projectName}版本到{version}");
- childNode.InnerText = version;
- return;
- }
- }
- ///
- /// 更新Csproj PropertyGroup版本
- ///
- ///
- ///
- ///
- protected virtual void UpdateCsprojItemGroupVersion(string projectName, string version, XmlNode node)
- {
- foreach (XmlNode childNode in node.ChildNodes)
- {
- if (childNode.Name != "PackageReference" || childNode.Attributes is null || childNode.Attributes.Count <= 0) continue;
- XmlAttribute? nameAttribute = childNode.Attributes["Include"];
- if (nameAttribute is null || (!nameAttribute.Value.StartsWith("Materal.") && !nameAttribute.Value.StartsWith("RC."))) continue;
- XmlAttribute? versionAttribute = childNode.Attributes["Version"];
- if (versionAttribute is null) continue;
- if (versionAttribute.Value == version) return;
- Logger?.LogInformation($"正在更新{projectName}->{nameAttribute.Value}的版本到{version}");
- versionAttribute.Value = version;
- return;
- }
- }
- #endregion
- #region 打包
- ///
- /// 打包
- ///
- ///
- ///
- ///
- protected virtual async Task PackageAsync(DirectoryInfo directoryInfo, DirectoryInfo nugetDirectoryInfo)
- {
- if (!directoryInfo.Exists) throw new ToolsException($"{directoryInfo.FullName}不存在");
- FileInfo? csprojFileInfo = directoryInfo.GetFiles().FirstOrDefault(m => m.Extension == ".csproj");
- if (csprojFileInfo != null)
- {
- if (!CanPackage(csprojFileInfo)) return;
- await PackageAsync(csprojFileInfo, nugetDirectoryInfo);
- }
- else
- {
- IEnumerable subDirectoryInfos = directoryInfo.GetDirectories();
- foreach (DirectoryInfo subDirectoryInfo in subDirectoryInfos)
- {
- await PackageAsync(subDirectoryInfo, nugetDirectoryInfo);
- }
- }
- }
- ///
- /// 打包
- ///
- ///
- ///
- protected virtual bool CanPackage(FileInfo fileInfo)
- {
- if (!fileInfo.Exists) return false;
- XmlDocument xmlDocument = new();
- xmlDocument.Load(fileInfo.FullName);
- XmlNode? isPackableNode = xmlDocument.SelectSingleNode("//Project//PropertyGroup//IsPackable");
- if (isPackableNode is null) return false;
- if (!string.IsNullOrWhiteSpace(isPackableNode.InnerText) && isPackableNode.InnerText.Equals("true", StringComparison.OrdinalIgnoreCase)) return true;
- return false;
- }
- ///
- /// 打包
- ///
- ///
- ///
- ///
- protected virtual async Task PackageAsync(FileInfo fileInfo, DirectoryInfo nugetDirectoryInfo)
- {
- string projectName = Path.GetFileNameWithoutExtension(fileInfo.Name);
- CmdHelper cmdHelper = new();
- string[] cmds = GetPackageCommand(fileInfo, nugetDirectoryInfo);
- Logger?.LogInformation($"正在打包{projectName}...");
- cmdHelper.OutputDataReceived += CmdHelper_OutputDataReceived;
- cmdHelper.ErrorDataReceived += CmdHelper_ErrorDataReceived;
- await cmdHelper.RunCmdCommandsAsync(cmds);
- Logger?.LogInformation($"{projectName}打包完毕");
- }
-
- ///
- /// 获得发布命令
- ///
- ///
- ///
- ///
- protected virtual string[] GetPackageCommand(FileInfo fileInfo, DirectoryInfo nugetDirectoryInfo)
- => [$"msbuild {fileInfo.FullName} /t:restore",
- $"msbuild {fileInfo.FullName} /t:pack /t:Rebuild /p:Configuration=Release /p:PackageOutputPath={nugetDirectoryInfo}"];
- #endregion
- #region 发布
- ///
- /// 发布
- ///
- ///
- ///
- ///
- protected virtual async Task PublishAsync(DirectoryInfo directoryInfo, DirectoryInfo publishDirectoryInfo)
- {
- if (!directoryInfo.Exists) throw new ToolsException($"{directoryInfo.FullName}不存在");
- FileInfo? csprojFileInfo = directoryInfo.GetFiles().FirstOrDefault(m => m.Extension == ".csproj");
- if (csprojFileInfo != null)
- {
- if (CanPublish(csprojFileInfo))
- {
- await PublishAsync(csprojFileInfo, publishDirectoryInfo);
- }
- else if (CanPublishVSIX(csprojFileInfo))
- {
- await PublishVSIXAsync(csprojFileInfo, publishDirectoryInfo);
- }
- }
- else
- {
- IEnumerable subDirectoryInfos = directoryInfo.GetDirectories();
- foreach (DirectoryInfo subDirectoryInfo in subDirectoryInfos)
- {
- await PublishAsync(subDirectoryInfo, publishDirectoryInfo);
- }
- }
- }
- ///
- /// 能否发布
- ///
- ///
- ///
- protected virtual bool CanPublish(FileInfo fileInfo)
- {
- if (!fileInfo.Exists) return false;
- XmlDocument xmlDocument = new();
- xmlDocument.Load(fileInfo.FullName);
- XmlNode? isPublishNode = xmlDocument.SelectSingleNode("//Project//PropertyGroup//IsPublish");
- if (isPublishNode is null) return false;
- if (!string.IsNullOrWhiteSpace(isPublishNode.InnerText) && isPublishNode.InnerText.Equals("true", StringComparison.OrdinalIgnoreCase)) return true;
- return false;
- }
- ///
- /// 发布
- ///
- ///
- ///
- ///
- protected virtual async Task PublishAsync(FileInfo fileInfo, DirectoryInfo publishDirectoryInfo)
- {
- string projectName = Path.GetFileNameWithoutExtension(fileInfo.Name);
- CmdHelper cmdHelper = new();
- string[] cmds = GetPublishCommand(fileInfo, publishDirectoryInfo);
- Logger?.LogInformation($"正在发布{projectName}...");
- cmdHelper.OutputDataReceived += CmdHelper_OutputDataReceived;
- cmdHelper.ErrorDataReceived += CmdHelper_ErrorDataReceived;
- await cmdHelper.RunCmdCommandsAsync(cmds);
- Logger?.LogInformation($"{projectName}发布完毕");
- }
- ///
- /// 获得发布命令
- ///
- ///
- ///
- ///
- protected virtual string[] GetPublishCommand(FileInfo fileInfo, DirectoryInfo publishDirectoryInfo)
- {
- List cmds = [$"msbuild {fileInfo.FullName} /t:restore",];
- XmlDocument xmlDocument = new();
- xmlDocument.Load(fileInfo.FullName);
- XmlNode? targetFrameworksNode = xmlDocument.SelectSingleNode("//Project//PropertyGroup//TargetFrameworks");
- if (targetFrameworksNode is null)
- {
- cmds.Add(GetPublishCommand(fileInfo, publishDirectoryInfo, null));
- }
- else
- {
- string[] targets = targetFrameworksNode.InnerText.Split(';');
- foreach (string target in targets)
- {
- cmds.Add(GetPublishCommand(fileInfo, publishDirectoryInfo, target));
- }
- }
- return [.. cmds];
- }
- ///
- /// 获得发布命令
- ///
- ///
- ///
- ///
- ///
- protected virtual string GetPublishCommand(FileInfo fileInfo, DirectoryInfo publishDirectoryInfo, string? targetFrameworks)
- {
- string projectName = Path.GetFileNameWithoutExtension(fileInfo.Name);
- StringBuilder cmdBuilder = new();
- cmdBuilder.Append($"msbuild {fileInfo.FullName} /t:Rebuild /p:Configuration=Release");
- DirectoryInfo publishProjectDirectoryInfo = Path.Combine(publishDirectoryInfo.FullName, projectName).GetNewDirectoryInfo();
- if (!string.IsNullOrWhiteSpace(targetFrameworks))
- {
- publishProjectDirectoryInfo = Path.Combine(publishProjectDirectoryInfo.FullName, targetFrameworks).GetNewDirectoryInfo();
- cmdBuilder.Append($" /p:TargetFramework={targetFrameworks}");
- }
- string? publishPath = publishProjectDirectoryInfo.FullName;
- cmdBuilder.Append($" /p:OutputPath={publishPath}");
- string cmd = cmdBuilder.ToString();
- return cmd;
- }
- ///
- /// 能否发布VS插件
- ///
- ///
- ///
- protected virtual bool CanPublishVSIX(FileInfo fileInfo)
- {
- if (!fileInfo.Exists || fileInfo.Directory is null || !fileInfo.Directory.GetFiles().Any(m => m.Name == "source.extension.vsixmanifest")) return false;
- XmlDocument xmlDocument = new();
- xmlDocument.Load(fileInfo.FullName);
- XmlNamespaceManager nsmgr = new(xmlDocument.NameTable);
- nsmgr.AddNamespace("vsx", "http://schemas.microsoft.com/developer/msbuild/2003");
- XmlNode? isPublishNode = xmlDocument.SelectSingleNode("//vsx:IsPublish", nsmgr);
- if (isPublishNode is null) return false;
- if (!string.IsNullOrWhiteSpace(isPublishNode.InnerText) && isPublishNode.InnerText.Equals("true", StringComparison.OrdinalIgnoreCase)) return true;
- return false;
- }
- ///
- /// 发布VS插件
- ///
- ///
- ///
- ///
- protected virtual async Task PublishVSIXAsync(FileInfo fileInfo, DirectoryInfo publishDirectoryInfo)
- {
- string projectName = Path.GetFileNameWithoutExtension(fileInfo.Name);
- CmdHelper cmdHelper = new();
- DirectoryInfo publishProjectDirectoryInfo = Path.Combine(publishDirectoryInfo.FullName, projectName).GetNewDirectoryInfo();
- string[] cmds = GetPublishVSIXCommand(fileInfo, publishProjectDirectoryInfo);
- Logger?.LogInformation($"正在发布VS插件{projectName}...");
- cmdHelper.OutputDataReceived += CmdHelper_OutputDataReceived;
- cmdHelper.ErrorDataReceived += CmdHelper_ErrorDataReceived;
- await cmdHelper.RunCmdCommandsAsync(cmds);
- FileInfo vsixFileInfo = new(Path.Combine(publishProjectDirectoryInfo.FullName, $"{projectName}.vsix"));
- if (!vsixFileInfo.Exists) throw new ToolsException($"{vsixFileInfo.FullName}不存在");
- vsixFileInfo.MoveTo(Path.Combine(publishDirectoryInfo.FullName, vsixFileInfo.Name));
- publishProjectDirectoryInfo.Delete(true);
- Logger?.LogInformation($"VS插件{projectName}发布完毕");
- }
- ///
- /// 获得发布命令
- ///
- ///
- ///
- ///
- protected virtual string[] GetPublishVSIXCommand(FileInfo fileInfo, DirectoryInfo publishDirectoryInfo)
- => [$"msbuild {fileInfo.FullName} /t:restore",
- $"msbuild {fileInfo.FullName} /t:Rebuild /p:Configuration=Release /p:OutputPath={publishDirectoryInfo.FullName}"];
- #endregion
- ///
- /// 输出错误
- ///
- ///
- ///
- private void CmdHelper_ErrorDataReceived(object sender, DataReceivedEventArgs e)
- {
- if (string.IsNullOrWhiteSpace(e.Data)) return;
- Logger?.LogError(e.Data);
- }
- ///
- /// 输出数据
- ///
- ///
- ///
- private void CmdHelper_OutputDataReceived(object sender, DataReceivedEventArgs e)
- {
- if (string.IsNullOrWhiteSpace(e.Data)) return;
- LogLevel logLevel = LogLevel.Information;
- if (!string.IsNullOrWhiteSpace(e.Data))
- {
- if (e.Data.Contains(" error ", StringComparison.OrdinalIgnoreCase))
- {
- logLevel = LogLevel.Error;
- }
- else if (e.Data.Contains(" warning ", StringComparison.OrdinalIgnoreCase))
- {
- logLevel = LogLevel.Warning;
- }
- }
- Logger?.Log(logLevel, e.Data);
- }
- }
-}
diff --git a/Materal/Src/Materal.Tools.Core/MateralPublish/MateralProjects/Level0/MateralProject.cs b/Materal/Src/Materal.Tools.Core/MateralPublish/MateralProjects/Level0/MateralProject.cs
deleted file mode 100644
index d73142174..000000000
--- a/Materal/Src/Materal.Tools.Core/MateralPublish/MateralProjects/Level0/MateralProject.cs
+++ /dev/null
@@ -1,11 +0,0 @@
-using Microsoft.Extensions.Logging;
-
-namespace Materal.Tools.Core.MateralPublish.MateralProjects.Level0
-{
- ///
- /// Materal项目
- ///
- public class MateralProject(ILoggerFactory? loggerFactory = null) : BaseMateralProject(0, 1, "Materal", loggerFactory)
- {
- }
-}
diff --git a/Materal/Src/Materal.Tools.Core/MateralPublish/MateralProjects/Level0/MateralToolsProject.cs b/Materal/Src/Materal.Tools.Core/MateralPublish/MateralProjects/Level0/MateralToolsProject.cs
deleted file mode 100644
index 21f1ac8ed..000000000
--- a/Materal/Src/Materal.Tools.Core/MateralPublish/MateralProjects/Level0/MateralToolsProject.cs
+++ /dev/null
@@ -1,11 +0,0 @@
-using Microsoft.Extensions.Logging;
-
-namespace Materal.Tools.Core.MateralPublish.MateralProjects.Level0
-{
- ///
- /// MateralTools项目
- ///
- public class MateralToolsProject(ILoggerFactory? loggerFactory = null) : BaseMateralProject(0, 0, "Materal.Tools", loggerFactory)
- {
- }
-}
diff --git a/Materal/Src/Materal.Tools.Core/MateralPublish/MateralProjects/Level1/ContextCacheProject.cs b/Materal/Src/Materal.Tools.Core/MateralPublish/MateralProjects/Level1/ContextCacheProject.cs
deleted file mode 100644
index b7368a6c4..000000000
--- a/Materal/Src/Materal.Tools.Core/MateralPublish/MateralProjects/Level1/ContextCacheProject.cs
+++ /dev/null
@@ -1,12 +0,0 @@
-using Microsoft.Extensions.Logging;
-
-namespace Materal.Tools.Core.MateralPublish.MateralProjects.Level1
-{
- ///
- /// 上下文缓存项目
- ///
- ///
- public class ContextCacheProject(ILoggerFactory? loggerFactory = null) : BaseMateralProject(1, 1, "Materal.ContextCache", loggerFactory)
- {
- }
-}
diff --git a/Materal/Src/Materal.Tools.Core/MateralPublish/MateralProjects/Level1/LoggerProject.cs b/Materal/Src/Materal.Tools.Core/MateralPublish/MateralProjects/Level1/LoggerProject.cs
deleted file mode 100644
index 817c0ce03..000000000
--- a/Materal/Src/Materal.Tools.Core/MateralPublish/MateralProjects/Level1/LoggerProject.cs
+++ /dev/null
@@ -1,11 +0,0 @@
-using Microsoft.Extensions.Logging;
-
-namespace Materal.Tools.Core.MateralPublish.MateralProjects.Level1
-{
- ///
- /// 日志项目
- ///
- public class LoggerProject(ILoggerFactory? loggerFactory = null) : BaseMateralProject(1, 0, "Materal.Logger", loggerFactory)
- {
- }
-}
diff --git a/Materal/Src/Materal.Tools.Core/MateralPublish/MateralProjects/Level2/EventBusProject.cs b/Materal/Src/Materal.Tools.Core/MateralPublish/MateralProjects/Level2/EventBusProject.cs
deleted file mode 100644
index 19210aaaa..000000000
--- a/Materal/Src/Materal.Tools.Core/MateralPublish/MateralProjects/Level2/EventBusProject.cs
+++ /dev/null
@@ -1,11 +0,0 @@
-using Microsoft.Extensions.Logging;
-
-namespace Materal.Tools.Core.MateralPublish.MateralProjects.Level2
-{
- ///
- /// 事件总线
- ///
- public class EventBusProject(ILoggerFactory? loggerFactory = null) : BaseMateralProject(2, 1, "Materal.EventBus", loggerFactory)
- {
- }
-}
diff --git a/Materal/Src/Materal.Tools.Core/MateralPublish/MateralProjects/Level2/OscillatorProject.cs b/Materal/Src/Materal.Tools.Core/MateralPublish/MateralProjects/Level2/OscillatorProject.cs
deleted file mode 100644
index 415024cb4..000000000
--- a/Materal/Src/Materal.Tools.Core/MateralPublish/MateralProjects/Level2/OscillatorProject.cs
+++ /dev/null
@@ -1,11 +0,0 @@
-using Microsoft.Extensions.Logging;
-
-namespace Materal.Tools.Core.MateralPublish.MateralProjects.Level2
-{
- ///
- /// 调度器
- ///
- public class OscillatorProject(ILoggerFactory? loggerFactory = null) : BaseMateralProject(2, 2, "Materal.Oscillator", loggerFactory)
- {
- }
-}
diff --git a/Materal/Src/Materal.Tools.Core/MateralPublish/MateralProjects/Level2/TTAProject.cs b/Materal/Src/Materal.Tools.Core/MateralPublish/MateralProjects/Level2/TTAProject.cs
deleted file mode 100644
index 28ac82073..000000000
--- a/Materal/Src/Materal.Tools.Core/MateralPublish/MateralProjects/Level2/TTAProject.cs
+++ /dev/null
@@ -1,11 +0,0 @@
-using Microsoft.Extensions.Logging;
-
-namespace Materal.Tools.Core.MateralPublish.MateralProjects.Level2
-{
- ///
- /// TTA框架
- ///
- public class TTAProject(ILoggerFactory? loggerFactory = null) : BaseMateralProject(2, 0, "Materal.ThreeTierArchitecture", loggerFactory)
- {
- }
-}
diff --git a/Materal/Src/Materal.Tools.Core/MateralPublish/MateralProjects/Level4/MergeBlockProject.cs b/Materal/Src/Materal.Tools.Core/MateralPublish/MateralProjects/Level4/MergeBlockProject.cs
deleted file mode 100644
index d5e474b04..000000000
--- a/Materal/Src/Materal.Tools.Core/MateralPublish/MateralProjects/Level4/MergeBlockProject.cs
+++ /dev/null
@@ -1,11 +0,0 @@
-using Microsoft.Extensions.Logging;
-
-namespace Materal.Tools.Core.MateralPublish.MateralProjects.Level4
-{
- ///
- /// MergeBlock
- ///
- public class MergeBlockProject(ILoggerFactory? loggerFactory = null) : BaseMateralProject(4, 0, "Materal.MergeBlock", loggerFactory)
- {
- }
-}
diff --git a/Materal/Src/Materal.Tools.Core/MateralPublish/MateralProjects/Level5/GatewayProject.cs b/Materal/Src/Materal.Tools.Core/MateralPublish/MateralProjects/Level5/GatewayProject.cs
deleted file mode 100644
index 37f2d8b38..000000000
--- a/Materal/Src/Materal.Tools.Core/MateralPublish/MateralProjects/Level5/GatewayProject.cs
+++ /dev/null
@@ -1,11 +0,0 @@
-using Microsoft.Extensions.Logging;
-
-namespace Materal.Tools.Core.MateralPublish.MateralProjects.Level5
-{
- ///
- /// 网关
- ///
- public class GatewayProject(ILoggerFactory? loggerFactory = null) : BaseMateralProject(5, 0, "Materal.Gateway", loggerFactory)
- {
- }
-}
diff --git a/Materal/Src/Materal.Tools.Core/MateralPublish/MateralProjects/Level5/RCProject.cs b/Materal/Src/Materal.Tools.Core/MateralPublish/MateralProjects/Level5/RCProject.cs
deleted file mode 100644
index bb631b573..000000000
--- a/Materal/Src/Materal.Tools.Core/MateralPublish/MateralProjects/Level5/RCProject.cs
+++ /dev/null
@@ -1,11 +0,0 @@
-using Microsoft.Extensions.Logging;
-
-namespace Materal.Tools.Core.MateralPublish.MateralProjects.Level5
-{
- ///
- /// RC项目
- ///
- public class RCProject(ILoggerFactory? loggerFactory = null) : BaseMateralProject(5, 1, "RC", loggerFactory)
- {
- }
-}
diff --git a/Materal/Src/Materal.Tools.Core/MateralPublish/MateralPublishService.cs b/Materal/Src/Materal.Tools.Core/MateralPublish/MateralPublishService.cs
deleted file mode 100644
index 813dd6d2b..000000000
--- a/Materal/Src/Materal.Tools.Core/MateralPublish/MateralPublishService.cs
+++ /dev/null
@@ -1,139 +0,0 @@
-using Microsoft.Extensions.Logging;
-
-namespace Materal.Tools.Core.MateralPublish
-{
- ///
- /// Materal发布服务
- ///
- public class MateralPublishService(ILoggerFactory? loggerFactory = null) : IMateralPublishService
- {
- private readonly ILogger? _logger = loggerFactory?.CreateLogger();
- ///
- /// 获得所有项目
- ///
- ///
- ///
- public ICollection GetAllProjects()
- {
- Type baseProjectType = typeof(IMateralProject);
- List allProjectTypes = baseProjectType.Assembly.GetTypes().Where(m => !m.IsAbstract && m.IsAssignableTo(baseProjectType)).ToList();
- List _projects = [];
- foreach (Type projectType in allProjectTypes)
- {
- ConstructorInfo? constructorInfo = projectType.GetConstructor([typeof(ILoggerFactory)]) ?? throw new ToolsException("未找到构造函数");
- object projectObj = constructorInfo.Invoke([loggerFactory]);
- if (projectObj is not IMateralProject projectModel) throw new ToolsException("类型不是IMateralProject");
- _projects.Add(projectModel);
- }
- _projects = [.. _projects.OrderBy(m => m.Level).ThenBy(m => m.Index).ThenBy(m => m.Name)];
- return _projects;
- }
- ///
- /// 获得当前版本号
- ///
- ///
- ///
- ///
- public string GetNowVersion(string projectPath)
- {
- DirectoryInfo projectDirectoryInfo = GetMateralProjectRootPath(projectPath);
- if (!projectDirectoryInfo.Exists) throw new ToolsException($"\"{projectDirectoryInfo}\"文件夹不存在");
- string csprojFilePath = Path.Combine(projectDirectoryInfo.FullName, "Level0", "Materal", "Src", "Materal.Abstractions", "Materal.Abstractions.csproj");
- FileInfo csprojFileInfo = new(csprojFilePath);
- if (!csprojFileInfo.Exists) throw new ToolsException($"\"{csprojFileInfo.FullName}\"不存在");
- string[] codeContent = File.ReadAllLines(csprojFileInfo.FullName);
- const string versionStartCode = "";
- const string versionEndCode = "";
- foreach (string code in codeContent)
- {
- string tempCode = code.Trim();
- if (tempCode.StartsWith(versionStartCode))
- {
- int endStartIndex = tempCode.IndexOf(versionEndCode);
- string result = tempCode[versionStartCode.Length..endStartIndex];
- return result;
- }
- }
- throw new ToolsException("未找到版本号");
- }
- ///
- /// 获得Materal项目根路径
- ///
- ///
- ///
- ///
- public DirectoryInfo GetMateralProjectRootPath(string projectPath)
- {
- DirectoryInfo? projectDirectoryInfo = new(projectPath);
- if (!projectDirectoryInfo.Exists) throw new ToolsException($"\"{projectDirectoryInfo}\"文件夹不存在");
- string csprojFilePath = Path.Combine(projectDirectoryInfo.FullName, "Level0", "Materal", "Src", "Materal.Abstractions", "Materal.Abstractions.csproj");
- FileInfo csprojFileInfo = new(csprojFilePath);
- if (csprojFileInfo.Exists) return projectDirectoryInfo;
- projectDirectoryInfo = projectDirectoryInfo.Parent;
- if (projectDirectoryInfo is null) throw new ToolsException("未找到Materal项目根路径");
- csprojFilePath = Path.Combine(projectDirectoryInfo.FullName, "Level0", "Materal", "Src", "Materal.Abstractions", "Materal.Abstractions.csproj");
- csprojFileInfo = new(csprojFilePath);
- if (csprojFileInfo.Exists) return projectDirectoryInfo;
- projectDirectoryInfo = projectDirectoryInfo.Parent;
- if (projectDirectoryInfo is null) throw new ToolsException("未找到Materal项目根路径");
- csprojFilePath = Path.Combine(projectDirectoryInfo.FullName, "Level0", "Materal", "Src", "Materal.Abstractions", "Materal.Abstractions.csproj");
- csprojFileInfo = new(csprojFilePath);
- if (csprojFileInfo.Exists) return projectDirectoryInfo;
- throw new ToolsException("未找到Materal项目根路径");
- }
- ///
- /// 是Materal项目路径
- ///
- ///
- ///
- ///
- public bool IsMateralProjectPath(string projectPath)
- {
- try
- {
- GetMateralProjectRootPath(projectPath);
- return true;
- }
- catch
- {
- return false;
- }
- }
-
- ///
- /// 发布
- ///
- ///
- ///
- ///
- ///
- public async Task PublishAsync(string projectPath, string version, ICollection projects)
- {
- _logger?.LogInformation("开始发布...");
- ClearNugetPackages();
- DirectoryInfo projectDirectoryInfo = new(projectPath);
- foreach (IMateralProject project in projects)
- {
- _logger?.LogInformation($"开始发布{project.Name}...");
- await project.PublishAsync(projectDirectoryInfo, version);
- _logger?.LogInformation($"{project.Name}发布完毕");
- }
- _logger?.LogInformation("发布完毕");
- }
- private void ClearNugetPackages()
- {
- _logger?.LogInformation($"开始清理包缓存...");
- string nugetPackagesPath = Environment.GetEnvironmentVariable("NUGET_PACKAGES") ?? Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".nuget", "packages");
- DirectoryInfo nugetDirectoryInfo = new(nugetPackagesPath);
- if (!nugetDirectoryInfo.Exists) return;
- DirectoryInfo[] directoryInfos = nugetDirectoryInfo.GetDirectories();
- foreach (DirectoryInfo directoryInfo in directoryInfos)
- {
- if (!directoryInfo.Name.StartsWith("materal.") && !directoryInfo.Name.StartsWith("rc.")) continue;
- _logger?.LogInformation($"删除包缓存:{directoryInfo.FullName}");
- directoryInfo.Delete(true);
- }
- _logger?.LogInformation($"包缓存清理完毕");
- }
- }
-}
diff --git a/Materal/Src/Materal.Tools.Core/MateralVersion/IMateralVersionService.cs b/Materal/Src/Materal.Tools.Core/MateralVersion/IMateralVersionService.cs
deleted file mode 100644
index 09236e382..000000000
--- a/Materal/Src/Materal.Tools.Core/MateralVersion/IMateralVersionService.cs
+++ /dev/null
@@ -1,29 +0,0 @@
-namespace Materal.Tools.Core.MateralVersion
-{
- ///
- /// Materal版本服务
- ///
- public interface IMateralVersionService
- {
- ///
- /// 更新版本
- ///
- ///
- ///
- ///
- Task UpdateVersionAsync(string projectPath, string[]? nugetPaths = null);
- ///
- /// 更新版本
- ///
- ///
- ///
- ///
- Task UpdateVersionAsync(string projectPath, string version);
- ///
- /// 获得当前版本
- ///
- ///
- ///
- Task GetNowVersionAsync(string[]? nugetPaths = null);
- }
-}
diff --git a/Materal/Src/Materal.Tools.Core/MateralVersion/MateralVersionService.cs b/Materal/Src/Materal.Tools.Core/MateralVersion/MateralVersionService.cs
deleted file mode 100644
index fe48e983c..000000000
--- a/Materal/Src/Materal.Tools.Core/MateralVersion/MateralVersionService.cs
+++ /dev/null
@@ -1,247 +0,0 @@
-using Microsoft.Extensions.Logging;
-using System.Net;
-using System.Text;
-using System.Xml;
-
-namespace Materal.Tools.Core.MateralVersion
-{
- ///
- /// Materal版本服务
- ///
- public class MateralVersionService(ILogger? logger = null) : IMateralVersionService
- {
- private readonly string[] _defaultNugetPaths = {
- "https://nuget.gudianbustu.com/nuget/",
- @"E:\Project\Materal\Materal\Nupkgs"
- };
- private const string _materalID = "Materal.Abstractions";
- private readonly HttpClient _httpClient = new();
- ///
- /// 更新版本
- ///
- ///
- ///
- ///
- public async Task UpdateVersionAsync(string projectPath, string[]? nugetPaths = null)
- {
- logger?.LogInformation("正在获取最新的Materal版本...");
- string version = await GetNowVersionAsync(nugetPaths);
- logger?.LogInformation($"最新的Materal版本为{version}");
- await UpdateVersionAsync(projectPath, version);
- }
- ///
- /// 更新版本
- ///
- ///
- ///
- ///
- public async Task UpdateVersionAsync(string projectPath, string version)
- {
- logger?.LogInformation($"开始更新Materal版本到{version}...");
- DirectoryInfo directoryInfo = new(projectPath);
- await UpdateVersionAsync(version, directoryInfo);
- logger?.LogInformation("Materal版本更新完毕");
- }
- ///
- /// 更新版本
- ///
- ///
- ///
- ///
- protected virtual async Task UpdateVersionAsync(string version, DirectoryInfo directoryInfo)
- {
- if (!directoryInfo.Exists) throw new ToolsException($"{directoryInfo.FullName}不存在");
- FileInfo? csprojFileInfo = directoryInfo.GetFiles().FirstOrDefault(m => m.Extension == ".csproj");
- if (csprojFileInfo != null)
- {
- await UpdateCsprojVersionAsync(version, csprojFileInfo);
- }
- else
- {
- IEnumerable subDirectoryInfos = directoryInfo.GetDirectories();
- foreach (DirectoryInfo subDirectoryInfo in subDirectoryInfos)
- {
- await UpdateVersionAsync(version, subDirectoryInfo);
- }
- }
- }
- ///
- /// 更新版本
- ///
- ///
- ///
- ///
- protected virtual async Task UpdateCsprojVersionAsync(string version, FileInfo fileInfo)
- {
- string projectName = Path.GetFileNameWithoutExtension(fileInfo.Name);
- XmlDocument xmlDocument = new();
- xmlDocument.Load(fileInfo.FullName);
- XmlNode? projectNode = xmlDocument.SelectSingleNode("//Project");
- if (projectNode is null) return;
- foreach (XmlNode node in projectNode.ChildNodes)
- {
- if (node.Name != "ItemGroup") continue;
- UpdateCsprojItemGroupVersion(projectName, version, node);
- }
- string xmlContent = xmlDocument.GetFormatXmlContent();
- xmlContent = xmlContent.StartsWith(" xmlContent[(xmlContent.IndexOf("?>", StringComparison.Ordinal) + 2)..],
- false => xmlContent
- };
- xmlContent = xmlContent.Trim();
- await File.WriteAllTextAsync(fileInfo.FullName, xmlContent, Encoding.UTF8);
- }
- ///
- /// 更新Csproj PropertyGroup版本
- ///
- ///
- ///
- ///
- protected virtual void UpdateCsprojItemGroupVersion(string projectName, string version, XmlNode node)
- {
- foreach (XmlNode childNode in node.ChildNodes)
- {
- if (childNode.Name != "PackageReference" || childNode.Attributes is null || childNode.Attributes.Count <= 0) continue;
- XmlAttribute? nameAttribute = childNode.Attributes["Include"];
- if (nameAttribute is null || (!nameAttribute.Value.StartsWith("Materal.") && !nameAttribute.Value.StartsWith("RC."))) continue;
- XmlAttribute? versionAttribute = childNode.Attributes["Version"];
- if (versionAttribute is null) continue;
- if (versionAttribute.Value == version) continue;
- logger?.LogInformation($"正在更新{projectName}->{nameAttribute.Value}的版本到{version}");
- versionAttribute.Value = version;
- }
- }
- ///
- /// 获得当前版本
- ///
- ///
- ///
- ///
- public async Task GetNowVersionAsync(string[]? nugetPaths = null)
- {
- string? version = null;
- nugetPaths ??= _defaultNugetPaths;
- foreach (string nugetPath in nugetPaths)
- {
- try
- {
- string tempVersion = await GetNowVersionAsync(nugetPath);
- if (string.IsNullOrWhiteSpace(version))
- {
- version = tempVersion;
- }
- else
- {
- version = GetMaxVersion(version, tempVersion);
- }
- }
- catch
- {
- }
- }
- if (string.IsNullOrWhiteSpace(version)) throw new ToolsException("未找到Nuget包");
- return version;
- }
- ///
- /// 获得当前版本
- ///
- ///
- ///
- ///
- private async Task GetNowVersionAsync(string nugetPath)
- {
- if (nugetPath.StartsWith("http"))
- {
- return await GetNowVersionByServerAsync(nugetPath);
- }
- else
- {
- return GetNowVersionByLocal(nugetPath);
- }
- }
- ///
- /// 通过本地获得当前版本
- ///
- ///
- ///
- private static string GetNowVersionByLocal(string nugegtPath)
- {
- DirectoryInfo directoryInfo = new(nugegtPath);
- if (!directoryInfo.Exists) throw new ToolsException($"{nugegtPath}不存在");
- FileInfo[] files = directoryInfo.GetFiles($"{_materalID}.*.nupkg");
- string? version = null;
- foreach (FileInfo file in files)
- {
- string tempVersion = file.Name[(_materalID.Length + 1)..^6];
- if (version is null)
- {
- version = tempVersion;
- }
- else
- {
- version = GetMaxVersion(version, tempVersion);
- }
- }
- if (version is null) throw new ToolsException($"获取版本失败");
- return version;
- }
- ///
- /// 通过服务器获得当前版本
- ///
- ///
- ///
- private async Task GetNowVersionByServerAsync(string nugetUrl)
- {
- string url = $"{nugetUrl}Packages";
- HttpRequestMessage httpRequestMessage = new()
- {
- RequestUri = new Uri(url),
- Method = HttpMethod.Get
- };
- HttpResponseMessage httpResponseMessage = await _httpClient.SendAsync(httpRequestMessage);
- if (httpResponseMessage.StatusCode != HttpStatusCode.OK) throw new Exception($"[{httpResponseMessage.StatusCode}]访问Nuget服务器失败");
- using MemoryStream memoryStream = new();
- await httpResponseMessage.Content.CopyToAsync(memoryStream);
- byte[] buffer = memoryStream.ToArray();
- string httpResponseResult = Encoding.UTF8.GetString(buffer);
- XmlDocument xmlDocument = new();
- xmlDocument.LoadXml(httpResponseResult);
- XmlNamespaceManager nsmgr = new(xmlDocument.NameTable);
- nsmgr.AddNamespace("vsx", "http://www.w3.org/2005/Atom");
- XmlNodeList? entryNodes = xmlDocument.SelectNodes("//vsx:entry", nsmgr);
- if (entryNodes is null) throw new Exception($"未在Nuget服务器上找到包{_materalID}");
- string? version = null;
- foreach (XmlNode item in entryNodes)
- {
- string? value = item.FirstChild?.InnerText;
- if (string.IsNullOrWhiteSpace(value)) continue;
- value = value[$"{nugetUrl}Packages(Id='".Length..];
- string id = value[.._materalID.Length];
- if (id != _materalID) continue;
- version = GetMaxVersion(value[(id.Length + 11)..^2], version);
- }
- if (string.IsNullOrWhiteSpace(version)) throw new Exception($"未在Nuget服务器上找到包{_materalID}");
- return version;
- }
- ///
- /// 获得最大版本号
- ///
- ///
- ///
- ///
- public static string GetMaxVersion(string version1, string? version2)
- {
- if (version2 is null || string.IsNullOrEmpty(version2)) return version1;
- int[] version1s = version1.Split('.').Select(m => Convert.ToInt32(m)).ToArray();
- int[] version2s = version2.Split('.').Select(m => Convert.ToInt32(m)).ToArray();
- int length = version1s.Length > version2s.Length ? version2s.Length : version1s.Length;
- for (int i = 0; i < length; i++)
- {
- if (version1s[i] > version2s[i]) return version1;
- if (version2s[i] > version1s[i]) return version2;
- }
- return version1s.Length >= version2s.Length ? version1 : version2;
- }
- }
-}
diff --git a/Materal/Src/Materal.Tools.WinUI/Pages/MateralPublishPage.xaml b/Materal/Src/Materal.Tools.WinUI/Pages/MateralPublishPage.xaml
deleted file mode 100644
index fe8bfe1fe..000000000
--- a/Materal/Src/Materal.Tools.WinUI/Pages/MateralPublishPage.xaml
+++ /dev/null
@@ -1,48 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/Materal/Src/Materal.Tools.WinUI/Pages/MateralPublishPage.xaml.cs b/Materal/Src/Materal.Tools.WinUI/Pages/MateralPublishPage.xaml.cs
deleted file mode 100644
index b26ba000a..000000000
--- a/Materal/Src/Materal.Tools.WinUI/Pages/MateralPublishPage.xaml.cs
+++ /dev/null
@@ -1,17 +0,0 @@
-using Materal.Tools.WinUI.ViewModels;
-using Microsoft.UI.Xaml.Controls;
-
-namespace Materal.Tools.WinUI.Pages
-{
- [Menu("Materal发布", "\uE7B8", 0)]
- public sealed partial class MateralPublishPage : Page
- {
- public MateralPublishViewModel ViewModel { get; } = new();
- public MateralPublishPage()
- {
- ViewModel.OnClearMessage += ViewModel_OnClearMessage;
- InitializeComponent();
- }
- private void ViewModel_OnClearMessage() => logPrint.ClearLogs();
- }
-}
diff --git a/Materal/Src/Materal.Tools.WinUI/Pages/MateralVersionPage.xaml b/Materal/Src/Materal.Tools.WinUI/Pages/MateralVersionPage.xaml
deleted file mode 100644
index e8ba43ef5..000000000
--- a/Materal/Src/Materal.Tools.WinUI/Pages/MateralVersionPage.xaml
+++ /dev/null
@@ -1,23 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/Materal/Src/Materal.Tools.WinUI/Pages/MateralVersionPage.xaml.cs b/Materal/Src/Materal.Tools.WinUI/Pages/MateralVersionPage.xaml.cs
deleted file mode 100644
index 2fcdd31cb..000000000
--- a/Materal/Src/Materal.Tools.WinUI/Pages/MateralVersionPage.xaml.cs
+++ /dev/null
@@ -1,17 +0,0 @@
-using Materal.Tools.WinUI.ViewModels;
-using Microsoft.UI.Xaml.Controls;
-
-namespace Materal.Tools.WinUI.Pages
-{
- [Menu("Materal版本", "\uF0B3", 1)]
- public sealed partial class MateralVersionPage : Page
- {
- public MateralVersionViewModel ViewModel { get; } = new();
- public MateralVersionPage()
- {
- ViewModel.OnClearMessage += ViewModel_OnClearMessage;
- InitializeComponent();
- }
- private void ViewModel_OnClearMessage() => logPrint.ClearLogs();
- }
-}
diff --git a/Materal/Src/Materal.Tools.WinUI/PostBuild.bat b/Materal/Src/Materal.Tools.WinUI/PostBuild.bat
index 8098baf68..83505a3a1 100644
--- a/Materal/Src/Materal.Tools.WinUI/PostBuild.bat
+++ b/Materal/Src/Materal.Tools.WinUI/PostBuild.bat
@@ -1,5 +1,5 @@
@echo off
-set outputPath=%cd%\bin\x64\Release\net6.0-windows10.0.19041.0
+set outputPath=%cd%\bin\x64\Release\net8.0-windows10.0.22621.0
set destinationDirectory=%cd%
for %%i in ("%destinationDirectory%") do set destinationDirectory=%%~dpi
diff --git a/Materal/Src/Materal.Tools.WinUI/ViewModels/MateralProjectViewModel.cs b/Materal/Src/Materal.Tools.WinUI/ViewModels/MateralProjectViewModel.cs
deleted file mode 100644
index 9b4406f3b..000000000
--- a/Materal/Src/Materal.Tools.WinUI/ViewModels/MateralProjectViewModel.cs
+++ /dev/null
@@ -1,19 +0,0 @@
-using CommunityToolkit.Mvvm.ComponentModel;
-using Materal.Tools.Core.MateralPublish;
-
-namespace Materal.Tools.WinUI.ViewModels
-{
- public partial class MateralProjectViewModel(IMateralProject materalProject) : ObservableObject
- {
- ///
- /// Materal项目
- ///
- public IMateralProject MateralProject { get; } = materalProject;
- [ObservableProperty]
- private bool _isPublish = false;
- ///
- /// 名称
- ///
- public string Name => MateralProject.Name;
- }
-}
diff --git a/Materal/Src/Materal.Tools.WinUI/ViewModels/MateralPublishViewModel.cs b/Materal/Src/Materal.Tools.WinUI/ViewModels/MateralPublishViewModel.cs
deleted file mode 100644
index 25976bbda..000000000
--- a/Materal/Src/Materal.Tools.WinUI/ViewModels/MateralPublishViewModel.cs
+++ /dev/null
@@ -1,98 +0,0 @@
-using CommunityToolkit.Mvvm.ComponentModel;
-using CommunityToolkit.Mvvm.Input;
-using Materal.Tools.Core;
-using Materal.Tools.Core.MateralPublish;
-using Microsoft.Extensions.DependencyInjection;
-using Microsoft.Extensions.Logging;
-using System;
-using System.Collections.ObjectModel;
-using System.Linq;
-using System.Threading.Tasks;
-
-namespace Materal.Tools.WinUI.ViewModels
-{
- public partial class MateralPublishViewModel : ObservableObject
- {
- ///
- /// 项目路径
- ///
- [ObservableProperty]
- private string _projectPath = @"E:\Project\Materal\Materal";
- ///
- /// 版本号
- ///
- [ObservableProperty]
- private string _version = "1.0.0";
- public ObservableCollection Projects { get; } = [];
- private readonly IMateralPublishService _publishService;
- private readonly ILogger _logger;
- public event Action? OnClearMessage;
- public MateralPublishViewModel()
- {
- _publishService = App.ServiceProvider.GetRequiredService();
- _logger = App.ServiceProvider.GetRequiredService>();
- MateralProjectViewModel[] allProjects = _publishService.GetAllProjects().Select(m => new MateralProjectViewModel(m)).ToArray();
- Projects.Clear();
- foreach (MateralProjectViewModel project in allProjects)
- {
- Projects.Add(project);
- }
- if (_publishService.IsMateralProjectPath(ProjectPath))
- {
- Version = _publishService.GetNowVersion(ProjectPath);
- }
- else
- {
- ProjectPath = string.Empty;
- }
- }
- partial void OnProjectPathChanged(string? oldValue, string newValue)
- {
- try
- {
- if (string.IsNullOrWhiteSpace(ProjectPath))
- {
- Version = "1.0.0";
- return;
- }
- if (!_publishService.IsMateralProjectPath(ProjectPath)) throw new ToolsException($"\"{ProjectPath}\"不是Materal项目路径");
- Version = _publishService.GetNowVersion(ProjectPath);
- }
- catch (Exception)
- {
- ProjectPath = oldValue ?? string.Empty;
- throw;
- }
- }
- [RelayCommand]
- private void SelectionAllProject()
- {
- foreach (MateralProjectViewModel project in Projects)
- {
- project.IsPublish = true;
- }
- }
- [RelayCommand]
- private void InvertSelectionProject()
- {
- foreach (MateralProjectViewModel project in Projects)
- {
- project.IsPublish = !project.IsPublish;
- }
- }
- [RelayCommand]
- private async Task PublishAsync()
- {
- OnClearMessage?.Invoke();
- try
- {
- IMateralProject[] projects = Projects.Where(m => m.IsPublish).Select(m => m.MateralProject).ToArray();
- await _publishService.PublishAsync(ProjectPath, Version, projects);
- }
- catch (Exception ex)
- {
- _logger.LogError(ex, ex.Message);
- }
- }
- }
-}
diff --git a/Materal/Src/Materal.Tools.WinUI/ViewModels/MateralVersionViewModel.cs b/Materal/Src/Materal.Tools.WinUI/ViewModels/MateralVersionViewModel.cs
deleted file mode 100644
index bcc0f8571..000000000
--- a/Materal/Src/Materal.Tools.WinUI/ViewModels/MateralVersionViewModel.cs
+++ /dev/null
@@ -1,52 +0,0 @@
-using CommunityToolkit.Mvvm.ComponentModel;
-using CommunityToolkit.Mvvm.Input;
-using Materal.Tools.Core.MateralVersion;
-using Microsoft.Extensions.DependencyInjection;
-using Microsoft.Extensions.Logging;
-using System;
-using System.Threading.Tasks;
-
-namespace Materal.Tools.WinUI.ViewModels
-{
- public partial class MateralVersionViewModel : ObservableObject
- {
- ///
- /// 项目路径
- ///
- [ObservableProperty]
- private string _projectPath = @"E:\Project\Materal\Materal";
- ///
- /// 版本号
- ///
- [ObservableProperty]
- private string _version = string.Empty;
- private readonly IMateralVersionService _versionService;
- private readonly ILogger _logger;
- public event Action? OnClearMessage;
- public MateralVersionViewModel()
- {
- _versionService = App.ServiceProvider.GetRequiredService();
- _logger = App.ServiceProvider.GetRequiredService>();
- }
- [RelayCommand]
- private async Task UpdateVersionAsync()
- {
- OnClearMessage?.Invoke();
- try
- {
- if (string.IsNullOrWhiteSpace(Version))
- {
- await _versionService.UpdateVersionAsync(ProjectPath);
- }
- else
- {
- await _versionService.UpdateVersionAsync(ProjectPath, Version);
- }
- }
- catch (Exception ex)
- {
- _logger.LogError(ex, ex.Message);
- }
- }
- }
-}
diff --git a/Materal/Src/MateralMergeBlockVSIX/ToolWindows/ViewModels/SolutionNotOpenedViewModel.cs b/Materal/Src/MateralMergeBlockVSIX/ToolWindows/ViewModels/SolutionNotOpenedViewModel.cs
index 2938e4a7c..ac641a8f1 100644
--- a/Materal/Src/MateralMergeBlockVSIX/ToolWindows/ViewModels/SolutionNotOpenedViewModel.cs
+++ b/Materal/Src/MateralMergeBlockVSIX/ToolWindows/ViewModels/SolutionNotOpenedViewModel.cs
@@ -422,7 +422,7 @@ private void ApplyTemplate(string filePath, string templateName)
string projectPath = ProjectPath.Replace(@"\", @"\\");
template = template.Replace("${ProjectPath}", projectPath);
template = template.Replace("${ModuleName}", ModuleName);
- template = template.Replace("${Version}", "1.1.77");
+ template = template.Replace("${Version}", "1.1.78");
File.WriteAllText(filePath, template, Encoding.UTF8);
}
///
diff --git a/Materal/Src/MateralMergeBlockVSIX/source.extension.cs b/Materal/Src/MateralMergeBlockVSIX/source.extension.cs
index 231eba0ef..52acf15b4 100644
--- a/Materal/Src/MateralMergeBlockVSIX/source.extension.cs
+++ b/Materal/Src/MateralMergeBlockVSIX/source.extension.cs
@@ -11,7 +11,7 @@ internal sealed partial class Vsix
public const string Name = "MateralMergeBlockVSIX";
public const string Description = @"Materal.MergeBlock项目专用插件";
public const string Language = "zh-Hans";
- public const string Version = "1.1.77.9";
+ public const string Version = "1.1.78.1";
public const string Author = "Materal";
public const string Tags = "Materal.MergeBlock";
}
diff --git a/Materal/Src/MateralMergeBlockVSIX/source.extension.vsixmanifest b/Materal/Src/MateralMergeBlockVSIX/source.extension.vsixmanifest
index 8516720b3..3f45e1012 100644
--- a/Materal/Src/MateralMergeBlockVSIX/source.extension.vsixmanifest
+++ b/Materal/Src/MateralMergeBlockVSIX/source.extension.vsixmanifest
@@ -1,7 +1,7 @@
-
+
MateralMergeBlockVSIX
Materal.MergeBlock项目专用插件
Icon.jpg
diff --git a/Materal/Src/MateralToolsVSIX/source.extension.cs b/Materal/Src/MateralToolsVSIX/source.extension.cs
index 0dede90af..b05879743 100644
--- a/Materal/Src/MateralToolsVSIX/source.extension.cs
+++ b/Materal/Src/MateralToolsVSIX/source.extension.cs
@@ -11,7 +11,7 @@ internal sealed partial class Vsix
public const string Name = "MateralToolsVSIX";
public const string Description = @"MateralTools扩展";
public const string Language = "zh-CN";
- public const string Version = "1.1.77.1";
+ public const string Version = "1.1.78.1";
public const string Author = "陈明旭";
public const string Tags = "";
}
diff --git a/Materal/Src/MateralToolsVSIX/source.extension.vsixmanifest b/Materal/Src/MateralToolsVSIX/source.extension.vsixmanifest
index 29867da08..7308c4042 100644
--- a/Materal/Src/MateralToolsVSIX/source.extension.vsixmanifest
+++ b/Materal/Src/MateralToolsVSIX/source.extension.vsixmanifest
@@ -1,7 +1,7 @@
-
+
MateralToolsVSIX
MateralTools扩展
Resources\Icon.png
diff --git "a/NugetPackages/00-\346\270\205\347\251\272Materal\345\214\205\347\274\223\345\255\230.ps1" "b/NugetPackages/00-\346\270\205\347\251\272Materal\345\214\205\347\274\223\345\255\230.ps1"
index 2990c4fbe..bf3341f0a 100644
--- "a/NugetPackages/00-\346\270\205\347\251\272Materal\345\214\205\347\274\223\345\255\230.ps1"
+++ "b/NugetPackages/00-\346\270\205\347\251\272Materal\345\214\205\347\274\223\345\255\230.ps1"
@@ -1,5 +1,5 @@
$nugetCacheDir = 'E:\Packages\NuGet\packages'
Get-ChildItem -Path $nugetCacheDir -Directory -Filter "materal.*" | Remove-Item -Recurse -Force
-Write-Host "Materal Nuget"
+Write-Host "已清空Materal Nuget包缓存"
Get-ChildItem -Path $nugetCacheDir -Directory -Filter "RC.*" | Remove-Item -Recurse -Force
-Write-Host "RC Nuget"
\ No newline at end of file
+Write-Host "已清空RC Nuget包缓存"
\ No newline at end of file
diff --git a/RC/Directory.Packages.props b/RC/Directory.Packages.props
index ee0d2a6e4..065db8b33 100644
--- a/RC/Directory.Packages.props
+++ b/RC/Directory.Packages.props
@@ -32,7 +32,6 @@
-
\ No newline at end of file
diff --git a/RC/RC.Authority/RC.Authority.Repository/RC.Authority.Repository.csproj b/RC/RC.Authority/RC.Authority.Repository/RC.Authority.Repository.csproj
index 366bb87cc..e7e23b9b1 100644
--- a/RC/RC.Authority/RC.Authority.Repository/RC.Authority.Repository.csproj
+++ b/RC/RC.Authority/RC.Authority.Repository/RC.Authority.Repository.csproj
@@ -1,5 +1,9 @@
-
+
+
+
+
+
Always
diff --git a/RC/RC.Core/RC.Core.Repository/RCCacheRepository.cs b/RC/RC.Core/RC.Core.Repository/RCCacheRepositoryImpl.cs
similarity index 100%
rename from RC/RC.Core/RC.Core.Repository/RCCacheRepository.cs
rename to RC/RC.Core/RC.Core.Repository/RCCacheRepositoryImpl.cs
diff --git a/RC/RC.Core/RC.Core.Repository/RCRepository.cs b/RC/RC.Core/RC.Core.Repository/RCRepositoryImpl.cs
similarity index 100%
rename from RC/RC.Core/RC.Core.Repository/RCRepository.cs
rename to RC/RC.Core/RC.Core.Repository/RCRepositoryImpl.cs
diff --git a/RC/RC.EnvironmentServer/RC.EnvironmentServer.Application/RC.EnvironmentServer.Application.csproj b/RC/RC.EnvironmentServer/RC.EnvironmentServer.Application/RC.EnvironmentServer.Application.csproj
index 396458a77..727e29465 100644
--- a/RC/RC.EnvironmentServer/RC.EnvironmentServer.Application/RC.EnvironmentServer.Application.csproj
+++ b/RC/RC.EnvironmentServer/RC.EnvironmentServer.Application/RC.EnvironmentServer.Application.csproj
@@ -5,7 +5,6 @@
-