diff --git a/studio/src/Volo.Abp.Studio.Domain.CommonServices/Volo/Abp/Studio/Modifying/CsprojFileManager.cs b/studio/src/Volo.Abp.Studio.Domain.CommonServices/Volo/Abp/Studio/Modifying/CsprojFileManager.cs index c37321decf..a9f4227c34 100644 --- a/studio/src/Volo.Abp.Studio.Domain.CommonServices/Volo/Abp/Studio/Modifying/CsprojFileManager.cs +++ b/studio/src/Volo.Abp.Studio.Domain.CommonServices/Volo/Abp/Studio/Modifying/CsprojFileManager.cs @@ -92,6 +92,46 @@ public class CsprojFileManager : XmlFileManagerBase, ICsprojFileManager, ITransi await SaveXmlDocumentAsync(filePath, document); } + public async Task AddAssemblyVersionAsync(string filePath, string version) + { + var document = await GetXmlDocumentAsync(filePath); + + var matchedNodes = document.SelectNodes($"/Project/PropertyGroup"); + + if (matchedNodes.Count == 0) + { + return; + } + + var versionNode = document.CreateElement("Version"); + + versionNode.InnerText = version; + + matchedNodes[0].AppendChild(versionNode); + + await SaveXmlDocumentAsync(filePath, document); + } + + public async Task AddCopyLocalLockFileAssembliesAsync(string filePath) + { + var document = await GetXmlDocumentAsync(filePath); + + var matchedNodes = document.SelectNodes($"/Project/PropertyGroup"); + + if (matchedNodes.Count == 0) + { + return; + } + + var versionNode = document.CreateElement("CopyLocalLockFileAssemblies"); + + versionNode.InnerText = "True"; + + matchedNodes[0].AppendChild(versionNode); + + await SaveXmlDocumentAsync(filePath, document); + } + public async Task ConvertPackageReferenceToProjectReferenceAsync(string filePath, string projectToReference) { var document = await GetXmlDocumentAsync(filePath); diff --git a/studio/src/Volo.Abp.Studio.Domain.CommonServices/Volo/Abp/Studio/Modifying/ICsprojFileManager.cs b/studio/src/Volo.Abp.Studio.Domain.CommonServices/Volo/Abp/Studio/Modifying/ICsprojFileManager.cs index 287debad65..b0617f10f7 100644 --- a/studio/src/Volo.Abp.Studio.Domain.CommonServices/Volo/Abp/Studio/Modifying/ICsprojFileManager.cs +++ b/studio/src/Volo.Abp.Studio.Domain.CommonServices/Volo/Abp/Studio/Modifying/ICsprojFileManager.cs @@ -12,6 +12,10 @@ public interface ICsprojFileManager Task AddImportAsync(string filePath, string importFilePath); + Task AddAssemblyVersionAsync(string filePath, string version); + + Task AddCopyLocalLockFileAssembliesAsync(string filePath); + Task ConvertPackageReferenceToProjectReferenceAsync(string filePath, string projectToReference); diff --git a/studio/src/Volo.Abp.Studio.ModuleInstaller/Volo/Abp/Studio/ModuleInstalling/ModuleInstallingPipelineBuilderBase.cs b/studio/src/Volo.Abp.Studio.ModuleInstaller/Volo/Abp/Studio/ModuleInstalling/ModuleInstallingPipelineBuilderBase.cs index 5b3f953e1a..4c061ae87d 100644 --- a/studio/src/Volo.Abp.Studio.ModuleInstaller/Volo/Abp/Studio/ModuleInstalling/ModuleInstallingPipelineBuilderBase.cs +++ b/studio/src/Volo.Abp.Studio.ModuleInstaller/Volo/Abp/Studio/ModuleInstalling/ModuleInstallingPipelineBuilderBase.cs @@ -12,7 +12,7 @@ public abstract class ModuleInstallingPipelineBuilderBase if (context.WithSourceCode) { pipeline.Add(new SourceCodeDownloadStep()); - pipeline.Add(new CommonPropsStep()); + pipeline.Add(new AssemblyVersionStep()); if (context.AddToSolutionFile) { diff --git a/studio/src/Volo.Abp.Studio.ModuleInstaller/Volo/Abp/Studio/ModuleInstalling/Steps/AddEfCoreConfigurationMethodStep.cs b/studio/src/Volo.Abp.Studio.ModuleInstaller/Volo/Abp/Studio/ModuleInstalling/Steps/AddEfCoreConfigurationMethodStep.cs index 05e0d2073c..20caa109ba 100644 --- a/studio/src/Volo.Abp.Studio.ModuleInstaller/Volo/Abp/Studio/ModuleInstalling/Steps/AddEfCoreConfigurationMethodStep.cs +++ b/studio/src/Volo.Abp.Studio.ModuleInstaller/Volo/Abp/Studio/ModuleInstalling/Steps/AddEfCoreConfigurationMethodStep.cs @@ -36,7 +36,14 @@ public class AddEfCoreConfigurationMethodStep : ModuleInstallingPipelineStep foreach (var declaration in context.EfCoreConfigurationMethodDeclarations) { - _dbContextFileBuilderConfigureAdder.Add(dbContextFile, declaration.Namespace + ":" + declaration.MethodName); + try + { + _dbContextFileBuilderConfigureAdder.Add(dbContextFile, declaration.Namespace + ":" + declaration.MethodName); + } + catch (Exception e) + { + continue; + } } } } diff --git a/studio/src/Volo.Abp.Studio.ModuleInstaller/Volo/Abp/Studio/ModuleInstalling/Steps/CommonPropsStep.cs b/studio/src/Volo.Abp.Studio.ModuleInstaller/Volo/Abp/Studio/ModuleInstalling/Steps/AssemblyVersionStep.cs similarity index 77% rename from studio/src/Volo.Abp.Studio.ModuleInstaller/Volo/Abp/Studio/ModuleInstalling/Steps/CommonPropsStep.cs rename to studio/src/Volo.Abp.Studio.ModuleInstaller/Volo/Abp/Studio/ModuleInstalling/Steps/AssemblyVersionStep.cs index 519cc31c06..ecd83db1b1 100644 --- a/studio/src/Volo.Abp.Studio.ModuleInstaller/Volo/Abp/Studio/ModuleInstalling/Steps/CommonPropsStep.cs +++ b/studio/src/Volo.Abp.Studio.ModuleInstaller/Volo/Abp/Studio/ModuleInstalling/Steps/AssemblyVersionStep.cs @@ -5,7 +5,7 @@ using Volo.Abp.Studio.Packages.Modifying; namespace Volo.Abp.Studio.ModuleInstalling.Steps; -public class CommonPropsStep : ModuleInstallingPipelineStep +public class AssemblyVersionStep : ModuleInstallingPipelineStep { public async override Task ExecuteAsync(ModuleInstallingContext context) { @@ -23,7 +23,8 @@ public class CommonPropsStep : ModuleInstallingPipelineStep foreach (var csProjFile in csProjFiles) { - await _csprojFileManager.AddImportAsync(csProjFile, commonPropsFilePath); + await _csprojFileManager.AddAssemblyVersionAsync(csProjFile, context.Version); + await _csprojFileManager.AddCopyLocalLockFileAssembliesAsync(csProjFile); } } }