offlineprep - Offline Preparation

Overview

The offlineprep command prepares your development environment for offline work by updating git repositories and caching NuGet packages. This is essential for developers who need to work without internet connectivity, such as during travel, in secure environments, or in areas with unreliable internet.

Syntax

nmbl offlineprep <RootPath> [options]

Arguments

Options

What It Does

The command performs these steps:

  1. Git Updates - Updates all git repositories to latest
  2. NuGet Caching - Downloads and caches all NuGet packages locally
  3. Validation - Verifies all dependencies are available offline

Examples

Prepare Workspace for Offline Work

nmbl offlineprep ~/projects

Updates all repositories and caches all NuGet dependencies.

Before Travel

# Day before flight
nmbl offlineprep ~/workspace

Ensure you can work during travel without internet.

Skip Git Updates

nmbl offlineprep ~/projects --skip-git

Only cache NuGet packages, don’t update repositories.

Custom Cache Location

nmbl offlineprep ~/projects --cache-path /external-drive/nuget-cache

Use a specific location for the NuGet cache (useful for external drives).

Use Cases

Travel Preparation

# Before a long flight or trip
nmbl offlineprep ~/workspace

# Verify everything is cached
dotnet restore --source ~/.nuget/offline-cache

Secure/Air-Gapped Environments

# On internet-connected machine
nmbl offlineprep ~/projects --cache-path /usb/nuget-cache

# Transfer USB to air-gapped machine
# Configure NuGet to use the cache

Unreliable Internet

# During stable connection
nmbl offlineprep ~/workspace

# Work offline when connection is poor

Weekly Sync

# Every Monday morning
nmbl offlineprep ~/workspace

Keep everything up to date regularly.

Conference/Training Prep

# Before attending conference
nmbl offlineprep ~/demo-projects

# Present demos without worrying about WiFi

How NuGet Caching Works

The command:

  1. Scans all projects for package references
  2. Downloads missing packages to local cache
  3. Configures NuGet to use the local source
  4. Validates packages are available

Using the Offline Cache

After running offlineprep, NuGet is configured to use the local cache:

# Restore from cache
dotnet restore

# The cache is automatically used as a source

Verification

Check Git Status

# After offlineprep
nmbl gitstatus ~/projects

Verify all repositories are up to date.

Verify NuGet Cache

# List cached packages
ls -la ~/.nuget/offline-cache

# Test restore
dotnet restore --source ~/.nuget/offline-cache

Test Offline Build

# Disconnect internet
# Try building
dotnet build

# Should succeed using cached dependencies

Disk Space Considerations

The NuGet cache can be large:

Estimate Cache Size

# Before caching
du -sh ~/.nuget/offline-cache

# After caching
du -sh ~/.nuget/offline-cache

Clean Old Cache

# Remove old cache before creating new one
rm -rf ~/.nuget/offline-cache
nmbl offlineprep ~/projects

Advanced Usage

Multi-Stage Preparation

# Stage 1: Update git repos
nmbl offlineprep ~/projects --skip-nuget

# Stage 2: Cache NuGet (after reviewing updates)
nmbl offlineprep ~/projects --skip-git

Custom Workflow

#!/bin/bash
# prepare-offline.sh

echo "Preparing for offline work..."

# Update repositories
echo "Updating git repositories..."
nmbl gitupdate ~/projects

# Cache NuGet packages
echo "Caching NuGet packages..."
nmbl offlineprep ~/projects --skip-git

# Verify
echo "Verifying setup..."
nmbl gitstatus ~/projects
dotnet restore --source ~/.nuget/offline-cache

echo "Ready for offline work!"

Team Shared Cache

# Create shared cache for team
nmbl offlineprep ~/team-projects --cache-path /shared/nuget-cache

# Team members configure NuGet to use shared cache
dotnet nuget add source /shared/nuget-cache --name TeamCache

Troubleshooting

Git Update Fails

If git updates fail:

# Check status first
nmbl gitstatus ~/projects

# Resolve conflicts manually
# Then cache NuGet packages
nmbl offlineprep ~/projects --skip-git

NuGet Cache Incomplete

If some packages aren’t cached:

# Re-run with verbose output
nmbl offlineprep ~/projects --verbose

# Check for errors

Disk Space Issues

If running out of space:

# Use external drive
nmbl offlineprep ~/projects --cache-path /external/cache

# Or clean old cache first
rm -rf ~/.nuget/offline-cache
nmbl offlineprep ~/projects

Best Practices

Regular Updates

# Weekly sync when online
nmbl offlineprep ~/workspace

Before Offline Periods

# Before extended offline work
nmbl offlineprep ~/workspace

Verify Before Disconnecting

# Test offline build
nmbl offlineprep ~/projects
# Disconnect internet
dotnet build
dotnet test

Document for Team

# Before Traveling
Run: `nmbl offlineprep ~/projects`
Verify: `dotnet build`