-
Notifications
You must be signed in to change notification settings - Fork 464
Expand file tree
/
Copy pathBuild.bat
More file actions
122 lines (109 loc) · 4.16 KB
/
Build.bat
File metadata and controls
122 lines (109 loc) · 4.16 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
@ECHO OFF
CALL "%~dp0\InitializeEnvironment.bat" || EXIT /b 10
SETLOCAL
SETLOCAL EnableDelayedExpansion
IF "%~1"=="" (
SET CONFIGURATION=Debug
) ELSE (
SET CONFIGURATION=%1
)
IF "%~2"=="" (
SET GVFSVERSION=0.2.173.2
) ELSE (
SET GVFSVERSION=%2
)
IF "%~3"=="" (
SET VERBOSITY=minimal
) ELSE (
SET VERBOSITY=%3
)
REM .NET 10 SDK ships MSBuild 18.x; VS 2022 ships MSBuild 17.x.
REM Managed (csproj) projects require MSBuild 18.x via "dotnet build".
REM Native C++ (vcxproj) projects require VS MSBuild with VC++ targets.
ECHO ^**********************
ECHO ^* Restoring Packages *
ECHO ^**********************
dotnet restore "%VFS_SRCDIR%\GVFS.sln" ^
/v:%VERBOSITY% ^
/p:Configuration=%CONFIGURATION% || GOTO ERROR
ECHO ^**************************
ECHO ^* Building C++ Projects *
ECHO ^**************************
REM Locate VS MSBuild for native C++ projects
SET MSBUILD_EXEC=
FOR /F "tokens=* USEBACKQ" %%F IN (`where msbuild.exe 2^>nul`) DO (
SET MSBUILD_EXEC=%%F
ECHO INFO: Found msbuild.exe at '%%F'
GOTO :FOUND_MSBUILD
)
:LOCATE_MSBUILD
SET VSWHERE_EXEC="%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe"
IF EXIST %VSWHERE_EXEC% (
FOR /F "tokens=* USEBACKQ" %%F IN (`%VSWHERE_EXEC% -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -find MSBuild\**\Bin\amd64\MSBuild.exe`) DO (
SET MSBUILD_EXEC=%%F
ECHO INFO: Found msbuild.exe at '%%F'
)
)
:FOUND_MSBUILD
IF DEFINED MSBUILD_EXEC (
FOR %%P IN (
"%VFS_SRCDIR%\GVFS\GitHooksLoader\GitHooksLoader.vcxproj"
"%VFS_SRCDIR%\GVFS\GVFS.NativeTests\GVFS.NativeTests.vcxproj"
"%VFS_SRCDIR%\GVFS\GVFS.PostIndexChangedHook\GVFS.PostIndexChangedHook.vcxproj"
"%VFS_SRCDIR%\GVFS\GVFS.ReadObjectHook\GVFS.ReadObjectHook.vcxproj"
"%VFS_SRCDIR%\GVFS\GVFS.VirtualFileSystemHook\GVFS.VirtualFileSystemHook.vcxproj"
) DO (
ECHO Building %%~nP...
"%MSBUILD_EXEC%" %%P ^
/t:Build ^
/v:%VERBOSITY% ^
/p:Configuration=%CONFIGURATION% ^
/p:Platform=x64 ^
/p:SolutionDir="%VFS_SRCDIR%\\" || GOTO ERROR
)
) ELSE (
ECHO WARNING: Could not find VS MSBuild. Native C++ projects will not be built.
ECHO Install Visual Studio with the C++ workload to build native projects.
)
ECHO ^*****************************
ECHO ^* Building Managed Projects *
ECHO ^*****************************
REM Self-contained deployment requires "dotnet publish" (not "dotnet build")
REM to produce complete output with runtime and correct version resources.
FOR %%P IN (
"%VFS_SRCDIR%\GVFS\GVFS\GVFS.csproj"
"%VFS_SRCDIR%\GVFS\GVFS.Mount\GVFS.Mount.csproj"
"%VFS_SRCDIR%\GVFS\GVFS.Hooks\GVFS.Hooks.csproj"
"%VFS_SRCDIR%\GVFS\GVFS.Service\GVFS.Service.csproj"
"%VFS_SRCDIR%\GVFS\FastFetch\FastFetch.csproj"
"%VFS_SRCDIR%\GVFS\GVFS.UnitTests\GVFS.UnitTests.csproj"
"%VFS_SRCDIR%\GVFS\GVFS.FunctionalTests\GVFS.FunctionalTests.csproj"
"%VFS_SRCDIR%\GVFS\GVFS.PerfProfiling\GVFS.PerfProfiling.csproj"
) DO (
ECHO Publishing %%~nP...
dotnet publish %%P --no-restore -v:%VERBOSITY% -c %CONFIGURATION% || GOTO ERROR
)
ECHO ^*******************************
ECHO ^* Building Packaging Projects *
ECHO ^*******************************
REM Payload and Installers no longer reference vcxproj (native projects are
REM built separately above). Build ordering is handled by Build.bat.
FOR %%P IN (
"%VFS_SRCDIR%\GVFS\GVFS.Payload\GVFS.Payload.csproj"
"%VFS_SRCDIR%\GVFS\GVFS.Installers\GVFS.Installers.csproj"
) DO (
ECHO Publishing %%~nP...
dotnet publish %%P --no-restore -v:%VERBOSITY% -c %CONFIGURATION% || GOTO ERROR
)
GOTO :EOF
:USAGE
ECHO usage: %~n0%~x0 [^<configuration^>] [^<version^>] [^<verbosity^>]
ECHO.
ECHO configuration Solution configuration (default: Debug).
ECHO version GVFS version (default: 0.2.173.2).
ECHO verbosity MSBuild verbosity (default: minimal).
ECHO.
EXIT 1
:ERROR
ECHO ERROR: Build failed with exit code %ERRORLEVEL%
EXIT /B %ERRORLEVEL%