Skip to content

Commit a243edd

Browse files
authored
Add an easy way to enable binlogs in VS (#11375)
1 parent 03741ba commit a243edd

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ msbuild.ProjectImports.zip
3131
# Visual Studio 2015
3232
.vs/
3333

34+
# If MSBUILDDEBUGENGINE=1 and no directory is specified then MSBuild_Logs/ will be the default
35+
MSBuild_Logs/
36+
3437
# Visual Studio 2015 Pre-CTP6
3538
*.sln.ide
3639
*.ide/

startvs.ps1

+19-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,17 @@ Param(
1414
[Parameter(
1515
Mandatory=$false,
1616
HelpMessage="If specified, Roslyn dependencies will be included in the Razor extension when deployed.")]
17-
[Switch]$includeRoslynDeps
17+
[Switch]$includeRoslynDeps,
18+
19+
[Parameter(
20+
Mandatory=$false,
21+
HelpMessage="If specified, bin logs will be enabled for VS. See https://github.com/dotnet/msbuild/blob/main/documentation/wiki/Providing-Binary-Logs.md#capturing-binary-logs-through-visual-studio .")]
22+
[Switch]$captureBinLogs,
23+
24+
[Parameter(
25+
Mandatory=$false,
26+
HelpMessage="If captureBinLogs is specified, this determines the output folder for them. Ignored if captureBinLogs is false.")]
27+
[string]$binLogFolder=$null
1828
)
1929

2030
if ($solutionFile -eq "") {
@@ -39,6 +49,14 @@ $env:DOTNET_MULTILEVEL_LOOKUP = 0
3949
# Put our local dotnet.exe on PATH first so Visual Studio knows which one to use
4050
$env:PATH = $env:DOTNET_ROOT + ";" + $env:PATH
4151

52+
if ($captureBinLogs) {
53+
$env:MSBUILDDEBUGENGINE = 1
54+
55+
if ($binLogFolder -ne $null) {
56+
$env:MSBUILDDEBUGPATH=$binLogFolder
57+
}
58+
}
59+
4260
$vswhere = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe"
4361

4462
if ($chooseVS) {

0 commit comments

Comments
 (0)