GitHub Copilot で IronZIP を使用する方法

Curtis Chau
Curtis Chau
更新日: 2026年10月26日

一部の .NET システムは、1つのサービスごとにログを1つのフォルダーに書き込み、運用チームはそれらを毎日1つの .tar.gz としてコピーし、Linux ホストにコピーして tar -xzf で展開したいと考えています。 それらのバンドルを構築するジョブは、サービスと同じ Visual Studio ソリューションに属しています。

Copilot CLI はターミナルでそのジョブを構築でき、Copilot Chat とエージェントモードは Visual Studio または VS Code 内でそれを構築でき、クラウドエージェントはそれに関する GitHub イシューをプルリクエストに変えることができます。IronZIP は、.NET から TAR と GZIP を作成および展開し、このガイドにあるすべての Copilot サーフェスに TAR コールの動作を伝える2つの指示ファイルをリポジトリに置きます。

TAR作成の例、GZIP作成の例、およびGZIP抽出の例は、このガイドが構築するコールを示しています。

クイックスタート
NuGetNuGet でインストール

PM > Install-Package IronZip

NuGetパッケージマネージャーコンソールで上記のコマンドを実行するか、NuGetパッケージマネージャーでパッケージを検索して、IronZIPをインストールします。

ソリューションのルートで copilot を開始し、このプロンプトを送信してください。 Visual Studio の Copilot Chat は、CLI が @ を使用する場所で # を使用してファイルを命名します。

Read @docs/bundle-format.md, then fill in @src/LogArchiver/Archiving/LogBundle.cs.

Add one public static method that works like this:
- Its signature is Create(string logsRoot, DateOnly day, string outputFolder).
- It writes the day's bundle and returns its path.
- It returns null when the day has no logs.
- It builds the TAR and the GZIP with IronZIP.
- IronZIP comes from the IronZIP package and lives in the IronZip namespace.

Change the bundle command in Program.cs to call Create.
It prints the bundle path, or the message the format document gives for a day without logs.
Run it for 2026-10-10, then list the bundle with tar -tvzf and show me the listing.
Text

パス固有の指示ファイルには IronZIP の TAR 命名規則が記載されているので、プロンプトではこれを省略します。

キーを IRONZIP_LICENSE_KEY 環境変数またはリポジトリのシークレットに保存し、プロンプトやコミットから外してください。 その変数だけを設定したプローブでは、License.IsLicensed は false を返したので、Program.cs はその値を IronZip.License.LicenseKey にコピーします。 代わりに構成ファイルにキーを設定する場合は、ライセンスキーガイドに従ってください。 クラウドエージェントのプルリクエストに対して、ブランチ保護と人間による承認をオンのままにしてください。



Copilot に対する IronZIP の慣習をどのように設定しますか?

GitHub のサポートリファレンスは、Copilot CLI、クラウドエージェント、および Visual Studio と VS Code の両方での Copilot Chat のために .github/copilot-instructions.md を一覧していて、パッケージ、ライセンス、およびテストのルールがそこに移行されます。 Visual Studio は、その Copilot Chat オプションのカスタム指示チェックボックスを選択するまでファイルを無視します。

Archive code in this repo follows these rules:

- Archive code uses IronZIP from the IronZIP NuGet package, namespace IronZip.
- Add no other compression package.
- Keep System.Formats.Tar and System.IO.Compression out of src/.
- Tests may use them to read bundles.
- Change the IronZIP version in Directory.Packages.props only for an upgrade task.
- IRONZIP_LICENSE_KEY holds the license key.
- Never put it in code, settings, tests or output, and never echo it.
- Check only that it is set.
- docs/bundle-format.md is the contract for every bundle.
- Do not edit it, and report any place where the code departs from it.
- IronZIP documentation for agents: https://ironsoftware.com/zip/csharp/llms.txt
- Find each IronZIP member in IronZip.xml in the NuGet cache before using it.
- If a member is missing there, say so.

The tests follow these rules:

- A test that calls IronZIP copies IRONZIP_LICENSE_KEY into License.LicenseKey first.
- IronZIP never reads that variable on its own.
- Write bundles into a temp folder.
- Unpack them into a second empty folder and compare files by SHA-256.
- Never compare archive bytes.
Markdown

アーカイブコードにはどのようにして独自のルールを与えますか?

アーカイブルールを .github/instructions/archives.instructions.md として保存します。 GitHub ドキュメントによると、Copilot CLI はその applyTo 値が CLI が扱っているファイルに一致する場合にのみパス固有のファイルを含めます。 /instructions コマンドは CLI が見つけた指示ファイルを一覧表示し、それぞれをオンまたはオフに切り替えます。

---
applyTo: "src/LogArchiver/**,tests/LogArchiver.Tests/**"
---

IronZIP's TAR and GZIP calls behave this way in the log archiver and its tests:

- IronTarArchive.Add keeps only the file name and drops every folder.
- Two files with one name become two entries with that name, and unpacking keeps the last.
- Copy each file into a staging folder under its final entry name and add the copy.
- IronTarArchive.Add on a folder adds nothing and throws nothing.
- A GZIP file holds one stream.
- Save the TAR first, then add that single file to an IronGZipArchive.
- Two files added to one IronGZipArchive come out as one file with both contents joined.
- GetArchiveEntryNames throws on a new archive that was never saved.
- Call it on an archive opened from a file.
- No entry can be added after SaveAs. Start a new archive instead.
- Unpack a .tar.gz with IronGZipArchive.ExtractTGZArchiveToDirectory.
- Always unpack into a new empty folder.
- Unpacking replaces files of the same name and leaves every other file where it was.
- IronTarArchive.ExtractArchiveToDirectory writes an entry named ../x or /x outside the target.
- Check every name from GetArchiveEntryNames first.
- Without a key, IronTarArchive.Add throws LicensingException.
- SaveAs then still writes an empty archive.
- Never catch that exception and continue.
Markdown

IronZIP の TAR ライターはファイルパスから何を保持しますか?

ここにある各サービスは、ログを日付で名前付けしているので、logs/api/2026-10-10.log と logs/worker/2026-10-10.log はファイル名を共有しています。 IronZIP 2026.10.2 からそのフォルダーから直接追加された4つのログは、2026年10月10日には 2026-10-10.log という4つのTARエントリになりました。 tar -tvzf は4つすべてを一覧表示し、何も投げませんでした。 IronZIPで展開されると、そのバンドルには、追加された最後の worker ログである19,813 バイトの 2026-10-10.logが含まれていました。

各ログがそのサービス名で名付けられたコピーとしてステージングされている場合、worker-2026-10-10.log など、10月9日と8日のバンドルは、IronZIP を使わずにバンドルを読むPythonのフォーマットチェッカーの24回のチェックすべてに通りました。エントリはすべてモード700、オーナー0、ファイル自体のタイムスタンプではなく保存した時間を持っていました。同じロットの2つのバンドルは、2秒離れて構築され、GZIP がその時間を保存する第5バイトから異なりました。

書き込まれた後のバンドルをどのように確認しますか?

使い古されたフォルダーを指すと、ExtractTGZArchiveToDirectory は同名のファイルを置き換え、残りは維持したので、フォルダーを再利用するチェックで古いファイルをカウントできます。

Add a verify <bundle> command to Program.cs beside bundle.

The command runs these steps in order:
1. Unpack the bundle with IronZIP into a fresh temp folder.
2. Read manifest.txt there.
3. Confirm the folder holds manifest.txt plus exactly the files it names.
4. Confirm those files have matching sizes and SHA-256 hashes.

It reports the outcome this way:
- Print one line for each problem, and exit 1 if there is one.
- If there is none, print the file count and exit 0.
- If IronZIP cannot unpack the bundle, print its exception and exit 1.
- Delete the temp folder either way.

Run verify on the 2026-10-10 bundle.
Then run it on a copy of that bundle in a temp folder with the middle byte flipped.
Show me both results.
Text

キャリブレーションプローブでは、フリップされたバイトにより、IronZIP が最初のログの書き込み後に TarException (「ヘッダーのチェックサムが無効です」) を投げたため、失敗した展開は部分的なフォルダーを残す場合があります。

IronZIP バンドルをどのようにテストしますか?

System.Formats.Tar と IronZIP で各バンドルを読み取るテストは、IronZIP のアンパックが隠す命名の誤りを検出します。 GitHub の CLI リファレンスでは、/plan が Copilot CLI がコードを探求できるがプロジェクトファイルの編集がブロックされる計画セッションを開始すると言っています。

/plan an xUnit suite in tests/LogArchiver.Tests for LogBundle.Create.
Each test copies the logs folder to a temp directory and writes its bundles there.

Read each bundle back in two ways:
- unpacked by IronZIP into an empty folder
- listed with System.Formats.Tar over a GZipStream, which needs no IronZIP

The suite shows each of these points:
- The 2026-10-10 bundle has one top-level entry per service log plus manifest.txt.
- No entry name is repeated.
- Each unpacked log matches its source by SHA-256.
- The rotated .log.1 file and other days are left out.
- A day without logs writes nothing.
- Only the bundle remains in the output folder.

After I approve the plan, write the tests and run them with dotnet test.
Tell me how many passed and how many failed.
Text

なぜ古いTARを復元するとフォルダー外に書き込まれるのですか?

2026年前のバンドルはプレーンTARファイルで、チームメイトの復元コマンドが IronTarArchive.ExtractArchiveToDirectory でそれらを展開します。 あるプローブでは、その呼び出しがターゲットの上のフォルダーに ../escaped-dotdot.txt という名のエントリを書き込み、ドライブのルートに絶対名を持つエントリも書き込みました。ExtractTGZArchiveToDirectory は同じ ../ エントリを InvalidNameException で拒否しましたが、これはその前のエントリを展開した後のことでした。

セットアップコミットは、RestoreCommand.cs、RestoreTests.cs、および TestData/restore の下の2つのTARファイルを追加します。

A teammate added @src/LogArchiver/Archiving/RestoreCommand.cs.
It restores the plain .tar archives kept from before 2026.
RestoreTests now fails on TestData/restore/hostile.tar.

Before changing any code, do these three things:
1. Run that test.
2. Print the entry names IronZIP reports for both .tar files in TestData/restore.
3. Explain how a file ends up outside the target folder.

Then fix it in RestoreCommand.cs alone.
An archive with any entry that would be written outside the target must be refused.
Refuse it before a single file is written.
Leave TestData and the tests untouched.
Run dotnet test and report the result.
Text

キャリブレーション用に書かれたリファレンス修正は GetArchiveEntryNames で名前を読み込み、ターゲット外に解決されるものを拒否し、両方の復元テストを通過しました。

クラウドエージェントが行動できる問題を作成するにはどうすれば良いですか?

クラウドエージェントは、割り当てられたイシューのタイトル、説明、既存のコメント、および追加指示を見ます。 GitHub は、エージェントが割り当て後に追加されたコメントを見ないと言っているので、受け入れテストはイシュー本文に入ります。

Title: Write a .tar.bz2 copy of each bundle for cold storage

This issue touches the following:
- Files: src/LogArchiver/Archiving/LogBundle.cs, tests/LogArchiver.Tests
- IronZIP version: whatever Directory.Packages.props pins
- Target framework: .NET 9

After the change, the bundle command behaves like this:
- bundle <date> also writes out/cold/logs-<date>.tar.bz2.
- That file holds the same TAR as the .tar.gz.
- The pull request text proposes the matching docs/bundle-format.md rule.
- That rule goes in a separate pull request.

Today, cold storage bills by size and receives the .tar.gz only.

The work stays inside these limits:
- Build the TAR once and compress that one file twice.
- Use IronGZipArchive and IronBZip2Archive for the two copies.
- Keep the .tar.gz unchanged.
- No new packages.

The issue is done when these checks pass:
- dotnet test passes.
- A new test unpacks the .tar.bz2 with IronBZip2Archive.ExtractArchiveToDirectory.
- It unpacks into an empty folder.
- It finds every log and manifest.txt identical to the .tar.gz contents.
Markdown

IronBZip2Archive は圧縮レベルを取らず、その ExtractArchiveToDirectory は .tar.bz2 を直接TARの中のファイルに展開しました。

なぜクラウドエージェントのテストが IronZIP プロジェクトで失敗するのですか?

クラウドエージェントはデフォルトで Ubuntu Linux で動作します。 IronZIP は単一の .NET Standard 2.0 アセンブリを提供し、そのパッケージにも依存関係の IronSoftware.Common にもネイティブバイナリは含まれていないため、ランナーにはリストアが必要です。 Agents シークレットがなければ、IRONZIP_LICENSE_KEY はランナーに設定されません。 キーがないと、IronTarArchive.Add は「Production License Required」とともに LicensingException を投げ、同じアーカイブで SaveAs はエントリがなくても 10,240 バイトの TAR を書きました。 例外をキャッチして続行するコードは空のバンドルを書きます。

Copilot が作業を始めるのは copilot-setup-steps ジョブが完了してからで、GitHub はデフォルトのブランチに .github/workflows/copilot-setup-steps.yml が存在するときのみそのジョブをトリガーします。

Write the cloud agent's setup file, .github/workflows/copilot-setup-steps.yml.

The file holds one job with these settings:
- Name the job copilot-setup-steps.
- Give it contents: read.
- Run it on workflow_dispatch plus pull requests that edit this file.

The job runs these steps in order:
1. Fetch the repository.
2. Set up the .NET 9 SDK.
3. Restore.
4. Build the solution in Release.
5. Print tar --version, since the agent can compare its bundles with GNU tar.
6. Print a warning that names IRONZIP_LICENSE_KEY when that variable is empty.

IronZIP will not add entries without the key, which is why step 6 warns.
Step 6 always exits 0.
Print the YAML.
Text

クラウドエージェントが Actions、Codespaces、または Dependabot のシークレットを見れないので、キーをリポジトリの設定の「セキュリティ」の下にあるシークレットと変数の Agents タブに保存してください。

マージする前に何を確認すべきですか?

GitHub のドキュメントでは、/review が copilot -p に渡されるので、レビューはそのセッション内で実行され、コーディングセッションとは別です。

/review every commit after the first on this branch.
Compare those commits with docs/bundle-format.md and the two instruction files in .github.

Report each of these:
- an IronTarArchive.Add whose path does not already end in the final entry name
- a GetArchiveEntryNames on an archive that was never saved or opened
- an Add after SaveAs
- any unpacking into a folder that may hold files already
- an IronTarArchive.ExtractArchiveToDirectory without a check of every entry name first
- a catch that could hide a LicensingException
- an IronZIP member absent from IronZip.xml in the NuGet cache

Give the file and line of each finding, and modify nothing.
Text

プロンプトが実運用で生成したものは何ですか?

Copilot CLI は、最初の5つを1つのセッションで、レビューのプロンプトを別の copilot -p 呼び出しで受け取り、6つのプロンプトを順番に受け取りました。 ターゲットはこのガイドのために作られた .NET 9 ログソリューションで、4つのサービスにわたって7つのログを持ち、それらをカウントするだけのコンソールジョブ、空の xUnit プロジェクト、フォーマットドキュメントが含まれていました。 以下の図はレビュー結果および最後の箇条書きを除き、すべてセッション終了後に行われたチェックから得られたものです。 AIコーディングアシスタントガイド の受け入れプロンプトは、同じ2つの方法で ZIP および .tgz アーカイブを検査し、エントリ名の区別と抽出後の SHA-256 でそれらを確認します。

  • フォーマットチェッカーは、バンドルを書き込まない未処理のジョブでの4つのチェック中2つに合格しました。
  • 最初のプロンプトの後、チェッカーは10月10日、9日、および8日に対して24個中24個のチェックに合格しました。
  • 10月10日のバンドルには、サービスに接頭辞が付けられた名前の下の4つのログと manifest.txt が含まれていました。
  • 最後のプロンプト後も24個中24個のチェックに合格しました。
  • 10月10日のバンドルの上で、検証コマンドが4つのログをカウントし、終了コード0を出しました。
  • 中間バイトが反転したコピーにより、コマンドは TarException で終了コード1を出しました。
  • コマンドのどちらも一時フォルダーを残しませんでした。
  • 計画されたスイートのテストはどちらも合格しました。
  • それらのテストの1つは、サービスフォルダーから直接ログを追加した最終コードのコピーで失敗しました。
  • セットアップコミットはリストアテストを1つ合格、1つ失敗にし、hostile.tar は例外を投げませんでした。
  • リストアプロンプトは RestoreCommand.cs を変更し、他のファイルは変更しませんでした。
  • そのプロンプト後、両方のリストアテストは合格しました。
  • セットアップワークフローは6つのステップの1つの copilot-setup-steps ジョブとして解析され、キーのチェックが最後になっています。
  • 最終リリースビルドが警告0件、エラー0件で完了しました。
  • レビューはすべてのファイルを変更せず、3つの発見を報告しました。そのうち1つは、コードが検査していない空のフォルダーにリストアされるものでした。
  • 一部のステップはページと異なる方法で実行されました。 予行プロンプトはオートパイロット付きの計画モードで実行され、Copilot CLI は独自の計画を承認しました。 そのテストは System.Formats.Tar でエントリ名を読み取り、IronZIP が展開したファイルのハッシュを比較しました。 Copilot CLI の腐敗したコピーには 1 ビットがフリップしていて、例外なく展開され、3つの SHA-256 の不一致で失敗しました。 イシュー、クラウドエージェント、Actions 上のセットアップワークフロー、および Agents シークレットには GitHub リポジトリが必要であるため、どれも実行されませんでした。

カーサーガイドは ZIP バンドルコードを IronZIP に移植し、Add も各エントリ名からフォルダーを削除し、その移植されたバンドルには平坦なユニークな名前が付けられた7つのエントリが含まれていました。 Google Antigravityガイドもそれぞれのアーカイブを IronZIP で抽出し、すべてのファイルを SHA-256 で比較してチェックします。共有ランレコードには、このガイドの Copilot CLI のバージョン、モデル、運用時間、およびテストマシンが記載されています。


トラブルシューティング


質問ありますか?

質問がある場合は、support@ironsoftware.com にお問い合わせください。

Curtis Chauは、カールトン大学でコンピュータサイエンスの学士号を取得し、Node.js、TypeScript、JavaScript、およびReactに精通したフロントエンド開発を専門としています。直感的で美しいユーザーインターフェースを作成することに情熱を持ち、Curtisは現代のフレームワークを用いた開発や、構造の良い視覚的に魅力的なマニュアルの作成を楽しんでいます。

もっと読む

準備はできましたか?

NuGetダウンロード数 25,383バージョン:2026.11ちょうどリリースされました