Skip to content

Commit

Permalink
feat: Modify ZIP build target to use a nested folder per connector
Browse files Browse the repository at this point in the history
This enables support for multiple versions to be packed in the same installer (as we do now)
Minor changes in ArcGIS project output folder to align with other connectors
  • Loading branch information
AlanRynne committed May 24, 2024
1 parent 27fec08 commit cceee58
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 23 deletions.
45 changes: 39 additions & 6 deletions Build/Consts.cs
Original file line number Diff line number Diff line change
@@ -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<InstallerAsset> Projects { get; init; }

public InstallerProject(string hostAppSlug, IReadOnlyList<InstallerAsset> 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; }
}
44 changes: 28 additions & 16 deletions Build/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ void RemoveDirectory(string d)
}
}
);

Target(
VERSION,
async () =>
Expand All @@ -60,6 +61,7 @@ void RemoveDirectory(string d)
Run("echo", $"\"version={output}\" >> $GITHUB_OUTPUT");
}
);

Target(
FORMAT,
() =>
Expand All @@ -68,6 +70,7 @@ void RemoveDirectory(string d)
Run("dotnet", "csharpier --check .");
}
);

Target(
RESTORE,
Consts.Solutions,
Expand Down Expand Up @@ -111,30 +114,39 @@ IEnumerable<string> 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);
}
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<RootNameSpace>Speckle.Connectors.ArcGIS</RootNameSpace>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Esri.ArcGISPro.Extensions30" Version="3.2.0.49743" />
<PackageReference Include="Esri.ArcGISPro.Extensions30" Version="3.2.0.49743" IncludeAssets="compile" />
</ItemGroup>

<ItemGroup>
Expand Down

0 comments on commit cceee58

Please sign in to comment.