diff --git a/builder/vmware/iso/builder.go b/builder/vmware/iso/builder.go index 10fce5911..6f512ac82 100755 --- a/builder/vmware/iso/builder.go +++ b/builder/vmware/iso/builder.go @@ -199,7 +199,10 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe default: dir = new(vmwcommon.LocalOutputDir) } + + var localDir localOutputDir if b.config.RemoteType != "" && b.config.Format != "" { + localDir = localOutputDir{b.config.OutputDir} b.config.OutputDir = b.config.VMName } dir.SetOutputDir(b.config.OutputDir) @@ -210,6 +213,7 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe state.Put("config", &b.config) state.Put("debug", b.config.PackerDebug) state.Put("dir", dir) + state.Put("localDir", localDir) state.Put("driver", driver) state.Put("hook", hook) state.Put("ui", ui) diff --git a/builder/vmware/iso/step_export.go b/builder/vmware/iso/step_export.go index 13f5cf77f..b7fcbd24c 100644 --- a/builder/vmware/iso/step_export.go +++ b/builder/vmware/iso/step_export.go @@ -59,7 +59,8 @@ func (s *StepExport) Run(state multistep.StateBag) multistep.StepAction { } // Export the VM - outputPath := filepath.Join(c.OutputDir, c.VMName+"."+s.Format) + localDir := state.Get("localDir").(localOutputDir) + outputPath := filepath.Join(fmt.Sprintf("%v", localDir), c.VMName+"."+s.Format) if s.Format == "ova" { os.MkdirAll(outputPath, 0755)