diff --git a/src/Build.UnitTests/BinaryLogger_Tests.cs b/src/Build.UnitTests/BinaryLogger_Tests.cs
index 57e2bc3fa82..fa1d53f26a1 100644
--- a/src/Build.UnitTests/BinaryLogger_Tests.cs
+++ b/src/Build.UnitTests/BinaryLogger_Tests.cs
@@ -188,8 +188,8 @@ public void UnusedEnvironmentVariablesDoNotAppearInBinaryLog()
}
}
- [Fact]
- public void AssemblyLoadsDuringTaskRunLogged()
+ [WindowsFullFrameworkOnlyFact(additionalMessage: "Tests if the AppDomain used to load the task is included in the log text for the event, which is true only on Framework.")]
+ public void AssemblyLoadsDuringTaskRunLoggedWithAppDomain()
{
using (TestEnvironment env = TestEnvironment.Create())
{
@@ -201,7 +201,7 @@ public void AssemblyLoadsDuringTaskRunLogged()
TaskFactory="RoslynCodeTaskFactory"
AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.Core.dll" >
-
+
@@ -233,19 +233,88 @@ public void AssemblyLoadsDuringTaskRunLogged()
string assemblyLoadedEventText =
"Assembly loaded during TaskRun (InlineCode.HelloWorld): System.Diagnostics.Debug";
+ string appDomainEventText = "AppDomain: [Default]";
string text = File.ReadAllText(Path.Combine(logFolder.Path, "logFile.log"));
text.ShouldContain(assemblyLoadedEventText);
+ text.ShouldContain(appDomainEventText);
// events should not be in logger with verbosity normal
string text2 = File.ReadAllText(Path.Combine(logFolder.Path, "logFile2.log"));
text2.ShouldNotContain(assemblyLoadedEventText);
+ text2.ShouldNotContain(appDomainEventText);
+ RunnerUtilities.ExecMSBuild($"{logger.Parameters} -flp1:logfile={Path.Combine(logFolder.Path, "logFile3.log")};verbosity=diagnostic -flp2:logfile={Path.Combine(logFolder.Path, "logFile4.log")};verbosity=normal", out success);
+ success.ShouldBeTrue();
+ text = File.ReadAllText(Path.Combine(logFolder.Path, "logFile3.log"));
+ text.ShouldContain(assemblyLoadedEventText);
+ text.ShouldContain(appDomainEventText);
+ // events should not be in logger with verbosity normal
+ text2 = File.ReadAllText(Path.Combine(logFolder.Path, "logFile4.log"));
+ text2.ShouldNotContain(assemblyLoadedEventText);
+ text2.ShouldNotContain(appDomainEventText);
+ }
+ }
+
+ [DotNetOnlyFact(additionalMessage: "Tests if the AssemblyLoadContext used to load the task is included in the log text for the event, which is true only on Core.")]
+ public void AssemblyLoadsDuringTaskRunLoggedWithAssemblyLoadContext()
+ {
+ using (TestEnvironment env = TestEnvironment.Create())
+ {
+ string contents = $"""
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ """;
+ TransientTestFolder logFolder = env.CreateFolder(createFolder: true);
+ TransientTestFile projectFile = env.CreateFile(logFolder, "myProj.proj", contents);
+ BinaryLogger logger = new();
+ logger.Parameters = _logFile;
+ env.SetEnvironmentVariable("MSBUILDNOINPROCNODE", "1");
+ RunnerUtilities.ExecMSBuild($"{projectFile.Path} -nr:False -bl:{logger.Parameters} -flp1:logfile={Path.Combine(logFolder.Path, "logFile.log")};verbosity=diagnostic -flp2:logfile={Path.Combine(logFolder.Path, "logFile2.log")};verbosity=normal", out bool success);
+ success.ShouldBeTrue();
+ string assemblyLoadedEventText =
+ "Assembly loaded during TaskRun (InlineCode.HelloWorld): System.Diagnostics.Debug";
+ string assemblyLoadContextEventText = "AssemblyLoadContext: Default";
+ string text = File.ReadAllText(Path.Combine(logFolder.Path, "logFile.log"));
+ text.ShouldContain(assemblyLoadedEventText);
+ text.ShouldContain(assemblyLoadContextEventText);
+ // events should not be in logger with verbosity normal
+ string text2 = File.ReadAllText(Path.Combine(logFolder.Path, "logFile2.log"));
+ text2.ShouldNotContain(assemblyLoadedEventText);
+ text2.ShouldNotContain(assemblyLoadContextEventText);
RunnerUtilities.ExecMSBuild($"{logger.Parameters} -flp1:logfile={Path.Combine(logFolder.Path, "logFile3.log")};verbosity=diagnostic -flp2:logfile={Path.Combine(logFolder.Path, "logFile4.log")};verbosity=normal", out success);
success.ShouldBeTrue();
text = File.ReadAllText(Path.Combine(logFolder.Path, "logFile3.log"));
text.ShouldContain(assemblyLoadedEventText);
+ text.ShouldContain(assemblyLoadContextEventText);
// events should not be in logger with verbosity normal
text2 = File.ReadAllText(Path.Combine(logFolder.Path, "logFile4.log"));
text2.ShouldNotContain(assemblyLoadedEventText);
+ text2.ShouldNotContain(assemblyLoadContextEventText);
}
}