I've created a new box for use with the Hyper-V provider. When I try to add the box, it dies with the following:
PS C:\> vagrant box add sbx-misc-app01 .\img-misc-w2k16.box
==> box: Box file was not detected as metadata. Adding it directly...
==> box: Adding box 'sbx-misc-app01' (v0) for provider:
box: Unpacking necessary files from: file://C:/img-misc-w2k16.box
box:
C:/HashiCorp/Vagrant/embedded/gems/2.0.3/gems/vagrant-2.0.3/lib/vagrant/box_collection.rb:156:in `block (3 levels) in add': undefined method `to_sym' for nil:NilClass (NoMethodError)
from C:/HashiCorp/Vagrant/embedded/gems/2.0.3/gems/vagrant-2.0.3/lib/vagrant/box_collection.rb:461:in `with_temp_dir'
from C:/HashiCorp/Vagrant/embedded/gems/2.0.3/gems/vagrant-2.0.3/lib/vagrant/box_collection.rb:134:in `block (2 levels) in add'
from C:/HashiCorp/Vagrant/embedded/gems/2.0.3/gems/vagrant-2.0.3/lib/vagrant/box_collection.rb:461:in `with_temp_dir'
from C:/HashiCorp/Vagrant/embedded/gems/2.0.3/gems/vagrant-2.0.3/lib/vagrant/box_collection.rb:115:in `block inadd' from C:/HashiCorp/Vagrant/embedded/gems/2.0.3/gems/vagrant-2.0.3/lib/vagrant/box_collection.rb:448:in `block in with_collection_lock'
from C:/HashiCorp/Vagrant/embedded/mingw64/lib/ruby/2.4.0/monitor.rb:214:in `mon_synchronize'
from C:/HashiCorp/Vagrant/embedded/gems/2.0.3/gems/vagrant-2.0.3/lib/vagrant/box_collection.rb:447:in `with_collection_lock'
from C:/HashiCorp/Vagrant/embedded/gems/2.0.3/gems/vagrant-2.0.3/lib/vagrant/box_collection.rb:104:in `add'
from C:/HashiCorp/Vagrant/embedded/gems/2.0.3/gems/vagrant-2.0.3/lib/vagrant/action/builtin/box_add.rb:357:in `box_add'
from C:/HashiCorp/Vagrant/embedded/gems/2.0.3/gems/vagrant-2.0.3/lib/vagrant/action/builtin/box_add.rb:146:in `add_direct'
from C:/HashiCorp/Vagrant/embedded/gems/2.0.3/gems/vagrant-2.0.3/lib/vagrant/action/builtin/box_add.rb:120:in `call'
from C:/HashiCorp/Vagrant/embedded/gems/2.0.3/gems/vagrant-2.0.3/lib/vagrant/action/warden.rb:34:in `call'
from C:/HashiCorp/Vagrant/embedded/gems/2.0.3/gems/vagrant-2.0.3/lib/vagrant/action/builder.rb:116:in `call'
from C:/HashiCorp/Vagrant/embedded/gems/2.0.3/gems/vagrant-2.0.3/lib/vagrant/action/runner.rb:66:in `block in run'
from C:/HashiCorp/Vagrant/embedded/gems/2.0.3/gems/vagrant-2.0.3/lib/vagrant/util/busy.rb:19:in `busy'
from C:/HashiCorp/Vagrant/embedded/gems/2.0.3/gems/vagrant-2.0.3/lib/vagrant/action/runner.rb:66:in `run'
from C:/HashiCorp/Vagrant/embedded/gems/2.0.3/gems/vagrant-2.0.3/plugins/commands/box/command/add.rb:78:in `execute'
from C:/HashiCorp/Vagrant/embedded/gems/2.0.3/gems/vagrant-2.0.3/plugins/commands/box/command/root.rb:66:in `execute'
from C:/HashiCorp/Vagrant/embedded/gems/2.0.3/gems/vagrant-2.0.3/lib/vagrant/cli.rb:46:in `execute'
from C:/HashiCorp/Vagrant/embedded/gems/2.0.3/gems/vagrant-2.0.3/lib/vagrant/environment.rb:269:in `cli'
from C:/HashiCorp/Vagrant/embedded/gems/2.0.3/gems/vagrant-2.0.3/bin/vagrant:151:in `<main>'
Questions:
Environment...
Contents of box...
C:\img-misc-w2k16\Virtual Hard Disks
C:\img-misc-w2k16\Virtual Machines
C:\img-misc-w2k16\metadata.json
C:\img-misc-w2k16\Virtual Hard Disks\img-misc-w2k16.vhdx
C:\img-misc-w2k16\Virtual Machines\AB56D8F5-4F71-4CCD-97E6-237713B79FD8....
C:\img-misc-w2k16\Virtual Machines\AB56D8F5-4F71-4CCD-97E6-237713B79FD8....
Contents of metadata.json...
{
"name": "foo/windowsServer2016x64",
"description": "This box contains Windows Server 2016 64-bit standard edition.",
"versions": [
{
"version": "1.0.0",
"providers": [
{
"name": "hyperv"
}
]
}
]
}
It seems there is some confusion about the different aspects of the box.
so taking from https://www.vagrantup.com/docs/boxes/format.html
Box File - This is a compressed (tar, tar.gz, zip) file that is specific to a single provider and can contain anything. Vagrant core does not ever use the contents of this file. Instead, they are passed to the provider. Therefore, a VirtualBox box file has different contents from a VMware box file and so on.
Box Catalog Metadata - This is a JSON document (typically exchanged during interactions with HashiCorp's Vagrant Cloud) that specifies the name of the box, a description, available versions, available providers, and URLs to the actual box files (next component) for each provider and version. If this catalog metadata does not exist, a box file can still be added directly, but it will not support versioning and updating.
The file C:\img-misc-w2k16\metadata.json
is part of the box file - it is different from the box catalog metadata (used if you want to distribute your box) but the content that you share is a box catalog metadata.
reading further
Within the archive, Vagrant does expect a single file: metadata.json. This is a JSON file that is completely unrelated to the above box catalog metadata component; there is only one metadata.json per box file (inside the box file), whereas one catalog metadata JSON document can describe multiple versions of the same box, potentially spanning multiple providers.
metadata.json must contain at least the "provider" key with the provider the box is for. Vagrant uses this to verify the provider of the box. For example, if your box was for VirtualBox, the metadata.json would look like this:
{ "provider": "virtualbox" }
If there is no metadata.json file or the file does not contain valid JSON with at least a "provider" key, then Vagrant will error when adding the box, because it cannot verify the provider.
so when you package your box, the Contents of metadata.json should be as
{
"provider": "hyperv"
}
once you replace the content of your file, you can repackage the box and you should be able to run a VM from this box.