Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 26 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,31 +22,53 @@ jobs:
global-json-file: global.json
dotnet-version: |
8.0.x
10.0.x
- run: dotnet restore IOViewer.slnx
- run: dotnet build IOViewer.slnx -c Release --no-restore
- run: dotnet test IOViewer.slnx -c Release --no-build
- run: dotnet pack IOViewer.slnx -c Release --no-build -o artifacts
- run: dotnet pack IOViewer.slnx -c Release -p:PackCliForPlatforms=true -o artifacts
- name: Check package dependencies
shell: pwsh
run: |
./tools/check-packages.ps1 -PackageDirectory artifacts
./tools/test-package-checks.ps1
- name: Install the Windows CLI and export a scan
shell: pwsh
run: ./tools/test-cli-package.ps1 -PackageDirectory artifacts -Rid win-x64
- uses: actions/upload-artifact@v7
with:
name: packages-${{ matrix.os }}
path: artifacts/*.nupkg
if-no-files-found: error

build-linux:
runs-on: ubuntu-latest
cli-package:
needs: build
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
rid: linux-x64
- os: macos-15
rid: osx-arm64
- os: macos-15-intel
rid: any
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v7
- uses: actions/setup-dotnet@v6
with:
global-json-file: global.json
dotnet-version: |
8.0.x
- run: dotnet build src/IOViewer.Cli/IOViewer.Cli.csproj -c Release
10.0.x
- uses: actions/download-artifact@v8
with:
name: packages-windows-latest
path: artifacts
- name: Install the CLI and export a scan
shell: pwsh
run: ./tools/test-cli-package.ps1 -PackageDirectory artifacts -Rid ${{ matrix.rid }}

viewer:
runs-on: ubuntu-latest
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,10 @@ jobs:
- name: Publish NuGet packages
shell: pwsh
run: |
foreach ($package in Get-ChildItem artifacts -Filter *.nupkg) {
$pointer = "IOViewer.Cli.$($env:GITHUB_REF_NAME.Substring(1)).nupkg"
# Publish the platform packages before the package that refers to them.
$packages = Get-ChildItem artifacts -Filter *.nupkg | Sort-Object { $_.Name -eq $pointer }
foreach ($package in $packages) {
dotnet nuget push $package.FullName --api-key '${{ steps.nuget-login.outputs.NUGET_API_KEY }}' --source https://api.nuget.org/v3/index.json --skip-duplicate
if ($LASTEXITCODE -ne 0) { throw "dotnet nuget push failed for $($package.Name) with exit code $LASTEXITCODE" }
}
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ API between minor releases.

## [Unreleased]

### Changed

- The .NET tool downloads a smaller package for Windows x64, Linux x64 and macOS ARM64. Other architectures
receive the portable package. The platform-aware installer requires the .NET 10 SDK or later.

## [0.4.1] - 2026-11-26

### Added
Expand Down
2 changes: 2 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ with a stable lower bound, and rejects dependency bounds that nuget.org refuses
prerelease label of one part that does not start with a letter).
Before the tag, run the Revit test with a real Revit 2022 file, which CI does not have: set `IOVIEWER_RVT_FILE` to its path and run `dotnet test IOViewer.slnx -c Release --filter Cli_ConvertRvtToHtml`.
The NuGet policy must name this repository, `release.yml`, the configured NuGet profile and the `IOViewer*` package pattern.
The release and CI use `-p:PackCliForPlatforms=true` to create the CLI's platform packages and portable fallback.
The release publishes them before the top-level `IOViewer.Cli` package, so the installer can resolve its references.

## Licensing contributions

Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ Install the command line tool:
dotnet tool install --global IOViewer.Cli
```

Use the .NET 10 SDK or later to install platform-specific CLI releases. The installer selects a package for
Windows x64, Linux x64 or macOS ARM64 and uses the portable package on other platforms. The CLI runs on
.NET 8 or rolls forward when a newer runtime is available. Portable ZIPs are also available in
[GitHub Releases](https://github.com/IOExtend/IOViewer/releases).

Add the library to a .NET project:

```sh
Expand Down
3 changes: 3 additions & 0 deletions docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ Install the global CLI tool:
dotnet tool install --global IOViewer.Cli
```

Install platform-specific CLI releases with the .NET 10 SDK or later. The command selects the package for
your system, with a portable fallback. The CLI runs on .NET 8 or rolls forward to a newer installed runtime.

Add the library to your .NET project:

```sh
Expand Down
12 changes: 11 additions & 1 deletion src/IOViewer.Cli/IOViewer.Cli.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,16 @@
<WarningsNotAsErrors>NU1901;NU1902;NU1903</WarningsNotAsErrors>
</PropertyGroup>

<PropertyGroup Condition="'$(PackCliForPlatforms)' == 'true'">
<TargetFrameworks>net8.0</TargetFrameworks>
<RollForward>Major</RollForward>
<RuntimeIdentifiers>win-x64;linux-x64;osx-arm64;any</RuntimeIdentifiers>
<SelfContained>false</SelfContained>
<UseAppHost>false</UseAppHost>
<!-- The pointer package has no assemblies to put in a symbol package. -->
<IncludeSymbols Condition="'$(RuntimeIdentifier)' == ''">false</IncludeSymbols>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\IOViewer\IOViewer.csproj" />
<PackageReference Include="IOCoord" />
Expand All @@ -34,7 +44,7 @@
Pack="true" PackagePath="licenses/SkiaSharp-NOTICES.txt" Visible="false" />
</ItemGroup>

<!-- SkiaSharp's native debug symbols add about 147 MB to the tool package across the two target frameworks. -->
<!-- The native SkiaSharp PDB is larger than the rest of the Windows tool payload. -->
<Target Name="ExcludeSkiaSharpNativeDebugSymbols" AfterTargets="ComputeFilesToPublish">
<ItemGroup>
<ResolvedFileToPublish Remove="@(ResolvedFileToPublish)"
Expand Down
128 changes: 128 additions & 0 deletions tests/fixtures/cli/generate-lgs.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
// Generate a synthetic legacy LGS with four points and a JPEG panorama.
#:project ../../../src/IOViewer.Cli/IOViewer.Cli.csproj
#:property PublishAot=false
using System.Text;
using Microsoft.Data.Sqlite;
using SkiaSharp;

string path = args.Single();
string database = Path.ChangeExtension(path, ".db");
using (var connection = new SqliteConnection(new SqliteConnectionStringBuilder
{
DataSource = database,
Pooling = false,
}.ToString()))
{
connection.Open();
using var command = connection.CreateCommand();
command.CommandText = """
CREATE TABLE Hds_OdbSetup (mId INTEGER, mName TEXT);
CREATE TABLE Hds_OdbSetupRef (
mId INTEGER, mSetupId INTEGER, mPositionX REAL, mPositionY REAL, mPositionZ REAL,
mRotationX REAL, mRotationY REAL, mRotationZ REAL, mRotationW REAL);
INSERT INTO Hds_OdbSetup VALUES (1, 'Synthetic station');
INSERT INTO Hds_OdbSetupRef VALUES (1, 1, -2.5, 2.5, 1, 0, 0, 0, 1);
""";
command.ExecuteNonQuery();
}

using var bitmap = new SKBitmap(8, 8);
bitmap.Erase(SKColors.CornflowerBlue);
using var image = SKImage.FromBitmap(bitmap);
using var jpeg = image.Encode(SKEncodedImageFormat.Jpeg, 90);
using var camera = new MemoryStream();
camera.Write("CUBE"u8);
for (int face = 0; face < 6; face++) camera.Write(jpeg.AsSpan());

(string Name, byte[] Data)[] entries =
[
("PointCloud", PointCloud()),
("ProjectDatabase", File.ReadAllBytes(database)),
("SETUP-camera-1", camera.ToArray()),
];
using var file = File.Create(path);
using var writer = new BinaryWriter(file);
writer.Write("wild::geosystems"u8);
var offsets = new long[entries.Length];
for (int i = 0; i < entries.Length; i++)
{
offsets[i] = file.Position;
writer.Write(entries[i].Data);
}

var descriptors = new long[entries.Length];
for (int i = 0; i < entries.Length; i++)
{
descriptors[i] = file.Position;
writer.Write(new byte[10]);
WriteField(writer, entries[i].Name);
writer.Write((byte)3);
writer.Write(offsets[i]);
writer.Write((long)entries[i].Data.Length);
writer.Write(new byte[96]);
}

long toc = file.Position;
writer.Write(entries.Length);
foreach (long descriptor in descriptors) writer.Write(descriptor);
writer.Write("Leica Project File *"u8);
writer.Write(0u);
writer.Write(toc);

// Matches the synthetic four-point grid in PclIO's LegacyLgsTests.
static byte[] PointCloud()
{
using var stream = new MemoryStream();
using var writer = new BinaryWriter(stream);
writer.Write("UDS4\u0007\0\0\0"u8);
writer.Write(0u);
writer.Write(4.0);
writer.Write(1.0);
writer.Write(3u);
double[] grid = [1, 1, 1, -4, 2, 0, .5, .5, .5, .5, .5, .5, .5, .5, .5];
foreach (double value in grid) writer.Write(value);
writer.Write(2u);
WriteField(writer, "UniquePointCount");
WriteField(writer, "4");
WriteField(writer, "ModelAttributes");
WriteField(writer, "udIntensity:u16 udRGB:u32");
long metadataEnd = stream.Position;
stream.Position = 8;
writer.Write((uint)(metadataEnd - 8));
stream.Position = metadataEnd;
uint[] layout = [2, 256, 0, 2, 3, 4, 1, 1];
foreach (uint value in layout) writer.Write(value);
writer.Write(new byte[16]);

WriteBlockDescriptor(writer);
writer.Write(0UL);
writer.Write(0u);
writer.Write(6u);
writer.Write(0x10001u);
WriteBlockDescriptor(writer);
writer.Write(new byte[] { 0x81, 0x22, 0x0c });
for (int i = 1; i <= 4; i++) writer.Write((ushort)(i * 1000));
for (int i = 1; i <= 4; i++) writer.Write(new byte[] { 55, 70, (byte)(i * 10), 255 });
stream.SetLength(3 * 1024);
byte[] data = stream.ToArray();
var mask = new byte[1024];
new Random(42).NextBytes(mask);
for (int i = 0; i < data.Length; i++) data[i] ^= mask[i % mask.Length];
return data;
}

static void WriteField(BinaryWriter writer, string value)
{
writer.Write((ushort)(value.Length + 1));
writer.Write(Encoding.ASCII.GetBytes(value));
writer.Write((byte)0);
}

static void WriteBlockDescriptor(BinaryWriter writer)
{
const int blockBytes = 20 + 16 + 3 + 4 * 6;
writer.Write(blockBytes);
writer.Write(0u);
writer.Write(8u);
writer.Write(16u);
}
2 changes: 1 addition & 1 deletion tools/pack-release.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ if ($LASTEXITCODE -ne 0) { throw "git archive failed with exit code $LASTEXITCOD
Write-Host "Packing NuGet packages..."
# Packages left from an earlier run would be checked and published together with this version.
Get-ChildItem -LiteralPath $Output -File | Where-Object { $_.Extension -in '.nupkg', '.snupkg' } | Remove-Item
Invoke-DotNet pack (Join-Path $root 'IOViewer.slnx') -c Release --no-build -o $Output
Invoke-DotNet pack (Join-Path $root 'IOViewer.slnx') -c Release '-p:PackCliForPlatforms=true' -o $Output

& (Join-Path $PSScriptRoot 'check-packages.ps1') -PackageDirectory $Output

Expand Down
72 changes: 72 additions & 0 deletions tools/test-cli-package.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
param(
[Parameter(Mandatory)]
[string]$PackageDirectory,
[Parameter(Mandatory)]
[string]$Rid
)

$ErrorActionPreference = 'Stop'
Set-StrictMode -Version Latest

$feed = (Resolve-Path -LiteralPath $PackageDirectory).Path
$pointers = @(Get-ChildItem -LiteralPath $feed -File -Filter 'IOViewer.Cli.*.nupkg' |
Where-Object Name -match '^IOViewer\.Cli\.\d')
if ($pointers.Count -ne 1 -or $pointers[0].Length -gt 100KB) {
throw 'Expected one IOViewer.Cli pointer package under 100 KiB.'
}
$version = $pointers[0].Name -replace '^IOViewer\.Cli\.|\.nupkg$', ''
$package = Get-Item -LiteralPath (Join-Path $feed "IOViewer.Cli.$Rid.$version.nupkg")
if ($Rid -ne 'any' -and $package.Length -gt 15MB) {
throw "$($package.Name) is $($package.Length) bytes and exceeds the 15 MiB size limit."
}

function Invoke-Checked([string]$Executable, [string[]]$Arguments) {
& $Executable @Arguments
if ($LASTEXITCODE -ne 0) { throw "$Executable $($Arguments -join ' ') failed with exit code $LASTEXITCODE." }
}

$temp = [IO.Directory]::CreateTempSubdirectory('iov-').FullName
try {
$config = Join-Path $temp 'NuGet.Config'
$source = [Security.SecurityElement]::Escape($feed)
'<configuration><packageSources><clear/><add key="test" value="' + $source + '"/></packageSources></configuration>' |
Set-Content -LiteralPath $config -Encoding utf8
$toolPath = Join-Path $temp 'tool'
Invoke-Checked dotnet @('tool', 'install', 'IOViewer.Cli', '--version', $version, '--tool-path', $toolPath,
'--configfile', $config, '--no-cache')
$installed = @(Get-ChildItem -LiteralPath (Join-Path $toolPath '.store') -File -Recurse -Filter '*.nupkg')
if ($package.Name -notin $installed.Name) { throw "The installer did not select $($package.Name)." }
Write-Host "Installed $($package.Name) ($($package.Length) bytes)."

$fixture = Join-Path $temp 'scan.lgs'
$generator = Join-Path $PSScriptRoot '../tests/fixtures/cli/generate-lgs.cs'
Invoke-Checked dotnet @('run', $generator, '-c', 'Release', '--', $fixture)

$cli = Join-Path $toolPath $(if ($IsWindows) { 'ioviewer.exe' } else { 'ioviewer' })
$html = Join-Path $temp 'scan.html'
$json = Join-Path $temp 'scan.json'
Invoke-Checked $cli @($fixture, '-o', $html, '--json', $json)
$document = Get-Content -LiteralPath $json -Raw | ConvertFrom-Json -AsHashtable
$points = @($document.Scene.Geometries | Where-Object Topology -eq 2)
if ($points.Count -ne 1 -or $points[0].Vertices.Count -ne 12) { throw 'Expected four LGS points.' }
$id = [string]$points[0].Id
$rgb = [Convert]::FromBase64String($document.PointColors[$id])
$intensity = [Convert]::FromBase64String($document.PointIntensities[$id])
if (($rgb -join ',') -ne '10,70,55,30,70,55,20,70,55,40,70,55' -or $intensity.Length -ne 4) {
throw 'Expected the four LGS colors and intensity samples.'
}
$photos = @($document.Panoramas)
if ($photos.Count -ne 1 -or $photos[0].Name -ne 'Synthetic station') {
throw 'Expected the panorama and station name from the LGS project database.'
}
$jpeg = [Convert]::FromBase64String($photos[0].Jpeg)
if ($jpeg.Length -lt 4 -or $jpeg[0] -ne 0xff -or $jpeg[1] -ne 0xd8 -or
$jpeg[-2] -ne 0xff -or $jpeg[-1] -ne 0xd9) {
throw 'Expected a JPEG panorama encoded by the installed tool.'
}
if (-not (Test-Path -LiteralPath $html -PathType Leaf)) { throw 'Expected the standalone HTML export.' }
Write-Host 'Exported four colored points, measured intensity and a JPEG panorama.'
}
finally {
Remove-Item -LiteralPath $temp -Recurse -Force
}
Loading