Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hyper-V BYOC build failing in New-IsoFile #101

Closed
mikee47 opened this issue Dec 3, 2021 · 4 comments
Closed

Hyper-V BYOC build failing in New-IsoFile #101

mikee47 opened this issue Dec 3, 2021 · 4 comments

Comments

@mikee47
Copy link
Contributor

mikee47 commented Dec 3, 2021

Attempting to build for hyper-v fails due to conflict in New-IsoFile function.

PS C:\Users\Mike> Connect-AppVeyorToHyperV -AppVeyorUrl https://ci.appveyor.com -ApiToken XXXXXXXXX -CpuCores 16 -RamMb 2048 -ImageName "windows-hv" -ImageOs "Windows" -ImageTemplate "minimal-windows-server.json" -ImageFeatures "" -ImageCustomScript "Z2l0IGNsb25lIGh0dHBzOi8vZ2l0aHViLmNvbS9TbWluZ0h1Yi9TbWluZyAtLWJyYW5jaCBkZXZlbG9wIC0tZGVwdGggMSAvdG1wL3NtaW5nCi90bXAvc21pbmcvVG9vbHMvRG9ja2VyL2FwcHZleW9yL3NldHVwLnBzMQ==" -ImageCustomScriptAfterReboot ""

Checking AppVeyor API access...

Checking if Hyper-V tools are installed...
WARNING:
This command will create Hyper-V resources such as virtual switch and related subnet and NAT. For Linux VMs it will also create a new firewall rule. Also, it will run Hashicorp Packer which will create its own temporary Hyper-V resources and leave VHD for future use by AppVeyor build VMs.

If this server contains production resources you might consider using separate one.

Press Enter to continue or Ctrl-C to exit the command. Use '-SkipDisclaimer' switch parameter to skip this message next time.

New-IsoFile: M:\Users\Mike\Documents\PowerShell\Modules\AppVeyorBYOC\1.0.178\Connect-AppVeyorToHyperV.ps1:312
Line |
 312 |          New-IsoFile -Path $FileName -Source $Files -Force -Media "CDR …
     |          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | A parameter cannot be found that matches parameter name 'CompilerParameters'.

I've managed to get past this as follows:

  1. Add Add current New-ISOFile.ps1 from https://github.com/TheDotSource/New-ISOFile
  2. Revise code:
diff --git a/Connect-AppVeyorToHyperV.ps1 b/Connect-AppVeyorToHyperV.ps1
index db3adb6..6c7d8fb 100644
--- a/Connect-AppVeyorToHyperV.ps1
+++ b/Connect-AppVeyorToHyperV.ps1
@@ -309,7 +309,13 @@ Function Connect-AppVeyorToHyperV {
             "$ParentFolder/hyper-v/Windows/scripts/shutdown_vm.bat",
             "$ParentFolder/hyper-v/Windows/scripts/win-updates.ps1"
         )
-        New-IsoFile -Path $FileName -Source $Files -Force -Media "CDR"
+        $StagingFolder="$ParentFolder/iso-source"
+        mkdir -f "$StagingFolder"
+        foreach ($f in $Files)
+        {
+            Copy-Item -Force "$f" "$StagingFolder"
+        }
+        New-IsoFile -destinationIso "$FileName" -source "$StagingFolder" -Force -Media "CDR"
     }
     elseif ($imageOs -eq "Linux")
     {

However the resulting image isn't bootable so clearly isn't a full fix. Am I missing something simple?

NB. Work in progress at https://github.com/mikee47/appveyor-build-images/tree/fix/hyperv-build

@mikee47
Copy link
Contributor Author

mikee47 commented Dec 3, 2021

Update: I needed to manually hit ENTER to prevent network boot. Install proceeding...

@mikee47 mikee47 changed the title Hyper-V BYOC build failing Hyper-V BYOC build failing in New-IsoFile Dec 3, 2021
@mikee47
Copy link
Contributor Author

mikee47 commented Dec 4, 2021

It seems the script does send key sequence to prevent network boot, but it's too late!

Anyway, success so all good.

Linux hyperv build not so much... hangs waiting for ssh connection...

@FeodorFitsner
Copy link
Member

So, your changes have been merged and a new version of AppVeyorBYOC module published: https://www.powershellgallery.com/packages/AppVeyorBYOC/1.0.179

@mikee47
Copy link
Contributor Author

mikee47 commented Dec 6, 2021

Great, thank you.

@mikee47 mikee47 closed this as completed Dec 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants