-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAppHostPatch.targets
More file actions
54 lines (40 loc) · 2.86 KB
/
Copy pathAppHostPatch.targets
File metadata and controls
54 lines (40 loc) · 2.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<!--
AppHostPatcher
Copyright © 2020 Manuel Huber
See LICENSE for details <https://github.com/FPLedit/AppHostPatch-Linux/blob/main/LICENSE>.
-->
<Project>
<PropertyGroup>
<AppHostPatch_ContainerTool Condition=" '$(AppHostPatch_ContainerTool)' == '' ">podman</AppHostPatch_ContainerTool>
<AppHostPatch_ContainerFile Condition=" '$(AppHostPatch_ContainerFile)' == '' ">Containerfile</AppHostPatch_ContainerFile>
</PropertyGroup>
<Target Name="AppHostPatch_PatchWindowsAppHostLinuxTarget" AfterTargets="Publish" Condition=" '$(RuntimeIdentifier)' == 'win-x64' and '$(OS)' != 'Windows_NT' ">
<PropertyGroup>
<AppHostPatch_AppHostPath>$([System.String]::Copy('$(TargetFileName)').Replace('dll','exe'))</AppHostPatch_AppHostPath>
<AppHostPatch_AppHostPath>$([System.IO.Path]::Combine( '$(PublishDir)', '$(AppHostPatch_AppHostPath)' ) )</AppHostPatch_AppHostPath>
<AppHostPatch_AssemblyPath>$([System.IO.Path]::Combine( '$(PublishDir)', '$(TargetFileName)' ) )</AppHostPatch_AssemblyPath>
<AppHostPatcher_IsWinExe>0</AppHostPatcher_IsWinExe>
<AppHostPatcher_IsWinExe Condition=" '$(OutputType)' == 'WinExe' ">1</AppHostPatcher_IsWinExe>
</PropertyGroup>
<Message Importance="High" Text="Patching app host PE Executable with resources & WinGUI bit." />
<Error Condition="!Exists( '$(AppHostPatch_ContainerFile)' )" Text="Containerfile not found!" />
<!-- Create & start container -->
<Exec Command="$(AppHostPatch_ContainerTool) build -t app-host-patcher -f "$(AppHostPatch_ContainerFile)"" />
<Exec Command="$(AppHostPatch_ContainerTool) run -dt app-host-patcher" ConsoleToMSBuild="true">
<Output TaskParameter="ConsoleOutput" PropertyName="AppHostPatcher_ContainerId" />
</Exec>
<Message Importance="High" Text="Container ID: $(AppHostPatcher_ContainerId)" />
<!-- Copy files -->
<Exec Command="$(AppHostPatch_ContainerTool) cp "$(AppHostPatch_AppHostPath)" $(AppHostPatcher_ContainerId):w.exe" />
<Exec Command="$(AppHostPatch_ContainerTool) cp "$(AppHostPatch_AssemblyPath)" $(AppHostPatcher_ContainerId):w.dll" />
<!-- Execute build step in container -->
<Exec Command="$(AppHostPatch_ContainerTool) exec -it $(AppHostPatcher_ContainerId) wine64 AppHostPatcher.exe w.exe w.dll $(AppHostPatcher_IsWinExe)" />
<!-- Copy back -->
<Exec Command="$(AppHostPatch_ContainerTool) cp $(AppHostPatcher_ContainerId):w.exe "$(AppHostPatch_AppHostPath)"" />
<!-- Cleanup -->
<Exec Command="$(AppHostPatch_ContainerTool) kill $(AppHostPatcher_ContainerId)" />
<Exec Command="$(AppHostPatch_ContainerTool) rm $(AppHostPatcher_ContainerId)" />
<Exec Command="$(AppHostPatch_ContainerTool) image rm app-host-patcher" />
<Message Importance="high" Text="Patched app host file $(AppHostPatch_AppHostPath)!" />
</Target>
</Project>