From 31c5c6b4e3559fc85ec79dd7370229dcb36f71eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mariana=20Dematt=C3=A9?= Date: Thu, 21 Dec 2023 14:56:59 +0100 Subject: [PATCH 1/4] Wait for logger to flush mesages before shutting down --- src/Build/Definition/ProjectCollection.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Build/Definition/ProjectCollection.cs b/src/Build/Definition/ProjectCollection.cs index 924b3e25db7..11dd0a1143d 100644 --- a/src/Build/Definition/ProjectCollection.cs +++ b/src/Build/Definition/ProjectCollection.cs @@ -11,6 +11,7 @@ using System.Threading; using System.Xml; using Microsoft.Build.BackEnd; +using Microsoft.Build.BackEnd.Logging; using Microsoft.Build.Collections; using Microsoft.Build.Construction; using Microsoft.Build.Execution; @@ -1732,6 +1733,7 @@ private void ShutDownLoggingService() { try { + (LoggingService as LoggingService)?.WaitForLoggingToProcessEvents(); ((IBuildComponent)LoggingService).ShutdownComponent(); } catch (LoggerException) From 42cd1331086b5204cbef8628b8462b93cacbfc64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mariana=20Dematt=C3=A9?= Date: Thu, 21 Dec 2023 19:13:54 +0100 Subject: [PATCH 2/4] Added a small test to make sure log is returning --- MSBuild.Dev.slnf | 4 ++-- src/MSBuild.UnitTests/XMake_Tests.cs | 16 ++++++++++++++++ src/MSBuild/XMake.cs | 1 + 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/MSBuild.Dev.slnf b/MSBuild.Dev.slnf index 4ae636a74a6..61214ba22cc 100644 --- a/MSBuild.Dev.slnf +++ b/MSBuild.Dev.slnf @@ -9,12 +9,12 @@ "src\\Framework\\Microsoft.Build.Framework.csproj", "src\\MSBuild.UnitTests\\Microsoft.Build.CommandLine.UnitTests.csproj", "src\\MSBuild\\MSBuild.csproj", + "src\\StringTools\\StringTools.csproj", "src\\Tasks.UnitTests\\Microsoft.Build.Tasks.UnitTests.csproj", "src\\Tasks\\Microsoft.Build.Tasks.csproj", "src\\Utilities.UnitTests\\Microsoft.Build.Utilities.UnitTests.csproj", "src\\Utilities\\Microsoft.Build.Utilities.csproj", - "src\\Xunit.NetCore.Extensions\\Xunit.NetCore.Extensions.csproj", - "src\\StringTools\\StringTools.csproj" + "src\\Xunit.NetCore.Extensions\\Xunit.NetCore.Extensions.csproj" ] } } \ No newline at end of file diff --git a/src/MSBuild.UnitTests/XMake_Tests.cs b/src/MSBuild.UnitTests/XMake_Tests.cs index c18c5ad2d90..5e277e89e0b 100644 --- a/src/MSBuild.UnitTests/XMake_Tests.cs +++ b/src/MSBuild.UnitTests/XMake_Tests.cs @@ -793,6 +793,22 @@ public void ExecuteAppWithGetPropertyItemAndTargetResult( results.ShouldNotContain(ResourceUtilities.GetResourceString("BuildFailedWithPropertiesItemsOrTargetResultsRequested")); } + [Fact] + public void BuildFailsWithBadPropertyName() + { + using TestEnvironment env = TestEnvironment.Create(); + TransientTestFile project = env.CreateFile("testProject.csproj", @" + + + + +"); + string results = RunnerUtilities.ExecMSBuild($" {project.Path} /p:someProperty:fdalse= ", out bool success); + success.ShouldBeFalse(results); + + results.ShouldContain("error MSB4177: Invalid property."); + } + [Theory] [InlineData(true)] [InlineData(false)] diff --git a/src/MSBuild/XMake.cs b/src/MSBuild/XMake.cs index 0210df145df..235fc68b4fb 100644 --- a/src/MSBuild/XMake.cs +++ b/src/MSBuild/XMake.cs @@ -633,6 +633,7 @@ public static ExitType Execute( string[] commandLine) #endif { + Debugger.Launch(); DebuggerLaunchCheck(); // Initialize new build telemetry and record start of this build, if not initialized already From 6433fed983b18f4b66d44ddd46a74ff764947c33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mariana=20Dematt=C3=A9?= Date: Thu, 21 Dec 2023 19:32:20 +0100 Subject: [PATCH 3/4] Commit some stuff that should not go --- MSBuild.Dev.slnf | 4 ++-- src/MSBuild/XMake.cs | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/MSBuild.Dev.slnf b/MSBuild.Dev.slnf index 61214ba22cc..4ae636a74a6 100644 --- a/MSBuild.Dev.slnf +++ b/MSBuild.Dev.slnf @@ -9,12 +9,12 @@ "src\\Framework\\Microsoft.Build.Framework.csproj", "src\\MSBuild.UnitTests\\Microsoft.Build.CommandLine.UnitTests.csproj", "src\\MSBuild\\MSBuild.csproj", - "src\\StringTools\\StringTools.csproj", "src\\Tasks.UnitTests\\Microsoft.Build.Tasks.UnitTests.csproj", "src\\Tasks\\Microsoft.Build.Tasks.csproj", "src\\Utilities.UnitTests\\Microsoft.Build.Utilities.UnitTests.csproj", "src\\Utilities\\Microsoft.Build.Utilities.csproj", - "src\\Xunit.NetCore.Extensions\\Xunit.NetCore.Extensions.csproj" + "src\\Xunit.NetCore.Extensions\\Xunit.NetCore.Extensions.csproj", + "src\\StringTools\\StringTools.csproj" ] } } \ No newline at end of file diff --git a/src/MSBuild/XMake.cs b/src/MSBuild/XMake.cs index 235fc68b4fb..0210df145df 100644 --- a/src/MSBuild/XMake.cs +++ b/src/MSBuild/XMake.cs @@ -633,7 +633,6 @@ public static ExitType Execute( string[] commandLine) #endif { - Debugger.Launch(); DebuggerLaunchCheck(); // Initialize new build telemetry and record start of this build, if not initialized already From 99b62a104aafba1776fb592833ac7fd5847d1f05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mariana=20Dematt=C3=A9?= Date: Thu, 4 Jan 2024 13:38:36 +0100 Subject: [PATCH 4/4] Removed localized message lookup --- src/MSBuild.UnitTests/XMake_Tests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/MSBuild.UnitTests/XMake_Tests.cs b/src/MSBuild.UnitTests/XMake_Tests.cs index 5e277e89e0b..33c482df035 100644 --- a/src/MSBuild.UnitTests/XMake_Tests.cs +++ b/src/MSBuild.UnitTests/XMake_Tests.cs @@ -806,7 +806,7 @@ public void BuildFailsWithBadPropertyName() string results = RunnerUtilities.ExecMSBuild($" {project.Path} /p:someProperty:fdalse= ", out bool success); success.ShouldBeFalse(results); - results.ShouldContain("error MSB4177: Invalid property."); + results.ShouldContain("error MSB4177"); } [Theory]