diff --git a/src/MSBuild.UnitTests/Microsoft.Build.CommandLine.UnitTests.csproj b/src/MSBuild.UnitTests/Microsoft.Build.CommandLine.UnitTests.csproj
index b54e07f48fe..4ba8bcc482e 100644
--- a/src/MSBuild.UnitTests/Microsoft.Build.CommandLine.UnitTests.csproj
+++ b/src/MSBuild.UnitTests/Microsoft.Build.CommandLine.UnitTests.csproj
@@ -67,5 +67,10 @@
+
+
+
+
+
diff --git a/src/MSBuild.UnitTests/TestAssets/MemberAccessException/LoggerProject/CustomLogger.cs b/src/MSBuild.UnitTests/TestAssets/MemberAccessException/LoggerProject/CustomLogger.cs
new file mode 100644
index 00000000000..718abddbc50
--- /dev/null
+++ b/src/MSBuild.UnitTests/TestAssets/MemberAccessException/LoggerProject/CustomLogger.cs
@@ -0,0 +1,25 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Microsoft.Build.Framework;
+
+namespace Microsoft.Build.CommandLine.UnitTests.TestAssets.MemberAccessException.LoggerProject
+{
+ public class CustomLogger : ILogger
+ {
+ private CustomLogger()
+ {
+ Console.WriteLine("Private constructor");
+ }
+
+ public string? Parameters { get; set; }
+ public LoggerVerbosity Verbosity { get; set; }
+ public void Initialize(IEventSource eventSource) { }
+ public void Shutdown() { }
+ }
+}
diff --git a/src/MSBuild.UnitTests/TestAssets/MemberAccessException/LoggerProject/CustomLogger.csproj b/src/MSBuild.UnitTests/TestAssets/MemberAccessException/LoggerProject/CustomLogger.csproj
new file mode 100644
index 00000000000..b845b4a6c0a
--- /dev/null
+++ b/src/MSBuild.UnitTests/TestAssets/MemberAccessException/LoggerProject/CustomLogger.csproj
@@ -0,0 +1,12 @@
+
+
+ netstandard2.0
+ Library
+ CustomLogger
+ artifacts/bin
+ 8.0
+
+
+
+
+
diff --git a/src/MSBuild.UnitTests/TestAssets/TargetInvocationException/LoggerProject/FaultyLogger.cs b/src/MSBuild.UnitTests/TestAssets/TargetInvocationException/LoggerProject/FaultyLogger.cs
new file mode 100644
index 00000000000..40c60116787
--- /dev/null
+++ b/src/MSBuild.UnitTests/TestAssets/TargetInvocationException/LoggerProject/FaultyLogger.cs
@@ -0,0 +1,27 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Microsoft.Build.Framework;
+
+namespace Microsoft.Build.CommandLine.UnitTests.TestAssets.TargetInvocationException.LoggerProject
+{
+ public class FaultyLogger : ILogger
+ {
+ public FaultyLogger()
+ {
+ throw new Exception("Constructor failed intentionally.");
+ }
+
+ public string Parameters { get; set; }
+ public LoggerVerbosity Verbosity { get; set; }
+
+ public void Initialize(IEventSource eventSource) { }
+
+ public void Shutdown() { }
+ }
+}
diff --git a/src/MSBuild.UnitTests/TestAssets/TargetInvocationException/LoggerProject/FaultyLogger.csproj b/src/MSBuild.UnitTests/TestAssets/TargetInvocationException/LoggerProject/FaultyLogger.csproj
new file mode 100644
index 00000000000..b4eb424074c
--- /dev/null
+++ b/src/MSBuild.UnitTests/TestAssets/TargetInvocationException/LoggerProject/FaultyLogger.csproj
@@ -0,0 +1,12 @@
+
+
+ netstandard2.0
+ Library
+ FaultyLogger
+ artifacts/bin
+ 8.0
+
+
+
+
+
diff --git a/src/MSBuild.UnitTests/XMake_Tests.cs b/src/MSBuild.UnitTests/XMake_Tests.cs
index b18eb45c346..836c3dab0ab 100644
--- a/src/MSBuild.UnitTests/XMake_Tests.cs
+++ b/src/MSBuild.UnitTests/XMake_Tests.cs
@@ -20,6 +20,7 @@
using Microsoft.Build.Shared;
using Microsoft.Build.UnitTests.Shared;
using Microsoft.Build.Utilities;
+using Microsoft.VisualStudio.TestPlatform.Utilities;
using Shouldly;
using Xunit;
using Xunit.Abstractions;
@@ -45,6 +46,8 @@ public XMakeAppTests(ITestOutputHelper output)
_env = UnitTests.TestEnvironment.Create(_output);
}
+ private static string TestAssetsRootPath { get; } = Path.Combine(Path.Combine(Path.GetDirectoryName(typeof(XMakeAppTests).Assembly.Location) ?? AppContext.BaseDirectory), "TestAssets");
+
private const string AutoResponseFileName = "MSBuild.rsp";
[Fact]
@@ -2490,6 +2493,99 @@ public void MissingOptionalLoggersAreIgnored(string logger, string expectedLogge
output.ShouldContain($"The specified logger \"{expectedLoggerName}\" could not be created and will not be used.", customMessage: output);
}
+ [Theory]
+ [InlineData("-logger:,CustomLogger.dll", "CustomLogger.dll")]
+ [InlineData("-logger:,Logger.dll", "Logger.dll")]
+ public void LoggerThrowsIOExceptionWhenDllNotFound(string logger, string expectedLoggerName)
+ {
+ string projectString ="";
+ var tempDir = _env.CreateFolder();
+ var projectFile = tempDir.CreateFile("iologgertest.proj", projectString);
+
+ var parametersLogger = $"{logger} -verbosity:diagnostic \"{projectFile.Path}\"";
+
+ var output = RunnerUtilities.ExecMSBuild(parametersLogger, out bool successfulExit, _output);
+ successfulExit.ShouldBe(false);
+
+ output.ShouldContain($"Cannot create an instance of the logger {expectedLoggerName}.", customMessage: output);
+ }
+
+ [Theory]
+ [InlineData("-logger:,BadFile.dll", "BadFile.dll")]
+ [InlineData("-distributedlogger:,BadFile.dll", "BadFile.dll")]
+ public void LoggerThrowsBadImageFormatExceptionWhenFileIsInvalid(string logger, string expectedLoggerName)
+ {
+ string projectString ="";
+ var tempDir = _env.CreateFolder();
+ var projectFile = tempDir.CreateFile("badimagetest.proj", projectString);
+
+ var dllFilePath = Path.Combine(tempDir.Path, expectedLoggerName);
+ File.WriteAllText(dllFilePath, "Invalid content, not a valid .NET assembly.");
+
+ var loggerParam = $"\"{logger}\"";
+ var parametersLogger = $"{loggerParam} -verbosity:diagnostic \"{projectFile.Path}\"";
+
+ var output = RunnerUtilities.ExecMSBuild(parametersLogger, out bool successfulExit, _output);
+ successfulExit.ShouldBe(false);
+
+ output.ShouldContain($"Cannot create an instance of the logger {expectedLoggerName}.", customMessage: output);
+ }
+
+ [Theory]
+ [InlineData("MemberAccessException", "-logger:,", "CustomLogger.dll")]
+ [InlineData("MemberAccessException", "-distributedlogger:,", "CustomLogger.dll")]
+ public void LoggerThrowsMemberAccessExceptionWhenClassIsInvalid(string memberAccess, string loggerTemplate, string expectedLoggerName)
+ {
+ using (var env = TestEnvironment.Create())
+ {
+ string projectContent = "";
+ var tempDir = _env.CreateFolder();
+
+ (string projectFilePath, string tempLoggerProjDir) = CopyTestAssetsToTestEnv(tempDir, projectContent, memberAccess);
+
+ string loggerBuildLog = RunnerUtilities.ExecBootstrapedMSBuild(
+ $"\"{Path.Combine(tempLoggerProjDir, "CustomLogger.csproj")}\" -restore -verbosity:n", out bool success);
+
+ var loggerDllPath = Path.Combine(tempLoggerProjDir, "artifacts", "bin", "netstandard2.0", expectedLoggerName);
+ var loggerSwitch = $"{loggerTemplate}\"{loggerDllPath}\"";
+ var mainBuildParameters = $"\"{projectFilePath}\" -restore {loggerSwitch} -verbosity:diagnostic";
+
+ string mainBuildLog = RunnerUtilities.ExecBootstrapedMSBuild(
+ mainBuildParameters,
+ out bool successfulExit);
+
+ mainBuildLog.ShouldContain($"Cannot create an instance of the logger {loggerDllPath}.", customMessage: mainBuildLog);
+ }
+ }
+
+ [Theory]
+ [InlineData("TargetInvocationException", "-logger:,", "FaultyLogger.dll")]
+ [InlineData("TargetInvocationException", "-distributedlogger:,", "FaultyLogger.dll")]
+ public void LoggerThrowsTargetInvocationException(string targetInvocation, string loggerTemplate, string expectedLoggerName)
+ {
+ using (var env = TestEnvironment.Create())
+ {
+ string projectContent = "";
+ var tempDir = _env.CreateFolder();
+
+ (string projectFilePath, string tempLoggerProjDir) = CopyTestAssetsToTestEnv(tempDir, projectContent, targetInvocation);
+
+ string loggerBuildLog = RunnerUtilities.ExecBootstrapedMSBuild(
+ $"{Path.Combine(tempLoggerProjDir, $"FaultyLogger.csproj")} -restore -verbosity:n", out bool success);
+
+ var loggerDllPath = Path.Combine(tempLoggerProjDir, "artifacts", "bin", "netstandard2.0", expectedLoggerName);
+ var loggerSwitch = $"{loggerTemplate}{loggerDllPath}";
+ var mainBuildParameters = $"{projectFilePath} -restore {loggerSwitch} -verbosity:diagnostic";
+
+ string mainBuildLog = RunnerUtilities.ExecBootstrapedMSBuild(
+ mainBuildParameters,
+ out bool successfulExit);
+
+ successfulExit.ShouldBeFalse(mainBuildLog);
+ mainBuildLog.ShouldContain("The logger failed unexpectedly.");
+ }
+ }
+
[Theory]
[InlineData("/interactive")]
[InlineData("/p:NuGetInteractive=true")]
@@ -2849,6 +2945,26 @@ private string ExecuteMSBuildExeExpectFailure(string projectContents, IDictionar
return (success, output);
}
+ private (string projectFilePath, string tempLoggerProjDir) CopyTestAssetsToTestEnv(TransientTestFolder tempDir, string projectContent, string folderName)
+ {
+ var testAssetsPath = Path.Combine(TestAssetsRootPath, folderName);
+ var loggerProjDir = Path.Combine(testAssetsPath, "LoggerProject");
+
+ var projectFile = tempDir.CreateFile("loggerproject.proj", projectContent);
+
+ var tempLoggerProjDir = Path.Combine(tempDir.Path, "LoggerProject");
+ Directory.CreateDirectory(tempLoggerProjDir);
+
+ foreach (var file in Directory.GetFiles(loggerProjDir, "*.*", SearchOption.AllDirectories))
+ {
+ var relativePath = file.Substring(loggerProjDir.Length + 1);
+ var destPath = Path.Combine(tempLoggerProjDir, relativePath);
+ Directory.CreateDirectory(Path.GetDirectoryName(destPath));
+ File.Copy(file, destPath, true);
+ }
+ return (projectFile.Path, tempLoggerProjDir);
+ }
+
public void Dispose()
{
_env.Dispose();
diff --git a/src/MSBuild/InitializationException.cs b/src/MSBuild/InitializationException.cs
index 2d1153029b7..10085941093 100644
--- a/src/MSBuild/InitializationException.cs
+++ b/src/MSBuild/InitializationException.cs
@@ -157,6 +157,28 @@ internal static void Throw(string messageResourceName, string invalidSwitch, Exc
InitializationException.Throw(errorMessage, invalidSwitch);
}
+ ///
+ /// Throws the exception using the given exception context and can include the logger name.
+ ///
+ internal static void Throw(string messageResourceName, string invalidSwitch, Exception e, bool showStackTrace, params object[] formatArgs)
+ {
+ string errorMessage = AssemblyResources.GetString(messageResourceName);
+
+ ErrorUtilities.VerifyThrow(errorMessage != null, "The resource string must exist.");
+
+ // the exception message can contain a format item i.e.
+ // "{0}" to hold the logger name
+ // "{1}" to hold the given exception's message
+ errorMessage = ResourceUtilities.FormatString(errorMessage, formatArgs);
+
+ if (showStackTrace && e != null)
+ {
+ errorMessage += Environment.NewLine + e.ToString();
+ }
+
+ InitializationException.Throw(errorMessage, invalidSwitch);
+ }
+
///
/// Throws the exception if the specified condition is not met.
///
diff --git a/src/MSBuild/Resources/Strings.resx b/src/MSBuild/Resources/Strings.resx
index 17649c98a14..9e4c6709288 100644
--- a/src/MSBuild/Resources/Strings.resx
+++ b/src/MSBuild/Resources/Strings.resx
@@ -1513,7 +1513,7 @@
{StrBegin="MSBUILD : error MSB1059: "}
- MSBUILD : error MSB1021: Cannot create an instance of the logger. {0}
+ MSBUILD : error MSB1021: Cannot create an instance of the logger {0}. {1}{StrBegin="MSBUILD : error MSB1021: "}
UE: This error is shown when a logger cannot be loaded and instantiated from its assembly.
LOCALIZATION: The prefix "MSBUILD : error MSBxxxx:" should not be localized. {0} contains a message explaining why the
diff --git a/src/MSBuild/Resources/xlf/Strings.cs.xlf b/src/MSBuild/Resources/xlf/Strings.cs.xlf
index fd23839785c..ec513eb30c7 100644
--- a/src/MSBuild/Resources/xlf/Strings.cs.xlf
+++ b/src/MSBuild/Resources/xlf/Strings.cs.xlf
@@ -2205,8 +2205,8 @@ Když se nastaví na MessageUponIsolationViolation (nebo jeho krátký
- MSBUILD : error MSB1021: Cannot create an instance of the logger. {0}
- MSBUILD : error MSB1021: Nelze vytvořit instanci protokolovacího nástroje. {0}
+ MSBUILD : error MSB1021: Cannot create an instance of the logger {0}. {1}
+ MSBUILD : error MSB1021: Cannot create an instance of the logger {0}. {1}{StrBegin="MSBUILD : error MSB1021: "}
UE: This error is shown when a logger cannot be loaded and instantiated from its assembly.
LOCALIZATION: The prefix "MSBUILD : error MSBxxxx:" should not be localized. {0} contains a message explaining why the
diff --git a/src/MSBuild/Resources/xlf/Strings.de.xlf b/src/MSBuild/Resources/xlf/Strings.de.xlf
index f59cb4260d4..cade416a977 100644
--- a/src/MSBuild/Resources/xlf/Strings.de.xlf
+++ b/src/MSBuild/Resources/xlf/Strings.de.xlf
@@ -2193,8 +2193,8 @@ Dieses Protokollierungsformat ist standardmäßig aktiviert.
- MSBUILD : error MSB1021: Cannot create an instance of the logger. {0}
- MSBUILD : error MSB1021: Eine Instanz der Protokollierung kann nicht erzeugt werden. {0}
+ MSBUILD : error MSB1021: Cannot create an instance of the logger {0}. {1}
+ MSBUILD : error MSB1021: Cannot create an instance of the logger {0}. {1}{StrBegin="MSBUILD : error MSB1021: "}
UE: This error is shown when a logger cannot be loaded and instantiated from its assembly.
LOCALIZATION: The prefix "MSBUILD : error MSBxxxx:" should not be localized. {0} contains a message explaining why the
diff --git a/src/MSBuild/Resources/xlf/Strings.es.xlf b/src/MSBuild/Resources/xlf/Strings.es.xlf
index 61b6c952e98..1ccd3966708 100644
--- a/src/MSBuild/Resources/xlf/Strings.es.xlf
+++ b/src/MSBuild/Resources/xlf/Strings.es.xlf
@@ -2197,8 +2197,8 @@ Esta marca es experimental y puede que no funcione según lo previsto.
- MSBUILD : error MSB1021: Cannot create an instance of the logger. {0}
- MSBUILD : error MSB1021: No se puede crear una instancia del registrador. {0}
+ MSBUILD : error MSB1021: Cannot create an instance of the logger {0}. {1}
+ MSBUILD : error MSB1021: Cannot create an instance of the logger {0}. {1}{StrBegin="MSBUILD : error MSB1021: "}
UE: This error is shown when a logger cannot be loaded and instantiated from its assembly.
LOCALIZATION: The prefix "MSBUILD : error MSBxxxx:" should not be localized. {0} contains a message explaining why the
diff --git a/src/MSBuild/Resources/xlf/Strings.fr.xlf b/src/MSBuild/Resources/xlf/Strings.fr.xlf
index ca4e4e37fdb..5bf8a4371dd 100644
--- a/src/MSBuild/Resources/xlf/Strings.fr.xlf
+++ b/src/MSBuild/Resources/xlf/Strings.fr.xlf
@@ -2194,8 +2194,8 @@ Remarque : verbosité des enregistreurs d’événements de fichiers
- MSBUILD : error MSB1021: Cannot create an instance of the logger. {0}
- MSBUILD : error MSB1021: Impossible de créer une instance du journal. {0}
+ MSBUILD : error MSB1021: Cannot create an instance of the logger {0}. {1}
+ MSBUILD : error MSB1021: Cannot create an instance of the logger {0}. {1}{StrBegin="MSBUILD : error MSB1021: "}
UE: This error is shown when a logger cannot be loaded and instantiated from its assembly.
LOCALIZATION: The prefix "MSBUILD : error MSBxxxx:" should not be localized. {0} contains a message explaining why the
diff --git a/src/MSBuild/Resources/xlf/Strings.it.xlf b/src/MSBuild/Resources/xlf/Strings.it.xlf
index 4757e078ddb..a65d1602b75 100644
--- a/src/MSBuild/Resources/xlf/Strings.it.xlf
+++ b/src/MSBuild/Resources/xlf/Strings.it.xlf
@@ -2210,8 +2210,8 @@ Esegue la profilatura della valutazione di MSBuild e scrive
- MSBUILD : error MSB1021: Cannot create an instance of the logger. {0}
- MSBUILD : error MSB1021: non è possibile creare un'istanza del logger. {0}
+ MSBUILD : error MSB1021: Cannot create an instance of the logger {0}. {1}
+ MSBUILD : error MSB1021: Cannot create an instance of the logger {0}. {1}{StrBegin="MSBUILD : error MSB1021: "}
UE: This error is shown when a logger cannot be loaded and instantiated from its assembly.
LOCALIZATION: The prefix "MSBUILD : error MSBxxxx:" should not be localized. {0} contains a message explaining why the
diff --git a/src/MSBuild/Resources/xlf/Strings.ja.xlf b/src/MSBuild/Resources/xlf/Strings.ja.xlf
index 363f80a302a..bd12258da85 100644
--- a/src/MSBuild/Resources/xlf/Strings.ja.xlf
+++ b/src/MSBuild/Resources/xlf/Strings.ja.xlf
@@ -2193,8 +2193,8 @@
- MSBUILD : error MSB1021: Cannot create an instance of the logger. {0}
- MSBUILD : error MSB1021: Logger のインスタンスを作成できません。{0}
+ MSBUILD : error MSB1021: Cannot create an instance of the logger {0}. {1}
+ MSBUILD : error MSB1021: Cannot create an instance of the logger {0}. {1}{StrBegin="MSBUILD : error MSB1021: "}
UE: This error is shown when a logger cannot be loaded and instantiated from its assembly.
LOCALIZATION: The prefix "MSBUILD : error MSBxxxx:" should not be localized. {0} contains a message explaining why the
diff --git a/src/MSBuild/Resources/xlf/Strings.ko.xlf b/src/MSBuild/Resources/xlf/Strings.ko.xlf
index 5da5d3a7cac..84d5b560333 100644
--- a/src/MSBuild/Resources/xlf/Strings.ko.xlf
+++ b/src/MSBuild/Resources/xlf/Strings.ko.xlf
@@ -2193,8 +2193,8 @@
- MSBUILD : error MSB1021: Cannot create an instance of the logger. {0}
- MSBUILD : error MSB1021: 로거의 인스턴스를 만들 수 없습니다. {0}
+ MSBUILD : error MSB1021: Cannot create an instance of the logger {0}. {1}
+ MSBUILD : error MSB1021: Cannot create an instance of the logger {0}. {1}{StrBegin="MSBUILD : error MSB1021: "}
UE: This error is shown when a logger cannot be loaded and instantiated from its assembly.
LOCALIZATION: The prefix "MSBUILD : error MSBxxxx:" should not be localized. {0} contains a message explaining why the
diff --git a/src/MSBuild/Resources/xlf/Strings.pl.xlf b/src/MSBuild/Resources/xlf/Strings.pl.xlf
index 5e2ee08a6ca..70f6b54059c 100644
--- a/src/MSBuild/Resources/xlf/Strings.pl.xlf
+++ b/src/MSBuild/Resources/xlf/Strings.pl.xlf
@@ -2203,8 +2203,8 @@ Ta flaga jest eksperymentalna i może nie działać zgodnie z oczekiwaniami.
- MSBUILD : error MSB1021: Cannot create an instance of the logger. {0}
- MSBUILD : error MSB1021: nie można utworzyć wystąpienia rejestratora. {0}
+ MSBUILD : error MSB1021: Cannot create an instance of the logger {0}. {1}
+ MSBUILD : error MSB1021: Cannot create an instance of the logger {0}. {1}{StrBegin="MSBUILD : error MSB1021: "}
UE: This error is shown when a logger cannot be loaded and instantiated from its assembly.
LOCALIZATION: The prefix "MSBUILD : error MSBxxxx:" should not be localized. {0} contains a message explaining why the
diff --git a/src/MSBuild/Resources/xlf/Strings.pt-BR.xlf b/src/MSBuild/Resources/xlf/Strings.pt-BR.xlf
index d24483156db..f46b5d5c17f 100644
--- a/src/MSBuild/Resources/xlf/Strings.pt-BR.xlf
+++ b/src/MSBuild/Resources/xlf/Strings.pt-BR.xlf
@@ -2193,8 +2193,8 @@ arquivo de resposta.
- MSBUILD : error MSB1021: Cannot create an instance of the logger. {0}
- MSBUILD : error MSB1021: Não é possível criar instância do agente de log. {0}
+ MSBUILD : error MSB1021: Cannot create an instance of the logger {0}. {1}
+ MSBUILD : error MSB1021: Cannot create an instance of the logger {0}. {1}{StrBegin="MSBUILD : error MSB1021: "}
UE: This error is shown when a logger cannot be loaded and instantiated from its assembly.
LOCALIZATION: The prefix "MSBUILD : error MSBxxxx:" should not be localized. {0} contains a message explaining why the
diff --git a/src/MSBuild/Resources/xlf/Strings.ru.xlf b/src/MSBuild/Resources/xlf/Strings.ru.xlf
index f0de6f4d4bd..f6191ff318e 100644
--- a/src/MSBuild/Resources/xlf/Strings.ru.xlf
+++ b/src/MSBuild/Resources/xlf/Strings.ru.xlf
@@ -2193,8 +2193,8 @@
- MSBUILD : error MSB1021: Cannot create an instance of the logger. {0}
- MSBUILD : error MSB1021: не удается создать экземпляр журнала. {0}
+ MSBUILD : error MSB1021: Cannot create an instance of the logger {0}. {1}
+ MSBUILD : error MSB1021: Cannot create an instance of the logger {0}. {1}{StrBegin="MSBUILD : error MSB1021: "}
UE: This error is shown when a logger cannot be loaded and instantiated from its assembly.
LOCALIZATION: The prefix "MSBUILD : error MSBxxxx:" should not be localized. {0} contains a message explaining why the
diff --git a/src/MSBuild/Resources/xlf/Strings.tr.xlf b/src/MSBuild/Resources/xlf/Strings.tr.xlf
index 020b4a91f03..3cbc2c0aca6 100644
--- a/src/MSBuild/Resources/xlf/Strings.tr.xlf
+++ b/src/MSBuild/Resources/xlf/Strings.tr.xlf
@@ -2196,8 +2196,8 @@
- MSBUILD : error MSB1021: Cannot create an instance of the logger. {0}
- MSBUILD : error MSB1021: Günlük oluşturucunun bir örneği oluşturulamıyor. {0}
+ MSBUILD : error MSB1021: Cannot create an instance of the logger {0}. {1}
+ MSBUILD : error MSB1021: Cannot create an instance of the logger {0}. {1}{StrBegin="MSBUILD : error MSB1021: "}
UE: This error is shown when a logger cannot be loaded and instantiated from its assembly.
LOCALIZATION: The prefix "MSBUILD : error MSBxxxx:" should not be localized. {0} contains a message explaining why the
diff --git a/src/MSBuild/Resources/xlf/Strings.zh-Hans.xlf b/src/MSBuild/Resources/xlf/Strings.zh-Hans.xlf
index cd21bf6716b..b06b0d302e3 100644
--- a/src/MSBuild/Resources/xlf/Strings.zh-Hans.xlf
+++ b/src/MSBuild/Resources/xlf/Strings.zh-Hans.xlf
@@ -2195,8 +2195,8 @@
- MSBUILD : error MSB1021: Cannot create an instance of the logger. {0}
- MSBUILD : error MSB1021: 无法创建记录器的实例。{0}
+ MSBUILD : error MSB1021: Cannot create an instance of the logger {0}. {1}
+ MSBUILD : error MSB1021: Cannot create an instance of the logger {0}. {1}{StrBegin="MSBUILD : error MSB1021: "}
UE: This error is shown when a logger cannot be loaded and instantiated from its assembly.
LOCALIZATION: The prefix "MSBUILD : error MSBxxxx:" should not be localized. {0} contains a message explaining why the
diff --git a/src/MSBuild/Resources/xlf/Strings.zh-Hant.xlf b/src/MSBuild/Resources/xlf/Strings.zh-Hant.xlf
index 9fda517625b..91d450fda42 100644
--- a/src/MSBuild/Resources/xlf/Strings.zh-Hant.xlf
+++ b/src/MSBuild/Resources/xlf/Strings.zh-Hant.xlf
@@ -2193,8 +2193,8 @@
- MSBUILD : error MSB1021: Cannot create an instance of the logger. {0}
- MSBUILD : error MSB1021: 無法建立記錄器的執行個體。{0}
+ MSBUILD : error MSB1021: Cannot create an instance of the logger {0}. {1}
+ MSBUILD : error MSB1021: Cannot create an instance of the logger {0}. {1}{StrBegin="MSBUILD : error MSB1021: "}
UE: This error is shown when a logger cannot be loaded and instantiated from its assembly.
LOCALIZATION: The prefix "MSBUILD : error MSBxxxx:" should not be localized. {0} contains a message explaining why the
diff --git a/src/MSBuild/XMake.cs b/src/MSBuild/XMake.cs
index f9006a5b5b2..8b1aa79fd59 100644
--- a/src/MSBuild/XMake.cs
+++ b/src/MSBuild/XMake.cs
@@ -4435,7 +4435,6 @@ private static bool CreateAndConfigureLogger(
out ILogger logger)
{
logger = null;
-
try
{
logger = loggerDescription.CreateLogger();
@@ -4444,23 +4443,23 @@ private static bool CreateAndConfigureLogger(
}
catch (IOException e) when (!loggerDescription.IsOptional)
{
- InitializationException.Throw("XMake.LoggerCreationError", unquotedParameter, e, false);
+ InitializationException.Throw("XMake.LoggerCreationError", unquotedParameter, e, false, [loggerDescription.Name, (e == null) ? String.Empty : e.Message]);
}
catch (BadImageFormatException e) when (!loggerDescription.IsOptional)
{
- InitializationException.Throw("XMake.LoggerCreationError", unquotedParameter, e, false);
+ InitializationException.Throw("XMake.LoggerCreationError", unquotedParameter, e, false, [loggerDescription.Name, (e == null) ? String.Empty : e.Message]);
}
catch (SecurityException e) when (!loggerDescription.IsOptional)
{
- InitializationException.Throw("XMake.LoggerCreationError", unquotedParameter, e, false);
+ InitializationException.Throw("XMake.LoggerCreationError", unquotedParameter, e, false, [loggerDescription.Name, (e == null) ? String.Empty : e.Message]);
}
catch (ReflectionTypeLoadException e) when (!loggerDescription.IsOptional)
{
- InitializationException.Throw("XMake.LoggerCreationError", unquotedParameter, e, false);
+ InitializationException.Throw("XMake.LoggerCreationError", unquotedParameter, e, false, [loggerDescription.Name, (e == null) ? String.Empty : e.Message]);
}
catch (MemberAccessException e) when (!loggerDescription.IsOptional)
{
- InitializationException.Throw("XMake.LoggerCreationError", unquotedParameter, e, false);
+ InitializationException.Throw("XMake.LoggerCreationError", unquotedParameter, e, false, [loggerDescription.Name, (e == null) ? String.Empty : e.Message]);
}
catch (TargetInvocationException e) when (!loggerDescription.IsOptional)
{