Browse Source
Merge pull request #11054 from abpframework/studio-add-common-props-step
New Module Installing Step: CommonPropsStep
pull/11068/head
Ahmet Çotur
5 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with
51 additions and
0 deletions
-
studio/src/Volo.Abp.Studio.Domain.CommonServices/Volo/Abp/Studio/Modifying/CsprojFileManager.cs
-
studio/src/Volo.Abp.Studio.Domain.CommonServices/Volo/Abp/Studio/Modifying/ICsprojFileManager.cs
-
studio/src/Volo.Abp.Studio.ModuleInstaller/Volo/Abp/Studio/ModuleInstalling/ModuleInstallingPipelineBuilderBase.cs
-
studio/src/Volo.Abp.Studio.ModuleInstaller/Volo/Abp/Studio/ModuleInstalling/Steps/CommonPropsStep.cs
|
|
|
@ -74,6 +74,24 @@ public class CsprojFileManager : XmlFileManagerBase, ICsprojFileManager, ITransi |
|
|
|
await SaveXmlDocumentAsync(filePath, document); |
|
|
|
} |
|
|
|
|
|
|
|
public async Task AddImportAsync(string filePath, string importFilePath) |
|
|
|
{ |
|
|
|
var document = await GetXmlDocumentAsync(filePath); |
|
|
|
|
|
|
|
var relativeImportFilePath = PathHelper.GetRelativePath(filePath, importFilePath); |
|
|
|
|
|
|
|
var importNode = document.CreateElement("Import"); |
|
|
|
|
|
|
|
var projectAttr = document.CreateAttribute("Project"); |
|
|
|
projectAttr.Value = relativeImportFilePath; |
|
|
|
importNode.Attributes.Append(projectAttr); |
|
|
|
|
|
|
|
document["Project"].AppendChild(importNode); |
|
|
|
document["Project"].AppendChild(document.CreateWhitespace(Environment.NewLine + " ")); |
|
|
|
|
|
|
|
await SaveXmlDocumentAsync(filePath, document); |
|
|
|
} |
|
|
|
|
|
|
|
public async Task ConvertPackageReferenceToProjectReferenceAsync(string filePath, string projectToReference) |
|
|
|
{ |
|
|
|
var document = await GetXmlDocumentAsync(filePath); |
|
|
|
|
|
|
|
@ -10,8 +10,11 @@ public interface ICsprojFileManager |
|
|
|
|
|
|
|
Task AddPackageReferenceAsync(string filePath, string packageName, string version); |
|
|
|
|
|
|
|
Task AddImportAsync(string filePath, string importFilePath); |
|
|
|
|
|
|
|
Task ConvertPackageReferenceToProjectReferenceAsync(string filePath, string projectToReference); |
|
|
|
|
|
|
|
|
|
|
|
Task<string> GetTargetFrameworkAsync(string filePath); |
|
|
|
|
|
|
|
Task<List<PackageDependency>> GetDependencyListAsync(string filePath); |
|
|
|
|
|
|
|
@ -12,6 +12,7 @@ public abstract class ModuleInstallingPipelineBuilderBase |
|
|
|
if (context.WithSourceCode) |
|
|
|
{ |
|
|
|
pipeline.Add(new SourceCodeDownloadStep()); |
|
|
|
pipeline.Add(new CommonPropsStep()); |
|
|
|
|
|
|
|
if (context.AddToSolutionFile) |
|
|
|
{ |
|
|
|
|
|
|
|
@ -0,0 +1,29 @@ |
|
|
|
using System.IO; |
|
|
|
using System.Threading.Tasks; |
|
|
|
using Microsoft.Extensions.DependencyInjection; |
|
|
|
using Volo.Abp.Studio.Packages.Modifying; |
|
|
|
|
|
|
|
namespace Volo.Abp.Studio.ModuleInstalling.Steps; |
|
|
|
|
|
|
|
public class CommonPropsStep : ModuleInstallingPipelineStep |
|
|
|
{ |
|
|
|
public async override Task ExecuteAsync(ModuleInstallingContext context) |
|
|
|
{ |
|
|
|
var moduleFolder = Path.GetDirectoryName(context.TargetModule); |
|
|
|
var commonPropsFilePath = Path.Combine(moduleFolder, "common.props"); |
|
|
|
|
|
|
|
if (!File.Exists(commonPropsFilePath)) |
|
|
|
{ |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
var _csprojFileManager = context.ServiceProvider.GetRequiredService<ICsprojFileManager>(); |
|
|
|
|
|
|
|
var csProjFiles = Directory.GetFiles(context.GetTargetSourceCodeFolder(), "*.csproj", SearchOption.AllDirectories); |
|
|
|
|
|
|
|
foreach (var csProjFile in csProjFiles) |
|
|
|
{ |
|
|
|
await _csprojFileManager.AddImportAsync(csProjFile, commonPropsFilePath); |
|
|
|
} |
|
|
|
} |
|
|
|
} |