|
1 | 1 | <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
2 |
| - <PropertyGroup> |
3 |
| - <Name>DllIntoFolder</Name> |
4 |
| - </PropertyGroup> |
| 2 | + <PropertyGroup> |
| 3 | + <Name>DllIntoFolder</Name> |
| 4 | + <DllFolder>bin</DllFolder> |
| 5 | + </PropertyGroup> |
5 | 6 |
|
6 |
| - <!--This is used to move all reference dll to a separate folder after publish, as same as dnspy--> |
7 |
| - <Target Condition="'$(PublishProtocol)'!=''" Name="DllIntoFolder" AfterTargets="Publish"> |
8 |
| - <!--Clear old output--> |
9 |
| - <RemoveDir Directories="$(PublishDir)bin" /> |
10 |
| - <!--"robocopy" uses 1 as a success exit code, will be considered a failure by Exec task by default.--> |
11 |
| - <!--Set "ContinueOnError" of Exec task to true to continue even if occur error--> |
12 |
| - <Exec ContinueOnError="True" Command="robocopy "$(PublishDir.TrimEnd('\'))" "$(PublishDir)bin" /MOVE /E /NP /XD "$(ProjectDir)$(PublishDir)bin" @(MoveExcludeFolders-> '"$(ProjectDir)$(PublishDir)%(RelativeDir)%(FileName)"', ' ') /XF "$(ProjectDir)$(PublishDir)$(AssemblyName).exe" @(MoveExcludeFiles-> '"$(ProjectDir)$(PublishDir)%(RelativeDir)%(FileName)%(Extension)"', ' ')"> |
13 |
| - <!--Then use Output return ExitCode into ErrorCode--> |
14 |
| - <Output TaskParameter="ExitCode" PropertyName="ErrorCode" /> |
15 |
| - </Exec> |
16 |
| - <!--If ExitCode > 8 then break, "robocopy" exit code greater than 8 indicates failure--> |
17 |
| - <Error Condition="$(ErrorCode) > 8" Message="Failed to move file!" /> |
18 |
| - <!--Call "Patch.cscript" in powershell to modify the entry dll path of .NET Core dll Host exe file--> |
19 |
| - <Exec Command="powershell $source=Get-Content -Path '$(ProjectDir)Properties/Patch.cscript'; Add-Type -TypeDefinition $source[0]; [AppHostPatcher]::Patch('$(PublishDir)$(AssemblyName).exe','bin/$(AssemblyName).dll')" /> |
20 |
| - <!--Explain command:--> |
| 7 | + <!--This is used to move all reference dll to a separate folder after publish, as same as dnspy--> |
| 8 | + <Target Condition="'$(PublishProtocol)'!=''" Name="DllIntoFolder" AfterTargets="Publish"> |
| 9 | + <!--Clear old output--> |
| 10 | + <RemoveDir Directories="$(PublishDir)$(DllFolder)" /> |
| 11 | + <!--"robocopy" uses 1 as a success exit code, will be considered a failure by Exec task by default.--> |
| 12 | + <!--Set "ContinueOnError" of Exec task to true to continue even if occur error--> |
| 13 | + <Exec ContinueOnError="True" Command="robocopy "$(PublishDir.TrimEnd('\'))" "$(PublishDir)$(DllFolder)" /MOVE /E /NP /XD "$(ProjectDir)$(PublishDir)$(DllFolder)" @(MoveExcludeFolders-> '"$(ProjectDir)$(PublishDir)%(RelativeDir)%(FileName)"', ' ') /XF "$(ProjectDir)$(PublishDir)$(AssemblyName).exe" @(MoveExcludeFiles-> '"$(ProjectDir)$(PublishDir)%(RelativeDir)%(FileName)%(Extension)"', ' ')"> |
| 14 | + <!--Then use Output return ExitCode into ErrorCode--> |
| 15 | + <Output TaskParameter="ExitCode" PropertyName="ErrorCode" /> |
| 16 | + </Exec> |
| 17 | + <!--If ExitCode > 8 then break, "robocopy" exit code greater than 8 indicates failure--> |
| 18 | + <Error Condition="$(ErrorCode) > 8" Message="Failed to move file!" /> |
| 19 | + <!--Call "Patch.cscript" in powershell to modify the entry dll path of .NET Core dll Host exe file--> |
| 20 | + <Exec Command="powershell $source=Get-Content -Path '$(ProjectDir)Properties/Patch.cscript'; Add-Type -TypeDefinition $source[0]; [AppHostPatcher]::Patch('$(PublishDir)$(AssemblyName).exe','$(DllFolder)/$(AssemblyName).dll')" /> |
| 21 | + <!--Explain command:--> |
21 | 22 |
|
22 |
| - <!--$source=Get-Content -Path '$(ProjectDir)Properties/Patch.cscript';--> |
23 |
| - <!-- => Read the contents of the Patch.cscript file and store it in the $source variable ($source is a string array)--> |
| 23 | + <!--$source=Get-Content -Path '$(ProjectDir)Properties/Patch.cscript';--> |
| 24 | + <!-- => Read the contents of the Patch.cscript file and store it in the $source variable ($source is a string array)--> |
24 | 25 |
|
25 |
| - <!--Add-Type -TypeDefinition $source[0];--> |
26 |
| - <!-- => Compile the string in the $source variable as a class definition--> |
| 26 | + <!--Add-Type -TypeDefinition $source[0];--> |
| 27 | + <!-- => Compile the string in the $source variable as a class definition--> |
27 | 28 |
|
28 |
| - <!--[AppHostPatcher]::Patch('$(PublishDir)$(AssemblyName).exe','bin/$(AssemblyName).dll')--> |
29 |
| - <!-- => Call the Patch method in the compiled class AppHostPatcher--> |
30 |
| - <!-- and modify the entry dll path of the host exe '$(PublishDir)$(AssemblyName).exe" to bin/$(AssemblyName).dll--> |
31 |
| - </Target> |
| 29 | + <!--[AppHostPatcher]::Patch('$(PublishDir)$(AssemblyName).exe','$(DllFolder)/$(AssemblyName).dll')--> |
| 30 | + <!-- => Call the Patch method in the compiled class AppHostPatcher--> |
| 31 | + <!-- and modify the entry dll path of the host exe '$(PublishDir)$(AssemblyName).exe" to $(DllFolder)/$(AssemblyName).dll--> |
| 32 | + </Target> |
32 | 33 | </Project>
|
0 commit comments