From d370eb0dde19f5e44b79f5fd17bccdac8a7d1a9c Mon Sep 17 00:00:00 2001 From: Cory Knox Date: Thu, 13 Oct 2022 19:15:31 -0700 Subject: [PATCH 1/3] (maint) Normalize the recipe.cake line endings .editorconfig file says all files should be CRLF. When editing the recipe.cake with .editorconfig support, vscode wants to change the line endings every time the file is saved. As there's no reason to keep the file LF only, it seems reasonable to normalize the line endings before making any other changes. --- recipe.cake | 358 ++++++++++++++++++++++++++-------------------------- 1 file changed, 179 insertions(+), 179 deletions(-) diff --git a/recipe.cake b/recipe.cake index c192390fb4..d6f2547444 100644 --- a/recipe.cake +++ b/recipe.cake @@ -1,179 +1,179 @@ -#load nuget:?package=Chocolatey.Cake.Recipe&version=0.16.0 - -/////////////////////////////////////////////////////////////////////////////// -// TOOLS -/////////////////////////////////////////////////////////////////////////////// - -// This is needed in order to allow NUnit v2 tested to be executed by the NUnit -// v3 Test Runner -#tool nuget:?package=NUnit.Extension.NUnitV2Driver&version=3.9.0 - -/////////////////////////////////////////////////////////////////////////////// -// SCRIPT -/////////////////////////////////////////////////////////////////////////////// - -Func> getILMergeConfigs = () => -{ - var mergeConfigs = new List(); - - var targetPlatform = "v4,C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.0"; - var assembliesToILMerge = GetFiles(BuildParameters.Paths.Directories.PublishedApplications + "/choco/*.{exe|dll}") - - GetFiles(BuildParameters.Paths.Directories.PublishedApplications + "/choco/choco.exe") - - GetFiles(BuildParameters.Paths.Directories.PublishedApplications + "/choco/System.Management.Automation.dll"); - - Information("The following assemblies have been selected to be ILMerged for choco.exe..."); - foreach (var assemblyToILMerge in assembliesToILMerge) - { - Information(assemblyToILMerge.FullPath); - } - - mergeConfigs.Add(new ILMergeConfig() { - KeyFile = BuildParameters.StrongNameKeyPath, - LogFile = BuildParameters.Paths.Directories.Build + "/ilmerge-chocoexe.log", - TargetPlatform = targetPlatform, - Target = "exe", - Internalize = BuildParameters.RootDirectoryPath + "/src/chocolatey.console/ilmerge.internalize.ignore.txt", - Output = BuildParameters.Paths.Directories.PublishedApplications + "/choco_merged/choco.exe", - PrimaryAssemblyName = BuildParameters.Paths.Directories.PublishedApplications + "/choco/choco.exe", - AssemblyPaths = assembliesToILMerge }); - - assembliesToILMerge = GetFiles(BuildParameters.Paths.Directories.PublishedLibraries + "/chocolatey/*.{exe|dll}") - - GetFiles(BuildParameters.Paths.Directories.PublishedLibraries + "/chocolatey/choco.exe") - - GetFiles(BuildParameters.Paths.Directories.PublishedLibraries + "/chocolatey/chocolatey.dll") - - GetFiles(BuildParameters.Paths.Directories.PublishedLibraries + "/chocolatey/log4net.dll") - - GetFiles(BuildParameters.Paths.Directories.PublishedLibraries + "/chocolatey/System.Management.Automation.dll"); - - Information("The following assemblies have been selected to be ILMerged for chocolatey.dll..."); - foreach (var assemblyToILMerge in assembliesToILMerge) - { - Information(assemblyToILMerge.FullPath); - } - - mergeConfigs.Add(new ILMergeConfig() { - KeyFile = BuildParameters.StrongNameKeyPath, - LogFile = BuildParameters.Paths.Directories.Build + "/ilmerge-chocolateydll.log", - TargetPlatform = targetPlatform, - Target = "dll", - Internalize = BuildParameters.RootDirectoryPath + "/src/chocolatey/ilmerge.internalize.ignore.dll.txt", - Output = BuildParameters.Paths.Directories.PublishedLibraries + "/chocolatey_merged/chocolatey.dll", - PrimaryAssemblyName = BuildParameters.Paths.Directories.PublishedLibraries + "/chocolatey/chocolatey.dll", - AssemblyPaths = assembliesToILMerge }); - - return mergeConfigs; -}; - -Func getScriptsToSign = () => -{ - var scriptsToSign = GetFiles(BuildParameters.Paths.Directories.NuGetNuspecDirectory + "/**/*.{ps1|psm1}") + - GetFiles(BuildParameters.Paths.Directories.ChocolateyNuspecDirectory + "/**/*.{ps1|psm1}"); - - Information("The following PowerShell scripts have been selected to be signed..."); - foreach (var scriptToSign in scriptsToSign) - { - Information(scriptToSign.FullPath); - } - - return scriptsToSign; -}; - -Func getFilesToSign = () => -{ - var filesToSign = GetFiles(BuildParameters.Paths.Directories.NuGetNuspecDirectory + "/lib/chocolatey.dll") - + GetFiles(BuildParameters.Paths.Directories.ChocolateyNuspecDirectory + "/tools/chocolateyInstall/choco.exe") - + GetFiles(BuildParameters.Paths.Directories.ChocolateyNuspecDirectory + "/tools/chocolateyInstall/tools/{checksum|shimgen}.exe") - + GetFiles(BuildParameters.Paths.Directories.ChocolateyNuspecDirectory + "/tools/chocolateyInstall/redirects/*.exe"); - - Information("The following assemblies have been selected to be signed..."); - foreach (var fileToSign in filesToSign) - { - Information(fileToSign.FullPath); - } - - return filesToSign; -}; - -/////////////////////////////////////////////////////////////////////////////// -// CUSTOM TASKS -/////////////////////////////////////////////////////////////////////////////// - -Task("Prepare-Chocolatey-Packages") - .IsDependeeOf("Create-Chocolatey-Packages") - .IsDependeeOf("Sign-PowerShellScripts") - .IsDependeeOf("Sign-Assemblies") - .WithCriteria(() => BuildParameters.BuildAgentOperatingSystem == PlatformFamily.Windows, "Skipping because not running on Windows") - .Does(() => -{ - // Copy legal documents - CopyFile(BuildParameters.RootDirectoryPath + "/docs/legal/CREDITS.md", BuildParameters.Paths.Directories.ChocolateyNuspecDirectory + "/tools/chocolateyInstall/CREDITS.txt"); - - // Run Chocolatey Unpackself - CopyFile(BuildParameters.Paths.Directories.PublishedApplications + "/choco_merged/choco.exe", BuildParameters.Paths.Directories.ChocolateyNuspecDirectory + "/tools/chocolateyInstall/choco.exe"); - - StartProcess(BuildParameters.Paths.Directories.ChocolateyNuspecDirectory + "/tools/chocolateyInstall/choco.exe", new ProcessSettings{ Arguments = "unpackself -f -y --allow-unofficial-build" }); - - // Tidy up logs and config folder which are not required - var logsDirectory = BuildParameters.Paths.Directories.ChocolateyNuspecDirectory + "/tools/chocolateyInstall/logs"; - var configDirectory = BuildParameters.Paths.Directories.ChocolateyNuspecDirectory + "/tools/chocolateyInstall/config"; - - if (DirectoryExists(logsDirectory)) - { - DeleteDirectory(logsDirectory, new DeleteDirectorySettings { - Recursive = true, - Force = true - }); - } - - if (DirectoryExists(configDirectory)) - { - DeleteDirectory(configDirectory, new DeleteDirectorySettings { - Recursive = true, - Force = true - }); - } -}); - -Task("Prepare-NuGet-Packages") - .IsDependeeOf("Create-NuGet-Packages") - .IsDependeeOf("Sign-PowerShellScripts") - .IsDependeeOf("Sign-Assemblies") - .Does(() => -{ - // Copy legal documents - CleanDirectory(BuildParameters.Paths.Directories.NuGetNuspecDirectory + "/lib"); - CopyFile(BuildParameters.RootDirectoryPath + "/docs/legal/CREDITS.md", BuildParameters.Paths.Directories.NuGetNuspecDirectory + "/lib/CREDITS.txt"); - - CopyFiles(BuildParameters.Paths.Directories.PublishedLibraries + "/chocolatey_merged/*", BuildParameters.Paths.Directories.NuGetNuspecDirectory + "/lib"); - CopyFile(BuildParameters.Paths.Directories.PublishedLibraries + "/chocolatey/chocolatey.xml", BuildParameters.Paths.Directories.NuGetNuspecDirectory + "/lib/chocolatey.xml"); -}); - -/////////////////////////////////////////////////////////////////////////////// -// RECIPE SCRIPT -/////////////////////////////////////////////////////////////////////////////// - -Environment.SetVariableNames(); - -BuildParameters.SetParameters(context: Context, - buildSystem: BuildSystem, - sourceDirectoryPath: "./src", - solutionFilePath: "./src/chocolatey.sln", - solutionDirectoryPath: "./src/chocolatey", - resharperSettingsFileName: "chocolatey.sln.DotSettings", - title: "Chocolatey", - repositoryOwner: "chocolatey", - repositoryName: "choco", - productName: "Chocolatey", - productDescription: "chocolatey is a product of Chocolatey Software, Inc. - All Rights Reserved.", - productCopyright: string.Format("Copyright © 2017 - {0} Chocolatey Software, Inc. Copyright © 2011 - 2017, RealDimensions Software, LLC - All Rights Reserved.", DateTime.Now.Year), - shouldStrongNameSignDependentAssemblies: false, - treatWarningsAsErrors: false, - getScriptsToSign: getScriptsToSign, - getFilesToSign: getFilesToSign, - getILMergeConfigs: getILMergeConfigs, - preferDotNetGlobalToolUsage: !IsRunningOnWindows()); - -ToolSettings.SetToolSettings(context: Context, - buildMSBuildToolVersion: MSBuildToolVersion.NET40); - -BuildParameters.PrintParameters(Context); - -Build.Run(); \ No newline at end of file +#load nuget:?package=Chocolatey.Cake.Recipe&version=0.16.0 + +/////////////////////////////////////////////////////////////////////////////// +// TOOLS +/////////////////////////////////////////////////////////////////////////////// + +// This is needed in order to allow NUnit v2 tested to be executed by the NUnit +// v3 Test Runner +#tool nuget:?package=NUnit.Extension.NUnitV2Driver&version=3.9.0 + +/////////////////////////////////////////////////////////////////////////////// +// SCRIPT +/////////////////////////////////////////////////////////////////////////////// + +Func> getILMergeConfigs = () => +{ + var mergeConfigs = new List(); + + var targetPlatform = "v4,C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.0"; + var assembliesToILMerge = GetFiles(BuildParameters.Paths.Directories.PublishedApplications + "/choco/*.{exe|dll}") + - GetFiles(BuildParameters.Paths.Directories.PublishedApplications + "/choco/choco.exe") + - GetFiles(BuildParameters.Paths.Directories.PublishedApplications + "/choco/System.Management.Automation.dll"); + + Information("The following assemblies have been selected to be ILMerged for choco.exe..."); + foreach (var assemblyToILMerge in assembliesToILMerge) + { + Information(assemblyToILMerge.FullPath); + } + + mergeConfigs.Add(new ILMergeConfig() { + KeyFile = BuildParameters.StrongNameKeyPath, + LogFile = BuildParameters.Paths.Directories.Build + "/ilmerge-chocoexe.log", + TargetPlatform = targetPlatform, + Target = "exe", + Internalize = BuildParameters.RootDirectoryPath + "/src/chocolatey.console/ilmerge.internalize.ignore.txt", + Output = BuildParameters.Paths.Directories.PublishedApplications + "/choco_merged/choco.exe", + PrimaryAssemblyName = BuildParameters.Paths.Directories.PublishedApplications + "/choco/choco.exe", + AssemblyPaths = assembliesToILMerge }); + + assembliesToILMerge = GetFiles(BuildParameters.Paths.Directories.PublishedLibraries + "/chocolatey/*.{exe|dll}") + - GetFiles(BuildParameters.Paths.Directories.PublishedLibraries + "/chocolatey/choco.exe") + - GetFiles(BuildParameters.Paths.Directories.PublishedLibraries + "/chocolatey/chocolatey.dll") + - GetFiles(BuildParameters.Paths.Directories.PublishedLibraries + "/chocolatey/log4net.dll") + - GetFiles(BuildParameters.Paths.Directories.PublishedLibraries + "/chocolatey/System.Management.Automation.dll"); + + Information("The following assemblies have been selected to be ILMerged for chocolatey.dll..."); + foreach (var assemblyToILMerge in assembliesToILMerge) + { + Information(assemblyToILMerge.FullPath); + } + + mergeConfigs.Add(new ILMergeConfig() { + KeyFile = BuildParameters.StrongNameKeyPath, + LogFile = BuildParameters.Paths.Directories.Build + "/ilmerge-chocolateydll.log", + TargetPlatform = targetPlatform, + Target = "dll", + Internalize = BuildParameters.RootDirectoryPath + "/src/chocolatey/ilmerge.internalize.ignore.dll.txt", + Output = BuildParameters.Paths.Directories.PublishedLibraries + "/chocolatey_merged/chocolatey.dll", + PrimaryAssemblyName = BuildParameters.Paths.Directories.PublishedLibraries + "/chocolatey/chocolatey.dll", + AssemblyPaths = assembliesToILMerge }); + + return mergeConfigs; +}; + +Func getScriptsToSign = () => +{ + var scriptsToSign = GetFiles(BuildParameters.Paths.Directories.NuGetNuspecDirectory + "/**/*.{ps1|psm1}") + + GetFiles(BuildParameters.Paths.Directories.ChocolateyNuspecDirectory + "/**/*.{ps1|psm1}"); + + Information("The following PowerShell scripts have been selected to be signed..."); + foreach (var scriptToSign in scriptsToSign) + { + Information(scriptToSign.FullPath); + } + + return scriptsToSign; +}; + +Func getFilesToSign = () => +{ + var filesToSign = GetFiles(BuildParameters.Paths.Directories.NuGetNuspecDirectory + "/lib/chocolatey.dll") + + GetFiles(BuildParameters.Paths.Directories.ChocolateyNuspecDirectory + "/tools/chocolateyInstall/choco.exe") + + GetFiles(BuildParameters.Paths.Directories.ChocolateyNuspecDirectory + "/tools/chocolateyInstall/tools/{checksum|shimgen}.exe") + + GetFiles(BuildParameters.Paths.Directories.ChocolateyNuspecDirectory + "/tools/chocolateyInstall/redirects/*.exe"); + + Information("The following assemblies have been selected to be signed..."); + foreach (var fileToSign in filesToSign) + { + Information(fileToSign.FullPath); + } + + return filesToSign; +}; + +/////////////////////////////////////////////////////////////////////////////// +// CUSTOM TASKS +/////////////////////////////////////////////////////////////////////////////// + +Task("Prepare-Chocolatey-Packages") + .IsDependeeOf("Create-Chocolatey-Packages") + .IsDependeeOf("Sign-PowerShellScripts") + .IsDependeeOf("Sign-Assemblies") + .WithCriteria(() => BuildParameters.BuildAgentOperatingSystem == PlatformFamily.Windows, "Skipping because not running on Windows") + .Does(() => +{ + // Copy legal documents + CopyFile(BuildParameters.RootDirectoryPath + "/docs/legal/CREDITS.md", BuildParameters.Paths.Directories.ChocolateyNuspecDirectory + "/tools/chocolateyInstall/CREDITS.txt"); + + // Run Chocolatey Unpackself + CopyFile(BuildParameters.Paths.Directories.PublishedApplications + "/choco_merged/choco.exe", BuildParameters.Paths.Directories.ChocolateyNuspecDirectory + "/tools/chocolateyInstall/choco.exe"); + + StartProcess(BuildParameters.Paths.Directories.ChocolateyNuspecDirectory + "/tools/chocolateyInstall/choco.exe", new ProcessSettings{ Arguments = "unpackself -f -y --allow-unofficial-build" }); + + // Tidy up logs and config folder which are not required + var logsDirectory = BuildParameters.Paths.Directories.ChocolateyNuspecDirectory + "/tools/chocolateyInstall/logs"; + var configDirectory = BuildParameters.Paths.Directories.ChocolateyNuspecDirectory + "/tools/chocolateyInstall/config"; + + if (DirectoryExists(logsDirectory)) + { + DeleteDirectory(logsDirectory, new DeleteDirectorySettings { + Recursive = true, + Force = true + }); + } + + if (DirectoryExists(configDirectory)) + { + DeleteDirectory(configDirectory, new DeleteDirectorySettings { + Recursive = true, + Force = true + }); + } +}); + +Task("Prepare-NuGet-Packages") + .IsDependeeOf("Create-NuGet-Packages") + .IsDependeeOf("Sign-PowerShellScripts") + .IsDependeeOf("Sign-Assemblies") + .Does(() => +{ + // Copy legal documents + CleanDirectory(BuildParameters.Paths.Directories.NuGetNuspecDirectory + "/lib"); + CopyFile(BuildParameters.RootDirectoryPath + "/docs/legal/CREDITS.md", BuildParameters.Paths.Directories.NuGetNuspecDirectory + "/lib/CREDITS.txt"); + + CopyFiles(BuildParameters.Paths.Directories.PublishedLibraries + "/chocolatey_merged/*", BuildParameters.Paths.Directories.NuGetNuspecDirectory + "/lib"); + CopyFile(BuildParameters.Paths.Directories.PublishedLibraries + "/chocolatey/chocolatey.xml", BuildParameters.Paths.Directories.NuGetNuspecDirectory + "/lib/chocolatey.xml"); +}); + +/////////////////////////////////////////////////////////////////////////////// +// RECIPE SCRIPT +/////////////////////////////////////////////////////////////////////////////// + +Environment.SetVariableNames(); + +BuildParameters.SetParameters(context: Context, + buildSystem: BuildSystem, + sourceDirectoryPath: "./src", + solutionFilePath: "./src/chocolatey.sln", + solutionDirectoryPath: "./src/chocolatey", + resharperSettingsFileName: "chocolatey.sln.DotSettings", + title: "Chocolatey", + repositoryOwner: "chocolatey", + repositoryName: "choco", + productName: "Chocolatey", + productDescription: "chocolatey is a product of Chocolatey Software, Inc. - All Rights Reserved.", + productCopyright: string.Format("Copyright © 2017 - {0} Chocolatey Software, Inc. Copyright © 2011 - 2017, RealDimensions Software, LLC - All Rights Reserved.", DateTime.Now.Year), + shouldStrongNameSignDependentAssemblies: false, + treatWarningsAsErrors: false, + getScriptsToSign: getScriptsToSign, + getFilesToSign: getFilesToSign, + getILMergeConfigs: getILMergeConfigs, + preferDotNetGlobalToolUsage: !IsRunningOnWindows()); + +ToolSettings.SetToolSettings(context: Context, + buildMSBuildToolVersion: MSBuildToolVersion.NET40); + +BuildParameters.PrintParameters(Context); + +Build.Run(); From 77785ff4655bccbd23c490f4be45d687679882f2 Mon Sep 17 00:00:00 2001 From: Cory Knox Date: Thu, 13 Oct 2022 19:17:09 -0700 Subject: [PATCH 2/3] (maint) Update the chocolatey.cake.recipe version Chocolatey.Cake.Recipe version 0.17.0 included support for building from a branch that starts with a number. Bumping to this version allows us to work with a branch name that starts with numbers without needing to jump through any hoops. --- recipe.cake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipe.cake b/recipe.cake index d6f2547444..f389f7cfbc 100644 --- a/recipe.cake +++ b/recipe.cake @@ -1,4 +1,4 @@ -#load nuget:?package=Chocolatey.Cake.Recipe&version=0.16.0 +#load nuget:?package=Chocolatey.Cake.Recipe&version=0.17.1 /////////////////////////////////////////////////////////////////////////////// // TOOLS From 006a2bfbc3d7ba30b48ac6bf18e96c6a111d11ff Mon Sep 17 00:00:00 2001 From: Cory Knox Date: Thu, 13 Oct 2022 19:22:28 -0700 Subject: [PATCH 3/3] (#2851) Update LicenseValidation logging logic The LicenseValidation logging logic was only checking for `-v` or `--version` as the first arguments. This completely ignored `-r`, `--limit-output`, and `--limitoutput`. Additionally, a few places weren't suppressing output when limit output was used. This change correctly detects if regular output is desired, and if it is then it marks the output accordingly, otherwise it outputs to the log file only. --- .../licensing/LicenseValidation.cs | 27 ++++++++++++++----- 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/src/chocolatey/infrastructure/licensing/LicenseValidation.cs b/src/chocolatey/infrastructure/licensing/LicenseValidation.cs index c322b2cafa..0234dbd5ba 100644 --- a/src/chocolatey/infrastructure/licensing/LicenseValidation.cs +++ b/src/chocolatey/infrastructure/licensing/LicenseValidation.cs @@ -18,6 +18,7 @@ namespace chocolatey.infrastructure.licensing { using System; using System.IO; + using System.Linq; using app; using logging; using Rhino.Licensing; @@ -36,6 +37,8 @@ public static ChocolateyLicense validate() }; var regularLogOutput = determine_if_regular_output_for_logging(); + var normalLogger = regularLogOutput ? ChocolateyLoggers.Normal : ChocolateyLoggers.LogFileOnly; + var importantLogger = regularLogOutput ? ChocolateyLoggers.Important : ChocolateyLoggers.LogFileOnly; string licenseFile = ApplicationParameters.LicenseFileLocation; var userLicenseFile = ApplicationParameters.UserLicenseFileLocation; @@ -53,9 +56,9 @@ public static ChocolateyLicense validate() { if (Directory.GetFiles(licenseDirectory).Length != 0) { - "chocolatey".Log().Error(regularLogOutput ? ChocolateyLoggers.Normal : ChocolateyLoggers.LogFileOnly, @"Files found in directory '{0}' but not a + "chocolatey".Log().Error(normalLogger, @"Files found in directory '{0}' but not a valid license file. License should be named '{1}'.".format_with(licenseDirectory, licenseFileName)); - "chocolatey".Log().Warn(ChocolateyLoggers.Important,@" Rename license file to '{0}' to allow commercial features.".format_with(licenseFileName)); + "chocolatey".Log().Warn(importantLogger,@" Rename license file to '{0}' to allow commercial features.".format_with(licenseFileName)); } } @@ -63,9 +66,9 @@ public static ChocolateyLicense validate() // - user put the license file in the top level location and/or forgot to rename it if (File.Exists(Path.Combine(ApplicationParameters.InstallLocation, licenseFileName)) || File.Exists(Path.Combine(ApplicationParameters.InstallLocation, licenseFileName + ".txt"))) { - "chocolatey".Log().Error(regularLogOutput ? ChocolateyLoggers.Normal : ChocolateyLoggers.LogFileOnly, @"Chocolatey license found in the wrong location. File must be located at + "chocolatey".Log().Error(normalLogger, @"Chocolatey license found in the wrong location. File must be located at '{0}'.".format_with(ApplicationParameters.LicenseFileLocation)); - "chocolatey".Log().Warn(regularLogOutput ? ChocolateyLoggers.Important : ChocolateyLoggers.LogFileOnly, @" Move license file to '{0}' to allow commercial features.".format_with(ApplicationParameters.LicenseFileLocation)); + "chocolatey".Log().Warn(importantLogger, @" Move license file to '{0}' to allow commercial features.".format_with(ApplicationParameters.LicenseFileLocation)); } } @@ -91,7 +94,7 @@ public static ChocolateyLicense validate() { chocolateyLicense.IsValid = false; chocolateyLicense.InvalidReason = e.Message; - "chocolatey".Log().Error(regularLogOutput ? ChocolateyLoggers.Normal : ChocolateyLoggers.LogFileOnly, "A license was not found for a licensed version of Chocolatey:{0} {1}{0} {2}".format_with(Environment.NewLine, e.Message, + "chocolatey".Log().Error(normalLogger, "A license was not found for a licensed version of Chocolatey:{0} {1}{0} {2}".format_with(Environment.NewLine, e.Message, "A license was also not found in the user profile: '{0}'.".format_with(ApplicationParameters.UserLicenseFileLocation))); } catch (Exception e) @@ -99,7 +102,7 @@ public static ChocolateyLicense validate() //license may be invalid chocolateyLicense.IsValid = false; chocolateyLicense.InvalidReason = e.Message; - "chocolatey".Log().Error(regularLogOutput ? ChocolateyLoggers.Normal : ChocolateyLoggers.LogFileOnly, "A license was found for a licensed version of Chocolatey, but is invalid:{0} {1}".format_with(Environment.NewLine, e.Message)); + "chocolatey".Log().Error(normalLogger, "A license was found for a licensed version of Chocolatey, but is invalid:{0} {1}".format_with(Environment.NewLine, e.Message)); } var chocolateyLicenseType = ChocolateyLicenseType.Unknown; @@ -137,12 +140,24 @@ public static ChocolateyLicense validate() private static bool determine_if_regular_output_for_logging() { + var limitOutputArguments = new string[] + { + "--limit-output", + "--limitoutput", + "-r" + }; var args = Environment.GetCommandLineArgs(); + if (args == null || args.Length < 2) return true; var firstArg = args[1].to_string(); if (firstArg.is_equal_to("-v") || firstArg.is_equal_to("--version")) return false; + if (args.Count(argument => limitOutputArguments.Contains(argument)) > 0) + { + return false; + } + return true; } }