diff --git a/aspnet-core/frameworks/src/Lion.AbpPro.Cli.Core/Lion/AbpPro/Cli/AbpProCliCoreModule.cs b/aspnet-core/frameworks/src/Lion.AbpPro.Cli.Core/Lion/AbpPro/Cli/AbpProCliCoreModule.cs index e7984aa0..152fd6a4 100644 --- a/aspnet-core/frameworks/src/Lion.AbpPro.Cli.Core/Lion/AbpPro/Cli/AbpProCliCoreModule.cs +++ b/aspnet-core/frameworks/src/Lion.AbpPro.Cli.Core/Lion/AbpPro/Cli/AbpProCliCoreModule.cs @@ -20,21 +20,21 @@ public class AbpProCliCoreModule : AbpModule new AbpProTemplateOptions("abp-vnext-pro", "pro", "源码版本", true) { ExcludeFiles = "templates,docs,.github,LICENSE,Readme.md", - ReplaceSuffix = ".sln,.csproj,.cs,.cshtml,.json,.ci,.yml,.yaml,.nswag,.DotSettings,.env", + ReplaceSuffix = ".sln,.csproj,.cs,.cshtml,.json,.ci,.yml,.yaml,.nswag,.DotSettings,.env,Directory.Build.Lion.targets", OldCompanyName = "Lion", OldProjectName = "AbpPro" }, new AbpProTemplateOptions("abp-vnext-pro-nuget-all", "pro.all", "Nuget完整版本") { //ExcludeFiles = "aspnet-core,vben28,abp-vnext-pro-nuget-module,abp-vnext-pro-nuget-simplify,docs,.github,LICENSE,Readme.md", - ReplaceSuffix = ".sln,.csproj,.cs,.cshtml,.json,.ci,.yml,.yaml,.nswag,.DotSettings,.env", + ReplaceSuffix = ".sln,.csproj,.cs,.cshtml,.json,.ci,.yml,.yaml,.nswag,.DotSettings,.env,Directory.Build.Lion.targets", OldCompanyName = "MyCompanyName", OldProjectName = "MyProjectName" }, new AbpProTemplateOptions("abp-vnext-pro-nuget-simplify", "pro.simplify", "Nuget简单版本") { //ExcludeFiles = "aspnet-core,vben28,abp-vnext-pro-nuget-module,abp-vnext-pro-nuget-all,docs,.github,LICENSE,Readme.md", - ReplaceSuffix = ".sln,.csproj,.cs,.cshtml,.json,.ci,.yml,.yaml,.nswag,.DotSettings,.env", + ReplaceSuffix = ".sln,.csproj,.cs,.cshtml,.json,.ci,.yml,.yaml,.nswag,.DotSettings,.env,Directory.Build.Lion.targets", OldCompanyName = "MyCompanyName", OldProjectName = "MyProjectName" }, @@ -42,7 +42,7 @@ public class AbpProCliCoreModule : AbpModule new AbpProTemplateOptions("abp-vnext-pro-nuget-module", "pro.module", "模块") { //ExcludeFiles = "aspnet-core,vben28,abp-vnext-pro-nuget-all,abp-vnext-pro-nuget-simplify,docs,.github,LICENSE,Readme.md", - ReplaceSuffix = ".sln,.csproj,.cs,.cshtml,.json,.ci,.yml,.yaml,.nswag,.DotSettings,.env", + ReplaceSuffix = ".sln,.csproj,.cs,.cshtml,.json,.ci,.yml,.yaml,.nswag,.DotSettings,.env,Directory.Build.Lion.targets", OldCompanyName = "MyCompanyName", OldProjectName = "MyProjectName", OldModuleName = "MyModuleName", diff --git a/aspnet-core/frameworks/src/Lion.AbpPro.Cli.Core/Lion/AbpPro/Cli/SourceCode/SourceCodeManager.cs b/aspnet-core/frameworks/src/Lion.AbpPro.Cli.Core/Lion/AbpPro/Cli/SourceCode/SourceCodeManager.cs index e15d1ce6..bbc4da79 100644 --- a/aspnet-core/frameworks/src/Lion.AbpPro.Cli.Core/Lion/AbpPro/Cli/SourceCode/SourceCodeManager.cs +++ b/aspnet-core/frameworks/src/Lion.AbpPro.Cli.Core/Lion/AbpPro/Cli/SourceCode/SourceCodeManager.cs @@ -128,7 +128,8 @@ public class SourceCodeManager : ITransientDependency, ISourceCodeManager context.CompanyName, context.ProjectName, context.ModuleName, - context.ReplaceSuffix); + context.ReplaceSuffix, + context.TemplateFile.Version); if (context.IsSource) { diff --git a/aspnet-core/frameworks/src/Lion.AbpPro.Cli.Core/Lion/AbpPro/Cli/Utils/ReplaceHelper.cs b/aspnet-core/frameworks/src/Lion.AbpPro.Cli.Core/Lion/AbpPro/Cli/Utils/ReplaceHelper.cs index 6ba69ee3..4d6cb0e9 100644 --- a/aspnet-core/frameworks/src/Lion.AbpPro.Cli.Core/Lion/AbpPro/Cli/Utils/ReplaceHelper.cs +++ b/aspnet-core/frameworks/src/Lion.AbpPro.Cli.Core/Lion/AbpPro/Cli/Utils/ReplaceHelper.cs @@ -2,13 +2,20 @@ public static class ReplaceHelper { - - public static void ReplaceTemplates(string sourcePath, string oldCompanyName, string oldProjectName, string oldModuleName, string companyName, string projectName, string moduleName, - string replaceSuffix) + public static void ReplaceTemplates( + string sourcePath, + string oldCompanyName, + string oldProjectName, + string oldModuleName, + string companyName, + string projectName, + string moduleName, + string replaceSuffix, + string version) { try { - RenameTemplate(sourcePath, oldCompanyName, oldProjectName, oldModuleName, companyName, projectName, moduleName, replaceSuffix); + RenameTemplate(sourcePath, oldCompanyName, oldProjectName, oldModuleName, companyName, projectName, moduleName, replaceSuffix, version); } catch (Exception ex) { @@ -16,19 +23,35 @@ public static class ReplaceHelper } } - private static void RenameTemplate(string sourcePath, string oldCompanyName, string oldProjectName, string oldModuleName, string companyName, string projectName, string moduleName, - string replaceSuffix) + private static void RenameTemplate( + string sourcePath, + string oldCompanyName, + string oldProjectName, + string oldModuleName, + string companyName, + string projectName, + string moduleName, + string replaceSuffix, + string version) { - RenameAllDirectories(sourcePath, oldCompanyName, oldProjectName, oldModuleName, companyName, projectName, moduleName); - RenameAllFileNameAndContent(sourcePath, oldCompanyName, oldProjectName, oldModuleName, companyName, projectName, moduleName, replaceSuffix); + RenameAllDirectories(sourcePath, oldCompanyName, oldProjectName, oldModuleName, companyName, projectName, moduleName, version); + RenameAllFileNameAndContent(sourcePath, oldCompanyName, oldProjectName, oldModuleName, companyName, projectName, moduleName, replaceSuffix, version); } - private static void RenameAllDirectories(string sourcePath, string oldCompanyName, string oldProjectName, string oldModuleName, string companyName, string projectName, string moduleName) + private static void RenameAllDirectories( + string sourcePath, + string oldCompanyName, + string oldProjectName, + string oldModuleName, + string companyName, + string projectName, + string moduleName, + string version) { var directories = Directory.GetDirectories(sourcePath); foreach (var subDirectory in directories) { - RenameAllDirectories(subDirectory, oldCompanyName, oldProjectName, oldModuleName, companyName, projectName, moduleName); + RenameAllDirectories(subDirectory, oldCompanyName, oldProjectName, oldModuleName, companyName, projectName, moduleName, version); var directoryInfo = new DirectoryInfo(subDirectory); if (directoryInfo.Name.Contains(oldCompanyName) || @@ -36,7 +59,7 @@ public static class ReplaceHelper directoryInfo.Name.Contains(oldModuleName)) { var oldDirectoryName = directoryInfo.Name; - var newDirectoryName = oldDirectoryName.CustomReplace(oldCompanyName, oldProjectName, oldModuleName, companyName, projectName, moduleName); + var newDirectoryName = oldDirectoryName.CustomReplace(oldCompanyName, oldProjectName, oldModuleName, companyName, projectName, moduleName, version); var newDirectoryPath = Path.Combine(directoryInfo.Parent?.FullName, newDirectoryName); @@ -47,10 +70,18 @@ public static class ReplaceHelper } } } - - private static void RenameAllFileNameAndContent(string sourcePath, string oldCompanyName, string oldProjectName, string oldModuleName, string companyName, string projectName, string moduleName, - string replaceSuffix) + + private static void RenameAllFileNameAndContent( + string sourcePath, + string oldCompanyName, + string oldProjectName, + string oldModuleName, + string companyName, + string projectName, + string moduleName, + string replaceSuffix, + string version) { var list = new DirectoryInfo(sourcePath) .GetFiles() @@ -62,7 +93,7 @@ public static class ReplaceHelper { // 改文件内容 var oldContents = File.ReadAllText(fileInfo.FullName, encoding); - var newContents = oldContents.CustomReplace(oldCompanyName, oldProjectName, oldModuleName, companyName, projectName, moduleName); + var newContents = oldContents.CustomReplace(oldCompanyName, oldProjectName, oldModuleName, companyName, projectName, moduleName, version); // 文件名包含模板关键字 if (fileInfo.Name.Contains(oldCompanyName) @@ -70,7 +101,7 @@ public static class ReplaceHelper || fileInfo.Name.Contains(oldModuleName)) { var oldFileName = fileInfo.Name; - var newFileName = oldFileName.CustomReplace(oldCompanyName, oldProjectName, oldModuleName, companyName, projectName, moduleName); + var newFileName = oldFileName.CustomReplace(oldCompanyName, oldProjectName, oldModuleName, companyName, projectName, moduleName, version); var newFilePath = Path.Combine(fileInfo.DirectoryName, newFileName); // 无变化才重命名 @@ -87,19 +118,28 @@ public static class ReplaceHelper foreach (var subDirectory in Directory.GetDirectories(sourcePath)) { - RenameAllFileNameAndContent(subDirectory, oldCompanyName, oldProjectName, oldModuleName, companyName, projectName, moduleName, replaceSuffix); + RenameAllFileNameAndContent(subDirectory, oldCompanyName, oldProjectName, oldModuleName, companyName, projectName, moduleName, replaceSuffix, version); } } - - private static string CustomReplace(this string content, string oldCompanyName, string oldProjectName, string oldModuleName, string companyName, string projectName, string moduleName) + + private static string CustomReplace( + this string content, + string oldCompanyName, + string oldProjectName, + string oldModuleName, + string companyName, + string projectName, + string moduleName, + string version) { var result = content.ReplacePackageReferenceBasicManagement() .ReplacePackageReferenceLanguageManagement() .ReplacePackageReferenceFileManagement() .ReplacePackageReferenceDataDictionaryManagement() .ReplacePackageReferenceNotificationManagement() - .ReplacePackageReferenceCore(); + .ReplacePackageReferenceCore() + .ReplaceLionPackageVersion(version); if (oldModuleName.IsNullOrWhiteSpace() || oldModuleName.IsNullOrWhiteSpace()) { @@ -117,5 +157,4 @@ public static class ReplaceHelper return result; } - } \ No newline at end of file diff --git a/aspnet-core/frameworks/src/Lion.AbpPro.Cli.Core/Lion/AbpPro/Cli/Utils/ReplacePackageReferenceExtensions.cs b/aspnet-core/frameworks/src/Lion.AbpPro.Cli.Core/Lion/AbpPro/Cli/Utils/ReplacePackageReferenceExtensions.cs index 48c718fd..c92708dc 100644 --- a/aspnet-core/frameworks/src/Lion.AbpPro.Cli.Core/Lion/AbpPro/Cli/Utils/ReplacePackageReferenceExtensions.cs +++ b/aspnet-core/frameworks/src/Lion.AbpPro.Cli.Core/Lion/AbpPro/Cli/Utils/ReplacePackageReferenceExtensions.cs @@ -156,4 +156,9 @@ public static class ReplacePackageReferenceExtensions "", ""); } + + public static string ReplaceLionPackageVersion(this string context, string version) + { + return context.Replace("MyVersion", version); + } } \ No newline at end of file diff --git a/templates/abp-vnext-pro-nuget-all/aspnet-core/Directory.Build.Lion.targets b/templates/abp-vnext-pro-nuget-all/aspnet-core/Directory.Build.Lion.targets index 81cf0924..ffa275db 100644 --- a/templates/abp-vnext-pro-nuget-all/aspnet-core/Directory.Build.Lion.targets +++ b/templates/abp-vnext-pro-nuget-all/aspnet-core/Directory.Build.Lion.targets @@ -1,34 +1,34 @@  - - - + + + - - - - - - - + + + + + + + - - - - - - - + + + + + + + - - - - - - - + + + + + + + \ No newline at end of file diff --git a/templates/abp-vnext-pro-nuget-module/Directory.Build.Lion.targets b/templates/abp-vnext-pro-nuget-module/Directory.Build.Lion.targets index 3c1e7f2e..05e1e959 100644 --- a/templates/abp-vnext-pro-nuget-module/Directory.Build.Lion.targets +++ b/templates/abp-vnext-pro-nuget-module/Directory.Build.Lion.targets @@ -1,8 +1,8 @@  - - - + + + \ No newline at end of file diff --git a/templates/abp-vnext-pro-nuget-simplify/aspnet-core/Directory.Build.Lion.targets b/templates/abp-vnext-pro-nuget-simplify/aspnet-core/Directory.Build.Lion.targets index 81cf0924..ffa275db 100644 --- a/templates/abp-vnext-pro-nuget-simplify/aspnet-core/Directory.Build.Lion.targets +++ b/templates/abp-vnext-pro-nuget-simplify/aspnet-core/Directory.Build.Lion.targets @@ -1,34 +1,34 @@  - - - + + + - - - - - - - + + + + + + + - - - - - - - + + + + + + + - - - - - - - + + + + + + + \ No newline at end of file