diff --git a/Tasks/Common/MSBuildHelpers/InvokeFunctions.ps1 b/Tasks/Common/MSBuildHelpers/InvokeFunctions.ps1 index 2d3a57e33edc..36d7ce486bd5 100644 --- a/Tasks/Common/MSBuildHelpers/InvokeFunctions.ps1 +++ b/Tasks/Common/MSBuildHelpers/InvokeFunctions.ps1 @@ -11,7 +11,8 @@ function Invoke-BuildTools { [switch]$Clean, [switch]$NoTimelineLogger, [switch]$CreateLogFile, - [string]$LogFileVerbosity) + [string]$LogFileVerbosity, + [switch]$IsDefaultLoggerEnabled = $true) Trace-VstsEnteringInvocation $MyInvocation try { @@ -30,7 +31,7 @@ function Invoke-BuildTools { if ($CreateLogFile) { $splat["LogFile"] = "$file-clean.log" } - Invoke-MSBuild -ProjectFile $file -Targets Clean -MSBuildPath $MSBuildLocation -AdditionalArguments $MSBuildArguments -NoTimelineLogger:$NoTimelineLogger @splat + Invoke-MSBuild -ProjectFile $file -Targets Clean -MSBuildPath $MSBuildLocation -AdditionalArguments $MSBuildArguments -NoTimelineLogger:$NoTimelineLogger -IsDefaultLoggerEnabled:$IsDefaultLoggerEnabled @splat } # If we cleaned and passed /t targets, we don't need to run them again @@ -38,7 +39,7 @@ function Invoke-BuildTools { if ($CreateLogFile) { $splat["LogFile"] = "$file.log" } - Invoke-MSBuild -ProjectFile $file -MSBuildPath $MSBuildLocation -AdditionalArguments $MSBuildArguments -NoTimelineLogger:$NoTimelineLogger @splat + Invoke-MSBuild -ProjectFile $file -MSBuildPath $MSBuildLocation -AdditionalArguments $MSBuildArguments -NoTimelineLogger:$NoTimelineLogger -IsDefaultLoggerEnabled:$IsDefaultLoggerEnabled @splat } } } finally { @@ -59,7 +60,8 @@ function Invoke-MSBuild { [string]$LogFileVerbosity, [switch]$NoTimelineLogger, [string]$MSBuildPath, # TODO: Switch MSBuildPath to mandatory. Both callers (MSBuild and VSBuild task) throw prior to reaching here if MSBuild cannot be resolved. - [string]$AdditionalArguments) + [string]$AdditionalArguments, + [switch]$IsDefaultLoggerEnabled = $true) Trace-VstsEnteringInvocation $MyInvocation try { @@ -102,10 +104,12 @@ function Invoke-MSBuild { # Store the solution folder so we can provide solution-relative paths (for now) for the project events. $solutionDirectory = [System.IO.Path]::GetDirectoryName($ProjectFile) - # Hook up the custom logger. - $loggerAssembly = "$PSScriptRoot\Microsoft.TeamFoundation.DistributedTask.MSBuild.Logger.dll" - Assert-VstsPath -LiteralPath $loggerAssembly -PathType Leaf - $arguments = "$arguments /dl:CentralLogger,`"$loggerAssembly`";`"RootDetailId=$($detailId)|SolutionDir=$($solutionDirectory)`"*ForwardingLogger,`"$loggerAssembly`"" + if($IsDefaultLoggerEnabled) { + # Hook up the custom logger. + $loggerAssembly = "$PSScriptRoot\Microsoft.TeamFoundation.DistributedTask.MSBuild.Logger.dll" + Assert-VstsPath -LiteralPath $loggerAssembly -PathType Leaf + $arguments = "$arguments /dl:CentralLogger,`"$loggerAssembly`";`"RootDetailId=$($detailId)|SolutionDir=$($solutionDirectory)`"*ForwardingLogger,`"$loggerAssembly`"" + } # Append additional arguments. if ($AdditionalArguments) { diff --git a/Tasks/Common/MSBuildHelpers/Tests/Invoke-BuildTools.DefaultLoggerEnabledByDefault.ps1 b/Tasks/Common/MSBuildHelpers/Tests/Invoke-BuildTools.DefaultLoggerEnabledByDefault.ps1 new file mode 100644 index 000000000000..9ec12804ca2d --- /dev/null +++ b/Tasks/Common/MSBuildHelpers/Tests/Invoke-BuildTools.DefaultLoggerEnabledByDefault.ps1 @@ -0,0 +1,23 @@ +[CmdletBinding()] +param() + +# Arrange. +. $PSScriptRoot\..\..\..\..\Tests\lib\Initialize-Test.ps1 +Microsoft.PowerShell.Core\Import-Module $PSScriptRoot\.. +$directory = 'Some drive:\Some directory' +$file = "$directory\Some solution" +$msBuildLocation = 'Some MSBuild location' +$msBuildArguments = 'Some MSBuild arguments' + +Register-Mock Invoke-NuGetRestore { 'NuGet output' } -- -File $file +Register-Mock Invoke-MSBuild { 'MSBuild disabled logger output' } -- -ProjectFile $file -MSBuildPath $msBuildLocation -AdditionalArguments $msBuildArguments -NoTimelineLogger: $true -IsDefaultLoggerEnabled:$true -LogFile: "$file.log" + +# Act. +$actual = Invoke-BuildTools -NuGetRestore -SolutionFiles $file -MSBuildLocation $msBuildLocation -MSBuildArguments $msBuildArguments -NoTimelineLogger -CreateLogFile +# Assert. +Assert-AreEqual -Expected @( + 'NuGet output' + 'MSBuild disabled logger output' + ) -Actual $actual + + diff --git a/Tasks/Common/MSBuildHelpers/Tests/Invoke-BuildTools.DisableDefaultLogger.ps1 b/Tasks/Common/MSBuildHelpers/Tests/Invoke-BuildTools.DisableDefaultLogger.ps1 new file mode 100644 index 000000000000..dd2d3c45ef98 --- /dev/null +++ b/Tasks/Common/MSBuildHelpers/Tests/Invoke-BuildTools.DisableDefaultLogger.ps1 @@ -0,0 +1,23 @@ +[CmdletBinding()] +param() + +# Arrange. +. $PSScriptRoot\..\..\..\..\Tests\lib\Initialize-Test.ps1 +Microsoft.PowerShell.Core\Import-Module $PSScriptRoot\.. +$directory = 'Some drive:\Some directory' +$file = "$directory\Some solution" +$msBuildLocation = 'Some MSBuild location' +$msBuildArguments = 'Some MSBuild arguments' + +Register-Mock Invoke-NuGetRestore { 'NuGet output' } -- -File $file +Register-Mock Invoke-MSBuild { 'MSBuild disabled logger output' } -- -ProjectFile $file -MSBuildPath $msBuildLocation -AdditionalArguments $msBuildArguments -NoTimelineLogger: $true -IsDefaultLoggerEnabled:$false -LogFile: "$file.log" + +# Act. +$actual = Invoke-BuildTools -NuGetRestore -SolutionFiles $file -MSBuildLocation $msBuildLocation -MSBuildArguments $msBuildArguments -NoTimelineLogger -CreateLogFile -IsDefaultLoggerEnabled:$false +# Assert. +Assert-AreEqual -Expected @( + 'NuGet output' + 'MSBuild disabled logger output' + ) -Actual $actual + + diff --git a/Tasks/Common/MSBuildHelpers/Tests/Invoke-BuildTools.InvokesAllToolsForAllFiles.ps1 b/Tasks/Common/MSBuildHelpers/Tests/Invoke-BuildTools.InvokesAllToolsForAllFiles.ps1 index 55d2bfc1d335..713e58e8f819 100644 --- a/Tasks/Common/MSBuildHelpers/Tests/Invoke-BuildTools.InvokesAllToolsForAllFiles.ps1 +++ b/Tasks/Common/MSBuildHelpers/Tests/Invoke-BuildTools.InvokesAllToolsForAllFiles.ps1 @@ -12,12 +12,12 @@ $msBuildLocation = 'Some MSBuild location' $msBuildArguments = 'Some MSBuild arguments' Register-Mock Invoke-NuGetRestore { 'NuGet output 1' } -- -File $file1 Register-Mock Invoke-NuGetRestore { 'NuGet output 2' } -- -File $file2 -Register-Mock Invoke-MSBuild { 'MSBuild output 1' } -- -ProjectFile $file1 -MSBuildPath $msBuildLocation -AdditionalArguments $msBuildArguments -NoTimelineLogger: $true -LogFile: "$file1.log" -Register-Mock Invoke-MSBuild { 'MSBuild output 2' } -- -ProjectFile $file2 -MSBuildPath $msBuildLocation -AdditionalArguments $msBuildArguments -NoTimelineLogger: $true -LogFile: "$file2.log" -Register-Mock Invoke-MSBuild { 'MSBuild clean output 1' } -- -ProjectFile $file1 -Targets Clean -MSBuildPath $msBuildLocation -AdditionalArguments $msBuildArguments -NoTimelineLogger: $true -LogFile: "$file1-clean.log" -Register-Mock Invoke-MSBuild { 'MSBuild clean output 2' } -- -ProjectFile $file2 -Targets Clean -MSBuildPath $msBuildLocation -AdditionalArguments $msBuildArguments -NoTimelineLogger: $true -LogFile: "$file2-clean.log" -Register-Mock Invoke-MSBuild { 'MSBuild clean output 1 wrong logfile' } -- -ProjectFile $file1 -Targets Clean -MSBuildPath $msBuildLocation -AdditionalArguments $msBuildArguments -NoTimelineLogger: $true -LogFile: "$file1.log" -Register-Mock Invoke-MSBuild { 'MSBuild clean output 2 wrong logfile' } -- -ProjectFile $file2 -Targets Clean -MSBuildPath $msBuildLocation -AdditionalArguments $msBuildArguments -NoTimelineLogger: $true -LogFile: "$file2.log" +Register-Mock Invoke-MSBuild { 'MSBuild output 1' } -- -ProjectFile $file1 -MSBuildPath $msBuildLocation -AdditionalArguments $msBuildArguments -NoTimelineLogger: $true -IsDefaultLoggerEnabled: $true -LogFile: "$file1.log" +Register-Mock Invoke-MSBuild { 'MSBuild output 2' } -- -ProjectFile $file2 -MSBuildPath $msBuildLocation -AdditionalArguments $msBuildArguments -NoTimelineLogger: $true -IsDefaultLoggerEnabled: $true -LogFile: "$file2.log" +Register-Mock Invoke-MSBuild { 'MSBuild clean output 1' } -- -ProjectFile $file1 -Targets Clean -MSBuildPath $msBuildLocation -AdditionalArguments $msBuildArguments -NoTimelineLogger: $true -IsDefaultLoggerEnabled: $true -LogFile: "$file1-clean.log" +Register-Mock Invoke-MSBuild { 'MSBuild clean output 2' } -- -ProjectFile $file2 -Targets Clean -MSBuildPath $msBuildLocation -AdditionalArguments $msBuildArguments -NoTimelineLogger: $true -IsDefaultLoggerEnabled: $true -LogFile: "$file2-clean.log" +Register-Mock Invoke-MSBuild { 'MSBuild clean output 1 wrong logfile' } -- -ProjectFile $file1 -Targets Clean -MSBuildPath $msBuildLocation -AdditionalArguments $msBuildArguments -NoTimelineLogger: $true -IsDefaultLoggerEnabled: $true -LogFile: "$file1.log" +Register-Mock Invoke-MSBuild { 'MSBuild clean output 2 wrong logfile' } -- -ProjectFile $file2 -Targets Clean -MSBuildPath $msBuildLocation -AdditionalArguments $msBuildArguments -NoTimelineLogger: $true -IsDefaultLoggerEnabled: $true -LogFile: "$file2.log" # Act. $actual = Invoke-BuildTools -NuGetRestore -SolutionFiles $file1, $file2 -MSBuildLocation $msBuildLocation -MSBuildArguments $msBuildArguments -Clean -NoTimelineLogger -CreateLogFile diff --git a/Tasks/Common/MSBuildHelpers/Tests/Invoke-BuildTools.SkipsCleanIfSpecified.ps1 b/Tasks/Common/MSBuildHelpers/Tests/Invoke-BuildTools.SkipsCleanIfSpecified.ps1 index 2c8d8e3beb37..c7370c12face 100644 --- a/Tasks/Common/MSBuildHelpers/Tests/Invoke-BuildTools.SkipsCleanIfSpecified.ps1 +++ b/Tasks/Common/MSBuildHelpers/Tests/Invoke-BuildTools.SkipsCleanIfSpecified.ps1 @@ -8,9 +8,8 @@ $file = "$directory1\Some solution" $msBuildLocation = 'Some MSBuild location' $msBuildArguments = 'Some MSBuild arguments' Register-Mock Invoke-NuGetRestore { 'NuGet output' } -- -File $file -Register-Mock Invoke-MSBuild { 'MSBuild output' } -- -ProjectFile $file -MSBuildPath $msBuildLocation -AdditionalArguments $msBuildArguments -NoTimelineLogger: $true -LogFile: "$file.log" -Register-Mock Invoke-MSBuild { 'MSBuild clean output' } -- -ProjectFile $file -Targets Clean -MSBuildPath $msBuildLocation -AdditionalArguments $msBuildArguments -NoTimelineLogger: $true -LogFile: "$file.log" - +Register-Mock Invoke-MSBuild { 'MSBuild output' } -- -ProjectFile $file -MSBuildPath $msBuildLocation -AdditionalArguments $msBuildArguments -NoTimelineLogger: $true -IsDefaultLoggerEnabled:$true -LogFile: "$file.log" +Register-Mock Invoke-MSBuild { 'MSBuild clean output' } -- -ProjectFile $file -Targets Clean -MSBuildPath $msBuildLocation -AdditionalArguments $msBuildArguments -NoTimelineLogger: $true -IsDefaultLoggerEnabled:$true -LogFile: "$file.log" # Act. $actual = Invoke-BuildTools -NuGetRestore -SolutionFiles $file -MSBuildLocation $msBuildLocation -MSBuildArguments $msBuildArguments -NoTimelineLogger -CreateLogFile diff --git a/Tasks/Common/MSBuildHelpers/Tests/Invoke-BuildTools.SkipsCreateLogFileIfSpecified.ps1 b/Tasks/Common/MSBuildHelpers/Tests/Invoke-BuildTools.SkipsCreateLogFileIfSpecified.ps1 index 9bd105227d58..e7560003091e 100644 --- a/Tasks/Common/MSBuildHelpers/Tests/Invoke-BuildTools.SkipsCreateLogFileIfSpecified.ps1 +++ b/Tasks/Common/MSBuildHelpers/Tests/Invoke-BuildTools.SkipsCreateLogFileIfSpecified.ps1 @@ -8,10 +8,10 @@ $file = "$directory1\Some solution" $msBuildLocation = 'Some MSBuild location' $msBuildArguments = 'Some MSBuild arguments' Register-Mock Invoke-NuGetRestore { 'NuGet output' } -- -File $file -Register-Mock Invoke-MSBuild { 'MSBuild clean output' } -- -ProjectFile $file -Targets Clean -MSBuildPath $msBuildLocation -AdditionalArguments $msBuildArguments -NoTimelineLogger: $true -LogFile: "$file.log" -Register-Mock Invoke-MSBuild { 'MSBuild clean output no log' } -- -ProjectFile $file -Targets Clean -MSBuildPath $msBuildLocation -AdditionalArguments $msBuildArguments -NoTimelineLogger: $true -Register-Mock Invoke-MSBuild { 'MSBuild output no log' } -- -ProjectFile $file -MSBuildPath $msBuildLocation -AdditionalArguments $msBuildArguments -NoTimelineLogger: $true -Register-Mock Invoke-MSBuild { 'MSBuild output' } -- -ProjectFile $file -MSBuildPath $msBuildLocation -AdditionalArguments $msBuildArguments -NoTimelineLogger: $true -LogFile: "$file.log" +Register-Mock Invoke-MSBuild { 'MSBuild clean output' } -- -ProjectFile $file -Targets Clean -MSBuildPath $msBuildLocation -AdditionalArguments $msBuildArguments -NoTimelineLogger: $true -LogFile: "$file.log" -IsDefaultLoggerEnabled: $true +Register-Mock Invoke-MSBuild { 'MSBuild clean output no log' } -- -ProjectFile $file -Targets Clean -MSBuildPath $msBuildLocation -AdditionalArguments $msBuildArguments -NoTimelineLogger: $true -IsDefaultLoggerEnabled: $true +Register-Mock Invoke-MSBuild { 'MSBuild output no log' } -- -ProjectFile $file -MSBuildPath $msBuildLocation -AdditionalArguments $msBuildArguments -NoTimelineLogger: $true -IsDefaultLoggerEnabled:$true +Register-Mock Invoke-MSBuild { 'MSBuild output' } -- -ProjectFile $file -MSBuildPath $msBuildLocation -AdditionalArguments $msBuildArguments -NoTimelineLogger: $true -LogFile: "$file.log" -IsDefaultLoggerEnabled: $true # Act. $actual = Invoke-BuildTools -NuGetRestore -SolutionFiles $file -MSBuildLocation $msBuildLocation -MSBuildArguments $msBuildArguments -Clean -NoTimelineLogger diff --git a/Tasks/Common/MSBuildHelpers/Tests/Invoke-BuildTools.SkipsRestoreIfSpecified.ps1 b/Tasks/Common/MSBuildHelpers/Tests/Invoke-BuildTools.SkipsRestoreIfSpecified.ps1 index c28db8cff92d..f431a8ec3478 100644 --- a/Tasks/Common/MSBuildHelpers/Tests/Invoke-BuildTools.SkipsRestoreIfSpecified.ps1 +++ b/Tasks/Common/MSBuildHelpers/Tests/Invoke-BuildTools.SkipsRestoreIfSpecified.ps1 @@ -9,9 +9,9 @@ $msBuildLocation = 'Some MSBuild location' $msBuildArguments = 'Some MSBuild arguments' Register-Mock Invoke-NuGetRestore Register-Mock Invoke-NuGetRestore { 'NuGet output' } -- -File $file -Register-Mock Invoke-MSBuild { 'MSBuild output' } -- -ProjectFile $file -MSBuildPath $msBuildLocation -AdditionalArguments $msBuildArguments -NoTimelineLogger: $true -LogFile: "$file.log" -Register-Mock Invoke-MSBuild { 'MSBuild clean output' } -- -ProjectFile $file -Targets Clean -MSBuildPath $msBuildLocation -AdditionalArguments $msBuildArguments -NoTimelineLogger: $true -LogFile: "$file-clean.log" -Register-Mock Invoke-MSBuild { 'MSBuild clean output wrong logfile' } -- -ProjectFile $file -Targets Clean -MSBuildPath $msBuildLocation -AdditionalArguments $msBuildArguments -NoTimelineLogger: $true -LogFile: "$file.log" +Register-Mock Invoke-MSBuild { 'MSBuild output' } -- -ProjectFile $file -MSBuildPath $msBuildLocation -AdditionalArguments $msBuildArguments -NoTimelineLogger: $true -IsDefaultLoggerEnabled:$true -LogFile: "$file.log" +Register-Mock Invoke-MSBuild { 'MSBuild clean output' } -- -ProjectFile $file -Targets Clean -MSBuildPath $msBuildLocation -AdditionalArguments $msBuildArguments -NoTimelineLogger: $true -IsDefaultLoggerEnabled:$true -LogFile: "$file-clean.log" +Register-Mock Invoke-MSBuild { 'MSBuild clean output wrong logfile' } -- -ProjectFile $file -Targets Clean -MSBuildPath $msBuildLocation -AdditionalArguments $msBuildArguments -NoTimelineLogger: $true -IsDefaultLoggerEnabled:$true -LogFile: "$file.log" # Act. $actual = Invoke-BuildTools -SolutionFiles $file -MSBuildLocation 'Some MSBuild location' -MSBuildArguments 'Some MSBuild arguments' -Clean -NoTimelineLogger -CreateLogFile diff --git a/Tasks/Common/MSBuildHelpers/Tests/Invoke-BuildTools.SkipsSecondBuildIfCleanPlusTargetsProvided.ps1 b/Tasks/Common/MSBuildHelpers/Tests/Invoke-BuildTools.SkipsSecondBuildIfCleanPlusTargetsProvided.ps1 index ce246b14e9dc..e5e53f9659b4 100644 --- a/Tasks/Common/MSBuildHelpers/Tests/Invoke-BuildTools.SkipsSecondBuildIfCleanPlusTargetsProvided.ps1 +++ b/Tasks/Common/MSBuildHelpers/Tests/Invoke-BuildTools.SkipsSecondBuildIfCleanPlusTargetsProvided.ps1 @@ -12,12 +12,12 @@ $msBuildLocation = 'Some MSBuild location' $msBuildArguments = 'Some MSBuild with /t:arguments' Register-Mock Invoke-NuGetRestore { 'NuGet output 1' } -- -File $file1 Register-Mock Invoke-NuGetRestore { 'NuGet output 2' } -- -File $file2 -Register-Mock Invoke-MSBuild { 'MSBuild output 1' } -- -ProjectFile $file1 -MSBuildPath $msBuildLocation -AdditionalArguments $msBuildArguments -NoTimelineLogger: $true -LogFile: "$file1.log" -Register-Mock Invoke-MSBuild { 'MSBuild output 2' } -- -ProjectFile $file2 -MSBuildPath $msBuildLocation -AdditionalArguments $msBuildArguments -NoTimelineLogger: $true -LogFile: "$file2.log" -Register-Mock Invoke-MSBuild { 'MSBuild clean output 1' } -- -ProjectFile $file1 -Targets Clean -MSBuildPath $msBuildLocation -AdditionalArguments $msBuildArguments -NoTimelineLogger: $true -LogFile: "$file1-clean.log" -Register-Mock Invoke-MSBuild { 'MSBuild clean output 2' } -- -ProjectFile $file2 -Targets Clean -MSBuildPath $msBuildLocation -AdditionalArguments $msBuildArguments -NoTimelineLogger: $true -LogFile: "$file2-clean.log" -Register-Mock Invoke-MSBuild { 'MSBuild clean output 1 wrong logfile' } -- -ProjectFile $file1 -Targets Clean -MSBuildPath $msBuildLocation -AdditionalArguments $msBuildArguments -NoTimelineLogger: $true -LogFile: "$file1.log" -Register-Mock Invoke-MSBuild { 'MSBuild clean output 2 wrong logfile' } -- -ProjectFile $file2 -Targets Clean -MSBuildPath $msBuildLocation -AdditionalArguments $msBuildArguments -NoTimelineLogger: $true -LogFile: "$file2.log" +Register-Mock Invoke-MSBuild { 'MSBuild output 1' } -- -ProjectFile $file1 -MSBuildPath $msBuildLocation -AdditionalArguments $msBuildArguments -NoTimelineLogger: $true -IsDefaultLoggerEnabled:$true -LogFile: "$file1.log" +Register-Mock Invoke-MSBuild { 'MSBuild output 2' } -- -ProjectFile $file2 -MSBuildPath $msBuildLocation -AdditionalArguments $msBuildArguments -NoTimelineLogger: $true -IsDefaultLoggerEnabled:$true -LogFile: "$file2.log" +Register-Mock Invoke-MSBuild { 'MSBuild clean output 1' } -- -ProjectFile $file1 -Targets Clean -MSBuildPath $msBuildLocation -AdditionalArguments $msBuildArguments -NoTimelineLogger: $true -IsDefaultLoggerEnabled:$true -LogFile: "$file1-clean.log" +Register-Mock Invoke-MSBuild { 'MSBuild clean output 2' } -- -ProjectFile $file2 -Targets Clean -MSBuildPath $msBuildLocation -AdditionalArguments $msBuildArguments -NoTimelineLogger: $true -IsDefaultLoggerEnabled:$true -LogFile: "$file2-clean.log" +Register-Mock Invoke-MSBuild { 'MSBuild clean output 1 wrong logfile' } -- -ProjectFile $file1 -Targets Clean -MSBuildPath $msBuildLocation -AdditionalArguments $msBuildArguments -NoTimelineLogger: $true -IsDefaultLoggerEnabled:$true -LogFile: "$file1.log" +Register-Mock Invoke-MSBuild { 'MSBuild clean output 2 wrong logfile' } -- -ProjectFile $file2 -Targets Clean -MSBuildPath $msBuildLocation -AdditionalArguments $msBuildArguments -NoTimelineLogger: $true -IsDefaultLoggerEnabled:$true -LogFile: "$file2.log" # Act. $actual = Invoke-BuildTools -NuGetRestore -SolutionFiles $file1, $file2 -MSBuildLocation $msBuildLocation -MSBuildArguments $msBuildArguments -Clean -NoTimelineLogger -CreateLogFile diff --git a/Tasks/Common/MSBuildHelpers/Tests/L0.ts b/Tasks/Common/MSBuildHelpers/Tests/L0.ts index 7a15d91a2456..463698cca497 100644 --- a/Tasks/Common/MSBuildHelpers/Tests/L0.ts +++ b/Tasks/Common/MSBuildHelpers/Tests/L0.ts @@ -96,6 +96,12 @@ describe('Common-MSBuildHelpers Suite', function () { it('(Invoke-BuildTools) skips second build if clean plus targets provided', (done) => { psr.run(path.join(__dirname, 'Invoke-BuildTools.SkipsSecondBuildIfCleanPlusTargetsProvided.ps1'), done); }) + it('(Invoke-BuildTools) default logger is enabled by default', (done) => { + psr.run(path.join(__dirname, 'Invoke-BuildTools.DefaultLoggerEnabledByDefault.ps1'), done); + }) + it('(Invoke-BuildTools) disables default logger', (done) => { + psr.run(path.join(__dirname, 'Invoke-BuildTools.DisableDefaultLogger.ps1'), done); + }) it('(Invoke-MSBuild) combines msbuildexe', (done) => { psr.run(path.join(__dirname, 'Invoke-MSBuild.CombinesMsbuildexe.ps1'), done); }) diff --git a/Tasks/Common/MSBuildHelpers/package-lock.json b/Tasks/Common/MSBuildHelpers/package-lock.json index 915e1d164b4a..eda10f379239 100644 --- a/Tasks/Common/MSBuildHelpers/package-lock.json +++ b/Tasks/Common/MSBuildHelpers/package-lock.json @@ -1,6 +1,6 @@ { "name": "msbuildhelpers", - "version": "1.0.0", + "version": "1.183.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/Tasks/Common/MSBuildHelpers/package.json b/Tasks/Common/MSBuildHelpers/package.json index 098257834013..0db9dfe1cbfd 100644 --- a/Tasks/Common/MSBuildHelpers/package.json +++ b/Tasks/Common/MSBuildHelpers/package.json @@ -1,6 +1,6 @@ { "name": "msbuildhelpers", - "version": "1.0.0", + "version": "1.183.0", "description": "Azure Pipelines tasks MSBuild helpers", "main": "msbuildhelpers.js", "scripts": { diff --git a/Tasks/MSBuildV1/package-lock.json b/Tasks/MSBuildV1/package-lock.json index ba6a9b41bb4d..2cdf2920eda5 100644 --- a/Tasks/MSBuildV1/package-lock.json +++ b/Tasks/MSBuildV1/package-lock.json @@ -315,7 +315,7 @@ "integrity": "sha1-9O3g2HUMHJcnwnLqLGBiniyaHE8=" }, "msbuildhelpers": { - "version": "file:../../_build/Tasks/Common/msbuildhelpers-1.0.0.tgz", + "version": "file:../../_build/Tasks/Common/msbuildhelpers-1.183.0.tgz", "requires": { "azure-pipelines-task-lib": "^2.9.3" }, diff --git a/Tasks/MSBuildV1/package.json b/Tasks/MSBuildV1/package.json index 675977f14b3b..6ed63832090d 100644 --- a/Tasks/MSBuildV1/package.json +++ b/Tasks/MSBuildV1/package.json @@ -15,7 +15,7 @@ "@types/mocha": "^5.2.7", "@types/node": "^10.17.0", "azure-pipelines-task-lib": "^3.0.6-preview.0", - "msbuildhelpers": "file:../../_build/Tasks/Common/msbuildhelpers-1.0.0.tgz" + "msbuildhelpers": "file:../../_build/Tasks/Common/msbuildhelpers-1.183.0.tgz" }, "devDependencies": { "typescript": "4.0.2" diff --git a/Tasks/MSBuildV1/task.json b/Tasks/MSBuildV1/task.json index b900d5171e0f..06953ebf2209 100644 --- a/Tasks/MSBuildV1/task.json +++ b/Tasks/MSBuildV1/task.json @@ -12,7 +12,7 @@ "author": "Microsoft Corporation", "version": { "Major": 1, - "Minor": 179, + "Minor": 183, "Patch": 0 }, "demands": [ diff --git a/Tasks/MSBuildV1/task.loc.json b/Tasks/MSBuildV1/task.loc.json index f0be4b3f5b3d..ebe1af70a53f 100644 --- a/Tasks/MSBuildV1/task.loc.json +++ b/Tasks/MSBuildV1/task.loc.json @@ -12,7 +12,7 @@ "author": "Microsoft Corporation", "version": { "Major": 1, - "Minor": 179, + "Minor": 183, "Patch": 0 }, "demands": [ diff --git a/Tasks/VSBuildV1/Strings/resources.resjson/en-US/resources.resjson b/Tasks/VSBuildV1/Strings/resources.resjson/en-US/resources.resjson index 7c74262934e2..e383455517cf 100644 --- a/Tasks/VSBuildV1/Strings/resources.resjson/en-US/resources.resjson +++ b/Tasks/VSBuildV1/Strings/resources.resjson/en-US/resources.resjson @@ -28,6 +28,8 @@ "loc.input.help.createLogFile": "Optionally create a log file (Windows only).", "loc.input.label.logFileVerbosity": "Log File Verbosity", "loc.input.help.logFileVerbosity": "Optional log file verbosity.", + "loc.input.label.enableDefaultLogger": "Enable Default Logger", + "loc.input.help.enableDefaultLogger": "If true - enables default logger for msbuild", "loc.messages.MSBuildLocationDeprecated0": "The MSBuild location parameter has been deprecated. Ignoring value '{0}'", "loc.messages.MSBuildVersionDeprecated0": "The MSBuild version parameter has been deprecated. Ignoring value '{0}'.", "loc.messages.UnexpectedVSVersion0": "Unexpected Visual Studio version '{0}'.", diff --git a/Tasks/VSBuildV1/Tests/MapsVSVersions.ps1 b/Tasks/VSBuildV1/Tests/MapsVSVersions.ps1 index a0119d6f2717..0a0ecfffa39f 100644 --- a/Tasks/VSBuildV1/Tests/MapsVSVersions.ps1 +++ b/Tasks/VSBuildV1/Tests/MapsVSVersions.ps1 @@ -31,6 +31,7 @@ foreach ($mapping in $mappings) { Register-Mock Get-VstsInput { $false } -- -Name RestoreNuGetPackages -AsBool Register-Mock Get-VstsInput { $false } -- -Name LogProjectEvents -AsBool Register-Mock Get-VstsInput { $false } -- -Name CreateLogFile -AsBool + Register-Mock Get-VstsInput { $false } -- -Name EnableDefaultLogger -AsBool Register-Mock Select-VSVersion { $mapping.VSVersion } -- -PreferredVersion $mapping.VSVersion Register-Mock Select-MSBuildPath diff --git a/Tasks/VSBuildV1/Tests/PassesArguments.ps1 b/Tasks/VSBuildV1/Tests/PassesArguments.ps1 index ae9a50b66d87..e4a5518ec7e6 100644 --- a/Tasks/VSBuildV1/Tests/PassesArguments.ps1 +++ b/Tasks/VSBuildV1/Tests/PassesArguments.ps1 @@ -5,14 +5,15 @@ param() . $PSScriptRoot\..\..\..\Tests\lib\Initialize-Test.ps1 $variableSets = @( # Variable combinations to assert Booleans are passed correctly. - @{ Clean = $false ; MaximumCpuCount = $false ; RestoreNugetPackages = $false ; LogProjectEvents = $false ; CreateLogFile = $true ; LogFileVerbosity = '' ; Debug = $false ; VSVersion = '14.0' } - @{ Clean = $false ; MaximumCpuCount = $false ; RestoreNugetPackages = $false ; LogProjectEvents = $true ; CreateLogFile = $false ; LogFileVerbosity = '' ; Debug = $false ; VSVersion = '14.0' } - @{ Clean = $false ; MaximumCpuCount = $false ; RestoreNugetPackages = $true ; LogProjectEvents = $false ; CreateLogFile = $false ; LogFileVerbosity = '' ; Debug = $false ; VSVersion = '14.0' } - @{ Clean = $false ; MaximumCpuCount = $true ; RestoreNugetPackages = $false ; LogProjectEvents = $false ; CreateLogFile = $false ; LogFileVerbosity = '' ; Debug = $false ; VSVersion = '14.0' } - @{ Clean = $true ; MaximumCpuCount = $false ; RestoreNugetPackages = $false ; LogProjectEvents = $false ; CreateLogFile = $false ; LogFileVerbosity = '' ; Debug = $false ; VSVersion = '14.0' } - @{ Clean = $true ; MaximumCpuCount = $false ; RestoreNugetPackages = $false ; LogProjectEvents = $false ; CreateLogFile = $false ; LogFileVerbosity = '' ; Debug = $false ; VSVersion = '14.0' } - @{ Clean = $true ; MaximumCpuCount = $false ; RestoreNugetPackages = $false ; LogProjectEvents = $false ; CreateLogFile = $true ; LogFileVerbosity = 'detailed' ; Debug = $false ; VSVersion = '14.0' } - @{ Clean = $true ; MaximumCpuCount = $false ; RestoreNugetPackages = $false ; LogProjectEvents = $false ; CreateLogFile = $true ; LogFileVerbosity = 'detailed' ; Debug = $true ; VSVersion = '14.0' } + @{ Clean = $false ; MaximumCpuCount = $false ; RestoreNugetPackages = $false ; LogProjectEvents = $false ; CreateLogFile = $true ; LogFileVerbosity = '' ; Debug = $false ; VSVersion = '14.0'; EnableDefaultLogger = $true } + @{ Clean = $false ; MaximumCpuCount = $false ; RestoreNugetPackages = $false ; LogProjectEvents = $true ; CreateLogFile = $false ; LogFileVerbosity = '' ; Debug = $false ; VSVersion = '14.0'; EnableDefaultLogger = $true } + @{ Clean = $false ; MaximumCpuCount = $false ; RestoreNugetPackages = $true ; LogProjectEvents = $false ; CreateLogFile = $false ; LogFileVerbosity = '' ; Debug = $false ; VSVersion = '14.0'; EnableDefaultLogger = $true } + @{ Clean = $false ; MaximumCpuCount = $true ; RestoreNugetPackages = $false ; LogProjectEvents = $false ; CreateLogFile = $false ; LogFileVerbosity = '' ; Debug = $false ; VSVersion = '14.0'; EnableDefaultLogger = $true } + @{ Clean = $true ; MaximumCpuCount = $false ; RestoreNugetPackages = $false ; LogProjectEvents = $false ; CreateLogFile = $false ; LogFileVerbosity = '' ; Debug = $false ; VSVersion = '14.0'; EnableDefaultLogger = $true } + @{ Clean = $true ; MaximumCpuCount = $false ; RestoreNugetPackages = $false ; LogProjectEvents = $false ; CreateLogFile = $false ; LogFileVerbosity = '' ; Debug = $false ; VSVersion = '14.0'; EnableDefaultLogger = $true } + @{ Clean = $true ; MaximumCpuCount = $false ; RestoreNugetPackages = $false ; LogProjectEvents = $false ; CreateLogFile = $true ; LogFileVerbosity = 'detailed' ; Debug = $false ; VSVersion = '14.0'; EnableDefaultLogger = $true } + @{ Clean = $true ; MaximumCpuCount = $false ; RestoreNugetPackages = $false ; LogProjectEvents = $false ; CreateLogFile = $true ; LogFileVerbosity = 'detailed' ; Debug = $true ; VSVersion = '14.0'; EnableDefaultLogger = $true } + @{ Clean = $true ; MaximumCpuCount = $false ; RestoreNugetPackages = $false ; LogProjectEvents = $false ; CreateLogFile = $true ; LogFileVerbosity = 'detailed' ; Debug = $true ; VSVersion = '14.0'; EnableDefaultLogger = $false } ) foreach ($variableSet in $variableSets) { Unregister-Mock Get-VstsInput @@ -34,6 +35,7 @@ foreach ($variableSet in $variableSets) { Register-Mock Get-VstsInput { $variableSet.LogProjectEvents } -- -Name LogProjectEvents -AsBool Register-Mock Get-VstsInput { $variableSet.CreateLogFile } -- -Name CreateLogFile -AsBool Register-Mock Get-VstsInput { $variableSet.LogFileVerbosity } -- -Name LogFileVerbosity + Register-Mock Get-VstsInput { $variableSet.EnableDefaultLogger } -- -Name EnableDefaultLogger -AsBool Register-Mock Get-VstsTaskVariable { $variableSet.Debug } -- -Name System.Debug -AsBool Register-Mock Get-SolutionFiles { 'Some solution 1', 'Some solution 2' } -- -Solution 'Some input solution' Register-Mock Select-VSVersion { $variableSet.VSVersion } -- -PreferredVersion $variableSet.VSVersion @@ -49,5 +51,5 @@ foreach ($variableSet in $variableSets) { # Assert. Assert-AreEqual 'Some build output' $output - Assert-WasCalled Invoke-BuildTools -- -NuGetRestore: $variableSet.RestoreNuGetPackages -SolutionFiles @('Some solution 1', 'Some solution 2') -MSBuildLocation 'Some MSBuild location' -MSBuildArguments 'Some formatted arguments' -Clean: $variableSet.Clean -NoTimelineLogger: $(!$variableSet.LogProjectEvents) -CreateLogFile: $ExpectedCreateLogFile -LogFileVerbosity: $ExpectedLogFileVerbosity + Assert-WasCalled Invoke-BuildTools -- -NuGetRestore: $variableSet.RestoreNuGetPackages -SolutionFiles @('Some solution 1', 'Some solution 2') -MSBuildLocation 'Some MSBuild location' -MSBuildArguments 'Some formatted arguments' -Clean: $variableSet.Clean -NoTimelineLogger: $(!$variableSet.LogProjectEvents) -CreateLogFile: $ExpectedCreateLogFile -LogFileVerbosity: $ExpectedLogFileVerbosity -IsDefaultLoggerEnabled: $variableSet.EnableDefaultLogger } diff --git a/Tasks/VSBuildV1/Tests/ThrowsIfUnknownVSVersion.ps1 b/Tasks/VSBuildV1/Tests/ThrowsIfUnknownVSVersion.ps1 index 0a3777a92adf..fbef3d4f5dbc 100644 --- a/Tasks/VSBuildV1/Tests/ThrowsIfUnknownVSVersion.ps1 +++ b/Tasks/VSBuildV1/Tests/ThrowsIfUnknownVSVersion.ps1 @@ -15,11 +15,11 @@ Register-Mock Get-VstsInput { $false } -- -Name MaximumCpuCount -AsBool Register-Mock Get-VstsInput { $false } -- -Name RestoreNuGetPackages -AsBool Register-Mock Get-VstsInput { $false } -- -Name LogProjectEvents -AsBool Register-Mock Get-VstsInput { $false } -- -Name CreateLogFile -AsBool +Register-Mock Get-VstsInput { $true } -- -Name EnableDefaultLogger -AsBool Register-Mock Get-VstsTaskVariable { $false } -- -Name System.Debug -AsBool Register-Mock Select-VSVersion { 'nosuchversion' } -- -PreferredVersion '14.0' Register-Mock Select-MSBuildPath Register-Mock Format-MSBuildArguments -Register-Mock Invoke-BuildTools # Act. Assert-Throws { $null = & $PSScriptRoot\..\VSBuild.ps1 } -MessagePattern "*nosuchversion*" diff --git a/Tasks/VSBuildV1/VSBuild.ps1 b/Tasks/VSBuildV1/VSBuild.ps1 index 5229f9d6d505..a8fedef498dd 100644 --- a/Tasks/VSBuildV1/VSBuild.ps1 +++ b/Tasks/VSBuildV1/VSBuild.ps1 @@ -21,6 +21,7 @@ try { [bool]$logProjectEvents = Get-VstsInput -Name LogProjectEvents -AsBool [bool]$createLogFile = (Get-VstsInput -Name CreateLogFile -AsBool) -or $debug [string]$logFileVerbosity = if ($debug) { "diagnostic" } else { Get-VstsInput -Name LogFileVerbosity } + [bool]$enableDefaultLogger = Get-VstsInput -Name EnableDefaultLogger -AsBool # Warn if deprecated inputs were specified. if ([string]$vsLocation = Get-VstsInput -Name VSLocation) { @@ -76,7 +77,7 @@ try { $global:ErrorActionPreference = 'Continue' # Build each solution. - Invoke-BuildTools -NuGetRestore:$RestoreNuGetPackages -SolutionFiles $solutionFiles -MSBuildLocation $MSBuildLocation -MSBuildArguments $MSBuildArgs -Clean:$Clean -NoTimelineLogger:(!$LogProjectEvents) -CreateLogFile:$createLogFile -LogFileVerbosity:$logFileVerbosity + Invoke-BuildTools -NuGetRestore:$RestoreNuGetPackages -SolutionFiles $solutionFiles -MSBuildLocation $MSBuildLocation -MSBuildArguments $MSBuildArgs -Clean:$Clean -NoTimelineLogger:(!$LogProjectEvents) -CreateLogFile:$createLogFile -LogFileVerbosity:$logFileVerbosity -IsDefaultLoggerEnabled:$enableDefaultLogger } finally { Trace-VstsLeavingInvocation $MyInvocation } \ No newline at end of file diff --git a/Tasks/VSBuildV1/task.json b/Tasks/VSBuildV1/task.json index 957a5ec2e291..1cb9690580f6 100644 --- a/Tasks/VSBuildV1/task.json +++ b/Tasks/VSBuildV1/task.json @@ -12,8 +12,8 @@ "author": "Microsoft Corporation", "version": { "Major": 1, - "Minor": 166, - "Patch": 2 + "Minor": 183, + "Patch": 0 }, "demands": [ "msbuild", @@ -149,6 +149,15 @@ "diagnostic": "Diagnostic" }, "visibleRule": "createLogFile = true" + }, + { + "name": "enableDefaultLogger", + "type": "boolean", + "label": "Enable Default Logger", + "defaultValue": "true", + "required": false, + "helpMarkDown": "If true - enables default logger for msbuild", + "groupName": "advanced" } ], "instanceNameFormat": "Build solution $(solution)", diff --git a/Tasks/VSBuildV1/task.loc.json b/Tasks/VSBuildV1/task.loc.json index 7b9274ffec6b..725b36c02d28 100644 --- a/Tasks/VSBuildV1/task.loc.json +++ b/Tasks/VSBuildV1/task.loc.json @@ -12,8 +12,8 @@ "author": "Microsoft Corporation", "version": { "Major": 1, - "Minor": 166, - "Patch": 2 + "Minor": 183, + "Patch": 0 }, "demands": [ "msbuild", @@ -149,6 +149,15 @@ "diagnostic": "Diagnostic" }, "visibleRule": "createLogFile = true" + }, + { + "name": "enableDefaultLogger", + "type": "boolean", + "label": "ms-resource:loc.input.label.enableDefaultLogger", + "defaultValue": "true", + "required": false, + "helpMarkDown": "ms-resource:loc.input.help.enableDefaultLogger", + "groupName": "advanced" } ], "instanceNameFormat": "ms-resource:loc.instanceNameFormat", diff --git a/Tasks/XamarinAndroidV1/task.json b/Tasks/XamarinAndroidV1/task.json index 91de11762f48..2a71f3d34877 100644 --- a/Tasks/XamarinAndroidV1/task.json +++ b/Tasks/XamarinAndroidV1/task.json @@ -12,7 +12,7 @@ "author": "Microsoft Corporation", "version": { "Major": 1, - "Minor": 180, + "Minor": 183, "Patch": 0 }, "demands": [ diff --git a/Tasks/XamarinAndroidV1/task.loc.json b/Tasks/XamarinAndroidV1/task.loc.json index 08a6c5e0c321..22e185ecfda8 100644 --- a/Tasks/XamarinAndroidV1/task.loc.json +++ b/Tasks/XamarinAndroidV1/task.loc.json @@ -12,7 +12,7 @@ "author": "Microsoft Corporation", "version": { "Major": 1, - "Minor": 180, + "Minor": 183, "Patch": 0 }, "demands": [