Skip to content

Commit 7153501

Browse files
authored
Update DllIntoFolder.targets
1 parent 7c361cf commit 7153501

File tree

1 file changed

+27
-26
lines changed

1 file changed

+27
-26
lines changed
Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,33 @@
11
<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>
56

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 &quot;$(PublishDir.TrimEnd('\'))&quot; &quot;$(PublishDir)bin&quot; /MOVE /E /NP /XD &quot;$(ProjectDir)$(PublishDir)bin&quot; @(MoveExcludeFolders-> '&quot;$(ProjectDir)$(PublishDir)%(RelativeDir)%(FileName)&quot;', ' ') /XF &quot;$(ProjectDir)$(PublishDir)$(AssemblyName).exe&quot; @(MoveExcludeFiles-> '&quot;$(ProjectDir)$(PublishDir)%(RelativeDir)%(FileName)%(Extension)&quot;', ' ')">
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) &gt; 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 &quot;$(PublishDir.TrimEnd('\'))&quot; &quot;$(PublishDir)$(DllFolder)&quot; /MOVE /E /NP /XD &quot;$(ProjectDir)$(PublishDir)$(DllFolder)&quot; @(MoveExcludeFolders-> '&quot;$(ProjectDir)$(PublishDir)%(RelativeDir)%(FileName)&quot;', ' ') /XF &quot;$(ProjectDir)$(PublishDir)$(AssemblyName).exe&quot; @(MoveExcludeFiles-> '&quot;$(ProjectDir)$(PublishDir)%(RelativeDir)%(FileName)%(Extension)&quot;', ' ')">
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) &gt; 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:-->
2122

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)-->
2425

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-->
2728

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>
3233
</Project>

0 commit comments

Comments
 (0)