Skip to content

Instantly share code, notes, and snippets.

@kant2002
Last active March 23, 2020 22:22
Show Gist options
  • Save kant2002/08de74e8849b0d5b1cfa6a714aca891f to your computer and use it in GitHub Desktop.
Save kant2002/08de74e8849b0d5b1cfa6a714aca891f to your computer and use it in GitHub Desktop.
Package UEFI application in VHDX
<Target Name="GenerateVirtuaDisk" AfterTargets="Publish">
<PropertyGroup>
<VHD>$(MSBuildProjectDirectory)\$(NativeOutputPath)seesharpsnake.vhdx</VHD>
<CreatePartitionCommand>
create vdisk file=$(VHD) maximum=40
select vdisk file=$(VHD)
attach vdisk
convert gpt
create partition efi
format quick fs=fat32 label="System"
assign letter="X"
exit
</CreatePartitionCommand>
<CreatePartitionCommand2>
select vdisk file=$(VHD)
select partition 1
remove letter=X
detach vdisk
exit
</CreatePartitionCommand2>
</PropertyGroup>
<Delete Files="$(VHD)" />
<WriteLinesToFile File="$(NativeOutputPath)diskpart1.txt" Overwrite="true" Lines="$(CreatePartitionCommand)" />
<WriteLinesToFile File="$(NativeOutputPath)diskpart2.txt" Overwrite="true" Lines="$(CreatePartitionCommand2)" />
<Exec Command="diskpart /s &quot;$(MSBuildProjectDirectory)\$(NativeOutputPath)diskpart1.txt&quot;" />
<Copy SourceFiles="$(MSBuildProjectDirectory)\$(NativeOutputPath)$(TargetName)$(NativeBinaryExt)" DestinationFiles="X:\EFI\BOOT\BOOTX64.efi" />
<Exec Command="diskpart /s &quot;$(MSBuildProjectDirectory)\$(NativeOutputPath)diskpart2.txt&quot;" />
</Target>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment