From cd3c9ae6065bc1f0c8d83d90b4fb7b6d19da9d8a Mon Sep 17 00:00:00 2001 From: Yunus Emre Kalkan Date: Fri, 18 Dec 2020 09:28:20 +0300 Subject: [PATCH] Fix ChangeDomainTestReferenceToMongoDB step --- .../SolutionModuleAdder.cs | 24 +++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/SolutionModuleAdder.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/SolutionModuleAdder.cs index b19deb7b2e..4d90319c95 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/SolutionModuleAdder.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/SolutionModuleAdder.cs @@ -194,11 +194,27 @@ namespace Volo.Abp.Cli.ProjectModification private async Task ChangeDomainTestReferenceToMongoDB(ModuleWithMastersInfo module, string moduleSolutionFile) { - var srcPath = Path.Combine(Path.GetDirectoryName(moduleSolutionFile), "test"); - var projectFolderPath = Directory.GetDirectories(srcPath).FirstOrDefault(d=> d.EndsWith("Domain.Tests")); + var testPath = Path.Combine(Path.GetDirectoryName(moduleSolutionFile), "test"); - var csprojFile = Directory.GetFiles(projectFolderPath).First(p => p.EndsWith(".csproj")); - var moduleFile = Directory.GetFiles(projectFolderPath).First(p => p.EndsWith("DomainTestModule.cs")); + if (!Directory.Exists(testPath)) + { + return; + } + + var projectFolderPath = Directory.GetDirectories(testPath).FirstOrDefault(d=> d.EndsWith("Domain.Tests")); + + if (projectFolderPath == null) + { + return; + } + + var csprojFile = Directory.GetFiles(projectFolderPath).FirstOrDefault(p => p.EndsWith(".csproj")); + var moduleFile = Directory.GetFiles(projectFolderPath).FirstOrDefault(p => p.EndsWith("DomainTestModule.cs")); + + if (csprojFile == null || moduleFile == null) + { + return; + } File.WriteAllText(csprojFile, File.ReadAllText(csprojFile).Replace("EntityFrameworkCore","MongoDB")); File.WriteAllText(moduleFile, File.ReadAllText(moduleFile)