forked from microsoft/VFSForGit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDirectory.Build.targets
More file actions
145 lines (127 loc) · 9 KB
/
Directory.Build.targets
File metadata and controls
145 lines (127 loc) · 9 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
<Project>
<!-- Define common properties that rely on SDK/props-defined properties -->
<PropertyGroup>
<Version>$(GVFSVersion)</Version>
<!--
We parse this version into System.Version in several places;
we should strip the commit ID from the attribute.
-->
<IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>
</PropertyGroup>
<!-- Include custom MSBuild targets/tasks -->
<Import Project="$(MSBuildThisFileDirectory)GVFS\GVFS.MSBuild\GVFS.targets" />
<!--
Auto-restore vcpkg native dependencies when missing.
Modeled after vcpkg's official VcpkgInstallManifestDependencies target
(scripts/buildsystems/msbuild/vcpkg.targets), adapted for .csproj projects
and dual-triplet installs (static-aot + dynamic).
Key differences from official vcpkg.targets:
- Hooks PrepareForBuild instead of ClCompile (which doesn't exist in csproj)
- Installs two triplets (static for AOT linking, dynamic for runtime P/Invoke)
- Outputs to out/vcpkg_installed/ instead of src/vcpkg_installed/
- Discovers vcpkg via VCPKG_INSTALLATION_ROOT, VS-bundled path, or PATH
Stamp file pattern: the target uses Inputs/Outputs so MSBuild skips it entirely
when the manifests haven't changed and the stamp file is up-to-date.
Build.bat also runs vcpkg install upfront, making this a no-op for CLI builds.
-->
<PropertyGroup Condition="'$(MSBuildProjectExtension)' == '.csproj'">
<_VcpkgManifestFile>$(RepoSrcPath)vcpkg.json</_VcpkgManifestFile>
<_VcpkgConfigFile>$(RepoSrcPath)vcpkg-configuration.json</_VcpkgConfigFile>
<_VcpkgStampFile>$(RepoOutPath)vcpkg_installed\.msbuildstamp</_VcpkgStampFile>
<!--
Terrapin asset caching for vcpkg downloads (only when explicitly
enabled by the release pipeline). -a $(IsLocalBuild) controls whether
the retrieval script may upload missing assets back to the Terrapin
cache: true on dev boxes (write permission available), false on CI
agents (read-only; x-block-origin causes immediate failure rather
than attempting public-internet downloads).
$(TerrapinRetrievalToolPath) is supplied by the release pipeline
after it downloads the internal Microsoft.Build.Vcpkg NuGet package
that ships the retrieval tool. The repo intentionally does not
reference that internal package directly; the pipeline is the only
bridge between this repo and the internal feed.
-->
<_VcpkgAssetSources Condition="'$(UseTerrapinAssetCache)' == 'true'">"--x-asset-sources=x-script,$(TerrapinRetrievalToolPath) -b https://vcpkg.storage.devpackages.microsoft.io/artifacts/ -a $(IsLocalBuild) -p {url} -s {sha512} -d {dst};x-block-origin"</_VcpkgAssetSources>
</PropertyGroup>
<ItemGroup Condition="'$(MSBuildProjectExtension)' == '.csproj'">
<_VcpkgManifestInputs Include="$(_VcpkgManifestFile)" />
<_VcpkgManifestInputs Include="$(_VcpkgConfigFile)" Condition="Exists('$(_VcpkgConfigFile)')" />
</ItemGroup>
<Target Name="_RestoreVcpkgDependencies"
BeforeTargets="PrepareForBuild;ComputeFilesToPublish"
Condition="'$(MSBuildProjectName)' == 'GVFS.Common'"
Inputs="@(_VcpkgManifestInputs)"
Outputs="$(_VcpkgStampFile)">
<!-- Locate vcpkg: VCPKG_INSTALLATION_ROOT > VS-bundled > PATH -->
<PropertyGroup>
<_VcpkgExe Condition="Exists('$(VCPKG_INSTALLATION_ROOT)\vcpkg.exe')">$(VCPKG_INSTALLATION_ROOT)\vcpkg.exe</_VcpkgExe>
<_VcpkgExe Condition="'$(_VcpkgExe)' == '' and Exists('$(VsInstallRoot)\VC\vcpkg\vcpkg.exe')">$(VsInstallRoot)\VC\vcpkg\vcpkg.exe</_VcpkgExe>
<_VcpkgManifestArg>--x-manifest-root="$(RepoSrcPath.TrimEnd('\'))"</_VcpkgManifestArg>
</PropertyGroup>
<!-- For dotnet build (no VsInstallRoot): find VS-bundled vcpkg via vswhere -->
<Exec Command=""$(MSBuildProgramFiles32)\Microsoft Visual Studio\Installer\vswhere.exe" -latest -products * -property installationPath"
ConsoleToMSBuild="true" IgnoreExitCode="true" StandardOutputImportance="low"
Condition="'$(_VcpkgExe)' == ''">
<Output TaskParameter="ConsoleOutput" PropertyName="_VsInstallPath" />
</Exec>
<PropertyGroup Condition="'$(_VcpkgExe)' == '' and '$(_VsInstallPath)' != '' and Exists('$(_VsInstallPath)\VC\vcpkg\vcpkg.exe')">
<_VcpkgExe>$(_VsInstallPath)\VC\vcpkg\vcpkg.exe</_VcpkgExe>
</PropertyGroup>
<!-- Final fallback: bare vcpkg on PATH -->
<PropertyGroup Condition="'$(_VcpkgExe)' == ''">
<_VcpkgExe>vcpkg</_VcpkgExe>
</PropertyGroup>
<Message Importance="high" Text="[vcpkg] Installing native dependencies to $(RepoOutPath)vcpkg_installed\" />
<MakeDir Directories="$(RepoOutPath)vcpkg_installed\" />
<!--
Guard: if asset caching was requested but the tool path was not
supplied, the asset-source string would be malformed and vcpkg
would fail with a confusing error. Surface the misconfiguration up
front.
-->
<Error Condition="'$(UseTerrapinAssetCache)' == 'true' and ('$(TerrapinRetrievalToolPath)' == '' or !Exists('$(TerrapinRetrievalToolPath)'))"
Text="UseTerrapinAssetCache=true but TerrapinRetrievalToolPath is empty or does not exist. The release pipeline must pre-download the Microsoft.Build.Vcpkg NuGet package and pass -p:TerrapinRetrievalToolPath=<path-to-TerrapinRetrievalTool.exe>." />
<Exec Command=""$(_VcpkgExe)" install --x-wait-for-lock --triplet x64-windows-static-aot --x-install-root="$(RepoOutPath)vcpkg_installed\static" $(_VcpkgManifestArg) $(_VcpkgAssetSources)"
StandardOutputImportance="High" StandardErrorImportance="High" />
<Exec Command=""$(_VcpkgExe)" install --x-wait-for-lock --triplet x64-windows-dynamic --x-install-root="$(RepoOutPath)vcpkg_installed\dynamic" $(_VcpkgManifestArg) $(_VcpkgAssetSources)"
StandardOutputImportance="High" StandardErrorImportance="High" />
<Error Condition="!Exists('$(RepoOutPath)vcpkg_installed\dynamic\x64-windows-dynamic\bin\git2.dll')"
Text="vcpkg install completed but git2.dll (dynamic) is missing. Check vcpkg output above for errors." />
<Error Condition="!Exists('$(RepoOutPath)vcpkg_installed\static\x64-windows-static-aot\lib\git2.lib')"
Text="vcpkg install completed but git2.lib (static) is missing. Check vcpkg output above for errors." />
<Touch Files="$(_VcpkgStampFile)" AlwaysCreate="true" />
</Target>
<!--
Copy native C++ hook executables and managed peer executables to GVFS.exe
output directory. In a production install all binaries are co-located in one
directory. During dev builds each project has its own output; this target
replicates the production layout for the GVFS project.
-->
<Target Name="_CopyNativeHooks" AfterTargets="Build" Condition="'$(MSBuildProjectName)' == 'GVFS'">
<PropertyGroup>
<_ManagedOutFragment>bin\$(Configuration)\$(TargetFramework)\win-x64</_ManagedOutFragment>
</PropertyGroup>
<ItemGroup>
<!-- Native C++ hooks (built separately with VS MSBuild) -->
<_NativeHook Include="$(RepoOutPath)GitHooksLoader\bin\x64\$(Configuration)\GitHooksLoader.exe" />
<_NativeHook Include="$(RepoOutPath)GVFS.ReadObjectHook\bin\x64\$(Configuration)\GVFS.ReadObjectHook.exe" />
<_NativeHook Include="$(RepoOutPath)GVFS.PostIndexChangedHook\bin\x64\$(Configuration)\GVFS.PostIndexChangedHook.exe" />
<_NativeHook Include="$(RepoOutPath)GVFS.VirtualFileSystemHook\bin\x64\$(Configuration)\GVFS.VirtualFileSystemHook.exe" />
<!-- Managed peer executables that must be co-located with GVFS.exe -->
<_PeerExe Include="$(RepoOutPath)GVFS.Mount\$(_ManagedOutFragment)\GVFS.Mount.exe" />
<_PeerExe Include="$(RepoOutPath)GVFS.Mount\$(_ManagedOutFragment)\GVFS.Mount.dll" />
<_PeerExe Include="$(RepoOutPath)GVFS.Mount\$(_ManagedOutFragment)\GVFS.Mount.runtimeconfig.json" />
<_PeerExe Include="$(RepoOutPath)GVFS.Mount\$(_ManagedOutFragment)\GVFS.Mount.deps.json" />
<_PeerExe Include="$(RepoOutPath)GVFS.Hooks\$(_ManagedOutFragment)\GVFS.Hooks.exe" />
<_PeerExe Include="$(RepoOutPath)GVFS.Hooks\$(_ManagedOutFragment)\GVFS.Hooks.dll" />
<_PeerExe Include="$(RepoOutPath)GVFS.Hooks\$(_ManagedOutFragment)\GVFS.Hooks.runtimeconfig.json" />
<_PeerExe Include="$(RepoOutPath)GVFS.Hooks\$(_ManagedOutFragment)\GVFS.Hooks.deps.json" />
<_PeerExe Include="$(RepoOutPath)GVFS.Service\$(_ManagedOutFragment)\GVFS.Service.exe" />
<_PeerExe Include="$(RepoOutPath)GVFS.Service\$(_ManagedOutFragment)\GVFS.Service.dll" />
<_PeerExe Include="$(RepoOutPath)GVFS.Service\$(_ManagedOutFragment)\GVFS.Service.runtimeconfig.json" />
<_PeerExe Include="$(RepoOutPath)GVFS.Service\$(_ManagedOutFragment)\GVFS.Service.deps.json" />
</ItemGroup>
<Copy SourceFiles="@(_NativeHook)" DestinationFolder="$(OutputPath)" SkipUnchangedFiles="true" Condition="Exists('%(FullPath)')" />
<Copy SourceFiles="@(_PeerExe)" DestinationFolder="$(OutputPath)" SkipUnchangedFiles="true" Condition="Exists('%(FullPath)')" />
</Target>
</Project>