From 8cde546db14df95d4a82111e75896f068311c5cf Mon Sep 17 00:00:00 2001 From: Yunus Emre Kalkan Date: Mon, 11 Oct 2021 15:10:33 +0300 Subject: [PATCH] [studio] Improve package installing --- .../Abp/Studio/Modifying/CsprojFileManager.cs | 22 ++- .../Volo/Abp/Studio/Package/PackageTypes.cs | 148 +++++++++++++++++- 2 files changed, 161 insertions(+), 9 deletions(-) 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 5dea6caf0b..e1bf7bccd2 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 @@ -143,23 +143,29 @@ namespace Volo.Abp.Studio.Packages.Modifying var packageReferenceNodes = document.SelectNodes($"/Project/ItemGroup/PackageReference"); var projectReferenceNodes = document.SelectNodes($"/Project/ItemGroup/ProjectReference"); - foreach (XmlNode packageReferenceNode in packageReferenceNodes) + if (packageReferenceNodes != null && packageReferenceNodes.Count > 0) { - result.Add( + foreach (XmlNode packageReferenceNode in packageReferenceNodes) + { + result.Add( new PackageDependency( - packageReferenceNode.Attributes["Include"].Value, - packageReferenceNode.Attributes["Version"].Value - ) + packageReferenceNode.Attributes["Include"].Value, + packageReferenceNode.Attributes["Version"].Value + ) ); + } } - foreach (XmlNode projectReferenceNode in projectReferenceNodes) + if (projectReferenceNodes != null && projectReferenceNodes.Count > 0) { - result.Add( + foreach (XmlNode projectReferenceNode in projectReferenceNodes) + { + result.Add( new PackageDependency( Path.GetFullPath(Path.Combine(Path.GetDirectoryName(filePath), projectReferenceNode.Attributes["Include"].Value)) - ) + ) ); + } } return result; diff --git a/studio/src/Volo.Abp.Studio.Domain.CommonServices/Volo/Abp/Studio/Package/PackageTypes.cs b/studio/src/Volo.Abp.Studio.Domain.CommonServices/Volo/Abp/Studio/Package/PackageTypes.cs index 8725d60386..78b2cea379 100644 --- a/studio/src/Volo.Abp.Studio.Domain.CommonServices/Volo/Abp/Studio/Package/PackageTypes.cs +++ b/studio/src/Volo.Abp.Studio.Domain.CommonServices/Volo/Abp/Studio/Package/PackageTypes.cs @@ -1,4 +1,6 @@ -namespace Volo.Abp.Studio.Packages +using System.Collections.Generic; + +namespace Volo.Abp.Studio.Packages { public static class PackageTypes { @@ -95,5 +97,149 @@ _ => null }; } + + // TODO: Rename this method, or (maybe and) write a summary. Also consider other suggestions + public static List GetDddTargetProjectRole(string packageType) + { + if (packageType == DomainShared) + { + return new List() + { + Domain, + ApplicationContracts + }; + } + + if (packageType == Domain) + { + return new List() + { + Application + }; + } + + if (packageType == ApplicationContracts) + { + return new List() + { + Application, + Mvc, + Blazor, + BlazorServer, + BlazorWebAssembly, + HttpApi + }; + } + + if (packageType == Application) + { + return new List() + { + Application, + HostMvc, + HostBlazorServer, + HostBlazorWebAssembly, + HostHttpApi + }; + } + + if (packageType == EntityFrameworkCore) + { + return new List() + { + HostMvc, + HostBlazorServer, + HostBlazorWebAssembly, + HostHttpApi + }; + } + + if (packageType == MongoDB) + { + return new List() + { + HostMvc, + HostBlazorServer, + HostBlazorWebAssembly, + HostHttpApi + }; + } + + if (packageType == HttpApi) + { + return new List() + { + HostMvc, + HostBlazorServer, + HostBlazorWebAssembly, + HostHttpApi + }; + } + + if (packageType == HttpApiClient) + { + return new List() + { + HostMvc, + HostBlazorServer, + HostBlazorWebAssembly, + HostHttpApi + }; + } + + if (packageType == HttpApiClient) + { + return new List() + { + HostMvc, + HostBlazorServer, + HostBlazorWebAssembly, + HostHttpApi + }; + } + + if (packageType == Mvc) + { + return new List() + { + HostMvc + }; + } + + if (packageType == Blazor) + { + return new List() + { + BlazorServer, + BlazorWebAssembly + }; + } + + if (packageType == BlazorServer) + { + return new List() + { + HostBlazorServer + }; + } + + if (packageType == BlazorWebAssembly) + { + return new List() + { + HostBlazorWebAssembly + }; + } + + if (packageType == Test) + { + return new List() + { + Test + }; + } + + return new List(); + } } }