diff --git a/src/VirtoCommerce.Build/Build.cs b/src/VirtoCommerce.Build/Build.cs index 1d28ae3..33ce534 100644 --- a/src/VirtoCommerce.Build/Build.cs +++ b/src/VirtoCommerce.Build/Build.cs @@ -191,6 +191,7 @@ public static Solution Solution protected static GitRepository GitRepository => GitRepository.FromLocalDirectory(RootDirectory / ".git"); protected static AbsolutePath SourceDirectory => RootDirectory / "src"; + protected static bool IsPlatformSource => SourceDirectory.Exists(); protected static AbsolutePath TestsDirectory => RootDirectory / "tests"; protected static AbsolutePath SamplesDirectory => RootDirectory / "samples"; @@ -301,13 +302,13 @@ protected override void OnTargetFailed(string target) .Before(Restore) .Executes(() => { - AbsolutePath[] ignorePaths = null; + List ignorePaths = [WebProject.Directory / "modules"]; if (ThereAreCustomApps) { - ignorePaths = [WebProject.Directory / "App"]; + ignorePaths.Add(WebProject.Directory / "App"); } - CleanSolution(cleanSearchPattern, ignorePaths); + CleanSolution(cleanSearchPattern, ignorePaths.ToArray()); }); public Target Restore => _ => _ diff --git a/src/VirtoCommerce.Build/PlatformTools/Build.PackageManager.cs b/src/VirtoCommerce.Build/PlatformTools/Build.PackageManager.cs index eb878bd..b23b3ed 100644 --- a/src/VirtoCommerce.Build/PlatformTools/Build.PackageManager.cs +++ b/src/VirtoCommerce.Build/PlatformTools/Build.PackageManager.cs @@ -36,7 +36,7 @@ internal partial class Build public static string[] Module { get; set; } [Parameter("Skip dependency solving")] - public static bool SkipDependencySolving { get; set; } + public static bool SkipDependencySolving { get; set; } = true; [Parameter("Install the platform", Name = "Platform")] public static bool PlatformParameter { get; set; } @@ -67,10 +67,11 @@ internal partial class Build public static string DiscoveryPath { get; set; } [Parameter("Probing path")] - public static AbsolutePath ProbingPath { get; set; } = RootDirectory / "app_data" / "modules"; + public static AbsolutePath ProbingPath { get; set; } = PlatformRootDirectory / "app_data" / "modules"; [Parameter("appsettings.json path")] - public static AbsolutePath AppsettingsPath { get; set; } = RootDirectory / "appsettings.json"; + public static AbsolutePath AppsettingsPath { get; set; } = PlatformRootDirectory / "appsettings.json"; + public static AbsolutePath PlatformRootDirectory => IsPlatformSource ? WebDirectory : RootDirectory; public Target InitPlatform => _ => _ .Executes(() => @@ -252,7 +253,7 @@ private static bool SkipFile(FileInfo fileInfo) .Executes(() => BackupFile.DeleteFile()); public Target InstallPlatform => _ => _ - .OnlyWhenDynamic(() => PlatformVersionChanged && !IsModulesInstallation) + .OnlyWhenDynamic(() => PlatformVersionChanged && !IsModulesInstallation && !IsPlatformSource) .Executes(async () => { var packageManifest = PackageManager.FromFile(PackageManifestPath); @@ -319,8 +320,18 @@ private static async Task InstallPlatformAsync(string platformVersion, string pl private static string GetDiscoveryPath() { - var configuration = AppSettings.GetConfiguration(RootDirectory, AppsettingsPath); - return DiscoveryPath.EmptyToNull() ?? configuration.GetModulesDiscoveryPath(); + if (DiscoveryPath.IsNullOrEmpty()) + { + var configuration = AppSettings.GetConfiguration(PlatformRootDirectory, AppsettingsPath); + var path = configuration.GetModulesDiscoveryPath(); + if (!Path.IsPathRooted(path)) + { + path = Path.GetFullPath(path, PlatformRootDirectory); + } + return path; + } + + return DiscoveryPath; } private static bool IsPlatformInstallationNeeded(string version) @@ -517,7 +528,7 @@ private static ManifestModuleInfo LoadModuleInfo(ModuleItem module, ManifestModu .Executes(async () => { SkipDependencySolving = true; - var manifest = await OpenOrCreateManifest(PackageManifestPath, Edge); + var manifest = await OpenOrCreateManifest(PackageManifestPath.ToAbsolutePath(), Edge); if (Edge) { @@ -533,7 +544,11 @@ private static ManifestModuleInfo LoadModuleInfo(ModuleItem module, ManifestModu private static async Task UpdateEdgeAsync(ManifestBase manifest, bool platformOnly) { - manifest = await UpdateEdgePlatformAsync(manifest); + if (!IsPlatformSource) + { + manifest = await UpdateEdgePlatformAsync(manifest); + } + if(!platformOnly) { manifest = await UpdateEdgeModulesAsync(manifest); @@ -547,7 +562,11 @@ private async Task UpdateStableAsync(ManifestBase manifest, bool p await DownloadBundleManifest(bundleName, bundleTmpFilePath); var bundle = PackageManager.FromFile(bundleTmpFilePath); - manifest = await UpdateStablePlatformAsync(manifest, bundle); + if (!IsPlatformSource) + { + manifest = await UpdateStablePlatformAsync(manifest, bundle); + } + if (!platformOnly) { manifest = await UpdateStableModulesAsync((MixedPackageManifest)manifest, (MixedPackageManifest)bundle); @@ -626,33 +645,34 @@ private static async Task UpdateEdgeModulesAsync(ManifestBase mani private static async Task OpenOrCreateManifest(string packageManifestPath, bool isEdge) { + ManifestBase result; var platformWebDllPath = Path.Combine(Directory.GetParent(packageManifestPath).FullName, "VirtoCommerce.Platform.Web.dll"); - if (!isEdge) + if(!File.Exists(packageManifestPath)) { - SkipDependencySolving = true; - if (!File.Exists(packageManifestPath)) + if (!isEdge) //Stable { await DownloadBundleManifest(BundleName, packageManifestPath); + result = PackageManager.FromFile(packageManifestPath); + } + else if (File.Exists(platformWebDllPath)) // There is platform + { + var discoveryAbsolutePath = Path.GetFullPath(GetDiscoveryPath()); + result = await CreateManifestFromEnvironment(PlatformRootDirectory, discoveryAbsolutePath.ToAbsolutePath()); + } + else // Create new + { + Log.Information("vc-package.json does not exist."); + Log.Information("Looking for the platform release"); + var platformRelease = await GithubManager.GetPlatformRelease(GitHubToken, VersionToInstall); + result = PackageManager.CreatePackageManifest(platformRelease.TagName); } - return PackageManager.FromFile(packageManifestPath); - } - else if (!File.Exists(packageManifestPath) && File.Exists(platformWebDllPath)) - { - var discoveryAbsolutePath = Path.GetFullPath(GetDiscoveryPath()); - return await CreateManifestFromEnvironment(RootDirectory, discoveryAbsolutePath.ToAbsolutePath()); - } - else if (!File.Exists(packageManifestPath)) - { - Log.Information("vc-package.json does not exist."); - Log.Information("Looking for the platform release"); - var platformRelease = await GithubManager.GetPlatformRelease(GitHubToken, VersionToInstall); - return PackageManager.CreatePackageManifest(platformRelease.TagName); } else { - SkipDependencySolving = true; - return PackageManager.FromFile(PackageManifestPath); + result = PackageManager.FromFile(packageManifestPath); } + + return result; } private static async Task DownloadBundleManifest(string bundleName, string outFile) diff --git a/src/VirtoCommerce.Build/Utils/ModuleCompressionOptions.cs b/src/VirtoCommerce.Build/Utils/ModuleCompressionOptions.cs index 0e56f79..b492f44 100644 --- a/src/VirtoCommerce.Build/Utils/ModuleCompressionOptions.cs +++ b/src/VirtoCommerce.Build/Utils/ModuleCompressionOptions.cs @@ -1,8 +1,4 @@ -using System; using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace Utils {