Repository navigation
Expand file tree
/
Copy pathDeployToGame.targets
More file actions
55 lines (50 loc) · 4.41 KB
/
Copy pathDeployToGame.targets
File metadata and controls
55 lines (50 loc) · 4.41 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
55
<?xml version="1.0" encoding="utf-8"?>
<!--
Deploys a project's outputs into the Rocksmith folder after EVERY build, so the game DLL, the proxy
driver and the GUI can never drift out of sync with each other (what is built is what runs). Each project lists what it ships as @(GameDeployFile) items with a Destination.
Each file is overwritten in place. Only when a running game or bridge holds it (it cannot be overwritten,
but Windows allows a mapped executable to be renamed) is the live copy parked as "<file>.previous" and the
fresh build put in its place; the running process keeps using the parked copy until it restarts, and the
next deploy that can overwrite removes the .previous. Nothing is killed here.
Skip with -p:DeployToGame=false. Point elsewhere with -p:RocksmithInstallDir=... . Never runs for the
"Master" configuration (that is the installer payload, not a dev deploy).
Only the checkout named in <game>\RSModsDeployOwner.txt deploys (Directory.Build.props sets
DeployToGame=false for any other). -p:ClaimGameDeploy=true makes this checkout the owner.
-->
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<RocksmithInstallDir Condition="'$(RocksmithInstallDir)'==''">C:\Program Files (x86)\Steam\steamapps\common\Rocksmith2014</RocksmithInstallDir>
<DeployToGame Condition="'$(DeployToGame)'==''">true</DeployToGame>
</PropertyGroup>
<Target Name="DeployOwnerSkipped" AfterTargets="Build" Condition="'$(RSModsDeployBlocked)'=='true'">
<Warning Text="DeployToGame SKIPPED for $(MSBuildProjectName): the game folder belongs to $(RSModsDeployOwner) (RSModsDeployOwner.txt); this checkout is $(RSModsThisCheckout). Build with -p:ClaimGameDeploy=true to take it over, or delete the file." />
</Target>
<Target Name="DeployToGame" AfterTargets="Build"
Condition="'$(DeployToGame)'=='true' And Exists('$(RocksmithInstallDir)') And '$(Configuration)'!='Master'">
<WriteLinesToFile Condition="'$(ClaimGameDeploy)'=='true'" File="$(RocksmithInstallDir)\RSModsDeployOwner.txt"
Lines="$(RSModsThisCheckout)" Overwrite="true" />
<Error Condition="'@(GameDeployFile)'==''" Text="DeployToGame: this project declares no GameDeployFile items." />
<Error Condition="!Exists('%(GameDeployFile.Identity)')" Text="DeployToGame: build output is missing: %(GameDeployFile.Identity)" />
<!-- Overwrite in place first, so no backup is left in the game folder when nothing holds the file. A copy
keeps the build's timestamp, so a destination that still differs afterwards was locked. -->
<Copy SourceFiles="%(GameDeployFile.Identity)" DestinationFiles="%(GameDeployFile.Destination)" Retries="0" ContinueOnError="true" />
<ItemGroup>
<_DeployLocked Include="@(GameDeployFile)"
Condition="!Exists('%(GameDeployFile.Destination)') Or '$([System.IO.File]::GetLastWriteTime(%(GameDeployFile.Destination)).Ticks)' != '$([System.IO.File]::GetLastWriteTime(%(GameDeployFile.Identity)).Ticks)'" />
</ItemGroup>
<!-- Overwritten: a .previous left by an earlier locked deploy is no longer needed. -->
<ItemGroup>
<_DeployOverwritten Include="@(GameDeployFile)" Exclude="@(_DeployLocked)" />
</ItemGroup>
<Delete Files="%(_DeployOverwritten.Destination).previous" Condition="'@(_DeployOverwritten)'!=''" ContinueOnError="true" />
<!-- Locked by the running game or bridge: Windows allows a mapped file to be renamed, so the live copy is
parked as "<file>.previous" (the running process keeps using it until it restarts) and the build put in
its place. -->
<Delete Files="%(_DeployLocked.Destination).previous" Condition="'@(_DeployLocked)'!=''" ContinueOnError="true" />
<Move SourceFiles="%(_DeployLocked.Destination)" DestinationFiles="%(_DeployLocked.Destination).previous"
Condition="'@(_DeployLocked)'!='' And Exists('%(_DeployLocked.Destination)')" ContinueOnError="true" />
<Copy SourceFiles="%(_DeployLocked.Identity)" DestinationFiles="%(_DeployLocked.Destination)" Condition="'@(_DeployLocked)'!=''" />
<Message Importance="high" Text="DeployToGame: %(GameDeployFile.Filename)%(GameDeployFile.Extension) -> %(GameDeployFile.Destination)" />
<Message Importance="high" Condition="'@(_DeployLocked)'!=''" Text="DeployToGame: %(_DeployLocked.Filename)%(_DeployLocked.Extension) was in use: the running copy is parked as .previous until it restarts" />
</Target>
</Project>