Skip to content

Automate your Unity releases. A high-performance .NET tool to pack assets and dependencies into .unitypackage files for GitHub Actions and other CI systems.

License

Notifications You must be signed in to change notification settings

Guardingpearsoftware/public-unity-package-exporter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Unity Package Exporter

A high-performance CLI tool to export a Unity project or directory into a .unitypackage file.

Features

  • Fast Export: Utilizes parallel processing and optimized I/O to quickly pack assets.
  • Dependency Analysis: Automatically finds and includes dependent assets (scripts, materials, prefabs) to ensure your package works out of the box.
  • Customizable: Options for including/excluding files via glob patterns.

Usage

Run the tool using the dotnet CLI. You can use the --help command to see all available options.

dotnet UnityPackageExporter.dll --help

Command Line Reference

Description:
  Packs the assets in a Unity Project

Usage:
  UnityPackageExporter <source> <output> [options]

Arguments:
  <source>  Unity Project Directory.
  <output>  Output .unitypackage file

Options:
  -a, --assets <assets>                   Adds an asset to the pack. Supports glob matching. [default: **.*]
  -e, --exclude <exclude>                 Excludes an asset from the pack. Supports glob matching. [default:
                                          Library/**.*|**/.*]
  --skip-dependency-check                 Skips dependency analysis. Disabling this feature may result in missing
                                          assets in your packages. [default: False]
  -r, --asset-root <asset-root>           Sets the root directory for the assets. Used in dependency analysis to only
                                          check files that could be potentially included. [default: Assets]
  -v, --log-level, --verbose <log-level>  Sets the logging level (Trace, Debug, Information, Warning, Error, Critical) [default: Trace]
  --version                               Show version information
  -?, -h, --help                          Show help and usage information

Example

dotnet UnityPackageExporter.dll "Projects/MyGame" package.unitypackage --assets "Assets/MyAsset/**.*" --skip-dependency-check

Github Actions

Below is a GitHub action for packaging a Unity Package styled project (no Assets folder).

jobs:
  env:
    package_path: "~/my-package.unitypackage"
  build:
    runs-on: ubuntu-latest
    steps:
      # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
      - uses: actions/checkout@v3
      - uses: actions/setup-dotnet@v2

      # Install the packager. We are putting it outside the working directory so we dont include it by mistake
      - name: Install Unity Packager
        run: |
          git clone https://github.com/Guardingpearsoftware/public-unity-package-exporter.git "../tools/unity-package-exporter"
          dotnet publish -c Release -o ../tools "../tools/unity-package-exporter/UnityPackageExporter"
        
      # Pack the assets
      - name: Package Project
        run: |
          echo "Creating package ${{env.package_path}}"
          dotnet ../tools/UnityPackageExporter.dll ./ ${{env.package_path}} --exclude ".*" --exclude "Documentation"
        
      # Upload artifact
      - name: Upload Artifact
        uses: actions/upload-artifact@v3.0.0
        with:
          name: Unity Package
          path: ${{env.package_path}}   

NOTE: We perform a publish and then run the DLL to avoid known issues with running projects directly.

Important Notes

This package builder requires the .meta files generated by Unity to properly pack assets. If you ignore .meta files in your .gitignore, this tool may fail to link assets correctly, leading to broken packages. Ensure .meta files are committed to your repository.

Dependency Analysis

This tool automatically scans selected assets for dependencies. While optimized with parallel processing, deep dependency analysis on large projects can still take time.

  • Use the --skip-dependency-check flag to skip this step if you are manually ensuring all assets are included via glob patterns.
  • The --asset-root flag determines the starting folder for dependency scanning. By default, this is the Assets folder. For large projects or specific Package projects, setting this to a more specific directory limits the scan scope and significantly improves performance.

The exclusion rules still apply to assets found via dependency analysis.

Credits & Acknowledgements

This project is a fork of Lachee/Unity-Package-Exporter. It has been modernized to run on .NET 8, optimized with parallel processing and asynchronous I/O for faster exports.

A huge thank you to Lachee for the original implementation!

About

Automate your Unity releases. A high-performance .NET tool to pack assets and dependencies into .unitypackage files for GitHub Actions and other CI systems.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages