diff --git a/Build/Consts.cs b/Build/Consts.cs index 65a4abf7e1..9825b5fad6 100644 --- a/Build/Consts.cs +++ b/Build/Consts.cs @@ -1,13 +1,46 @@ -namespace Build; +using System.Collections; +using System.Collections.Generic; + +namespace Build; public static class Consts { public static readonly string[] Solutions = { "DUI3-DX.slnf" }; - public static readonly (string, string)[] Projects = + + public static InstallerProject[] InstallerManifests = { - ("DUI3-DX\\Connectors\\ArcGIS\\Speckle.Connectors.ArcGIS3", "net6.0-windows"), - ("DUI3-DX\\Connectors\\Autocad\\Speckle.Connectors.Autocad2023", "net48"), - ("DUI3-DX\\Connectors\\Revit\\Speckle.Connectors.Revit2023", "net48"), - ("DUI3-DX\\Connectors\\Rhino\\Speckle.Connectors.Rhino7", "net48") + new( + "arcgis", + new InstallerAsset[] { new("DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3", "net6.0-windows") } + ), + new("rhino", new InstallerAsset[] { new("DUI3-DX/Connectors/Rhino/Speckle.Connectors.Rhino7", "net48") }), + new("revit", new InstallerAsset[] { new("DUI3-DX/Connectors/Revit/Speckle.Connectors.Revit2023", "net48") }), + new("acad", new InstallerAsset[] { new("DUI3-DX/Connectors/Autocad/Speckle.Connectors.Autocad2023", "net48") }) }; } + +public readonly struct InstallerProject +{ + public string HostAppSlug { get; init; } + public IReadOnlyList Projects { get; init; } + + public InstallerProject(string hostAppSlug, IReadOnlyList projects) + { + HostAppSlug = hostAppSlug; + Projects = projects; + } + + public override string ToString() => $"{HostAppSlug}"; +} + +public readonly struct InstallerAsset +{ + public InstallerAsset(string projectPath, string targetName) + { + ProjectPath = projectPath; + TargetName = targetName; + } + + public string ProjectPath { get; init; } + public string TargetName { get; init; } +} diff --git a/Build/Program.cs b/Build/Program.cs index 6762c94201..1cc1ae0ee0 100644 --- a/Build/Program.cs +++ b/Build/Program.cs @@ -50,6 +50,7 @@ void RemoveDirectory(string d) } } ); + Target( VERSION, async () => @@ -60,6 +61,7 @@ void RemoveDirectory(string d) Run("echo", $"\"version={output}\" >> $GITHUB_OUTPUT"); } ); + Target( FORMAT, () => @@ -68,6 +70,7 @@ void RemoveDirectory(string d) Run("dotnet", "csharpier --check ."); } ); + Target( RESTORE, Consts.Solutions, @@ -111,30 +114,39 @@ IEnumerable GetFiles(string d) Target( ZIP, - Consts.Projects, + Consts.InstallerManifests, x => { - var (path, framework) = x; + var outputDir = Path.Combine(".", "output"); + var slugDir = Path.Combine(outputDir, x.HostAppSlug); - var fullPath = Path.Combine(".", path, "bin", "Release", framework); - if (Directory.Exists(fullPath)) + Directory.CreateDirectory(outputDir); + Directory.CreateDirectory(slugDir); + + foreach (var asset in x.Projects) { - foreach (var file in Directory.EnumerateFiles(fullPath, "*", SearchOption.AllDirectories)) + var fullPath = Path.Combine(".", asset.ProjectPath, "bin", "Release", asset.TargetName); + if (Directory.Exists(fullPath)) { - Console.WriteLine(file); + var assetName = Path.GetFileName(asset.ProjectPath); + Directory.CreateDirectory(Path.Combine(slugDir, assetName)); + foreach (var file in Directory.EnumerateFiles(fullPath, "*", SearchOption.AllDirectories)) + { + Console.WriteLine(file); + File.Copy(file, Path.Combine(slugDir, assetName, Path.GetFileName(file)), true); + } + } + else + { + throw new InvalidOperationException("Could not find: " + fullPath); } } - else - { - throw new InvalidOperationException("Could not find: " + fullPath); - } - var outputDir = Path.Combine(".", "output"); - Directory.CreateDirectory(outputDir); - - var outputPath = Path.Combine(outputDir, $"{Path.GetFileName(path)}.zip"); - Console.WriteLine($"Zipping: '{fullPath}' to '{outputPath}'"); - ZipFile.CreateFromDirectory(fullPath, outputPath); + var outputPath = Path.Combine(outputDir, $"{x.HostAppSlug}.zip"); + File.Delete(outputPath); + Console.WriteLine($"Zipping: '{slugDir}' to '{outputPath}'"); + ZipFile.CreateFromDirectory(slugDir, outputPath, CompressionLevel.Optimal, true); + Directory.Delete(slugDir, true); } ); diff --git a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Speckle.Connectors.ArcGIS3.csproj b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Speckle.Connectors.ArcGIS3.csproj index 9e9e4a9d1f..564c8deb96 100644 --- a/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Speckle.Connectors.ArcGIS3.csproj +++ b/DUI3-DX/Connectors/ArcGIS/Speckle.Connectors.ArcGIS3/Speckle.Connectors.ArcGIS3.csproj @@ -7,6 +7,7 @@ win-x64 Speckle.Connectors.ArcGIS true + false diff --git a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Speckle.Converters.ArcGIS3.csproj b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Speckle.Converters.ArcGIS3.csproj index 596f00af45..2a8254afd0 100644 --- a/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Speckle.Converters.ArcGIS3.csproj +++ b/DUI3-DX/Converters/ArcGIS/Speckle.Converters.ArcGIS3/Speckle.Converters.ArcGIS3.csproj @@ -6,7 +6,7 @@ - +