diff --git a/eng/Versions.props b/eng/Versions.props index 53ac7db1ee0..fede78d61e9 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -2,7 +2,7 @@ - 17.14.32 + 17.14.33 release 17.13.9 15.1.0.0 diff --git a/src/Build.UnitTests/BackEnd/DotNetTaskHost_Tests.cs b/src/Build.UnitTests/BackEnd/DotNetTaskHost_Tests.cs new file mode 100644 index 00000000000..b4b54a0a9c4 --- /dev/null +++ b/src/Build.UnitTests/BackEnd/DotNetTaskHost_Tests.cs @@ -0,0 +1,62 @@ +// 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.IO; +using Microsoft.Build.Execution; +using Microsoft.Build.UnitTests; +using Shouldly; +using Xunit; +using Xunit.Abstractions; + +namespace Microsoft.Build.Engine.UnitTests.BackEnd +{ + /// + /// End-to-end MSBuild CLI tests for .NET Runtime task error handling. + /// These tests verify that MSBuild.exe CLI gives a clear error when attempting to use Runtime="NET" tasks. + /// + public class DotNetTaskHost_Tests + { + private readonly ITestOutputHelper _output; + + public DotNetTaskHost_Tests(ITestOutputHelper output) + { + _output = output; + } + + /// + /// Test that MSBuild.exe gives clear error (MSB4233) when building a project + /// that uses a task with Runtime="NET". + /// + [WindowsFullFrameworkOnlyFact] + public void CustomTask_WithNetRuntime_ShowsClearError() + { +#if NETFRAMEWORK + using (var env = TestEnvironment.Create(_output)) + { + string taskAssemblyPath = Path.Combine( + Path.GetDirectoryName(typeof(DotNetTaskHost_Tests).Assembly.Location) ?? AppContext.BaseDirectory, + "Microsoft.Build.Engine.UnitTests.dll"); + + string projectContent = $@" + + + + + + + +"; + var logger = new MockLogger(_output); + TransientTestFile project = env.CreateFile("test.csproj", projectContent); + ProjectInstance projectInstance = new(project.Path); + projectInstance.Build(new[] { logger }) + .ShouldBeFalse(); + + logger.ErrorCount.ShouldBeGreaterThan(0); + logger.Errors[0].Code.ShouldBe("MSB4233"); + } +#endif + } + } +} diff --git a/src/Build/BackEnd/Components/Communications/NodeProviderOutOfProcTaskHost.cs b/src/Build/BackEnd/Components/Communications/NodeProviderOutOfProcTaskHost.cs index 1d0f0f525d3..94a437947cc 100644 --- a/src/Build/BackEnd/Components/Communications/NodeProviderOutOfProcTaskHost.cs +++ b/src/Build/BackEnd/Components/Communications/NodeProviderOutOfProcTaskHost.cs @@ -486,6 +486,20 @@ internal static string GetMSBuildLocationFromHostContext(HandshakeOptions hostCo /// internal bool AcquireAndSetUpHost(HandshakeOptions hostContext, INodePacketFactory factory, INodePacketHandler handler, TaskHostConfiguration configuration) { +#if NETFRAMEWORK + // MSB4233: Check if .NET runtime is requested, which is not supported in .NET Framework builds of MSBuild (17.14 and earlier). + // All .NET Core/5+ MSBuilds and all 18.0+ builds do support .NET runtime tasks, so this check is not needed there. + // This provides a clear error message instead of the confusing "MSBuild.dll not found" error that would otherwise occur. + if ((hostContext & HandshakeOptions.NET) == HandshakeOptions.NET) + { + ProjectFileErrorUtilities.ThrowInvalidProjectFile( + new BuildEventFileInfo(configuration.ProjectFileOfTask, configuration.LineNumberOfTask, configuration.ColumnNumberOfTask), + "TaskRuntimeNET", + configuration.TaskName, + configuration.TaskLocation); + } +#endif + bool nodeCreationSucceeded; if (!_nodeContexts.ContainsKey(hostContext)) { diff --git a/src/Build/Resources/Strings.resx b/src/Build/Resources/Strings.resx index 88b068552be..4680be05c27 100644 --- a/src/Build/Resources/Strings.resx +++ b/src/Build/Resources/Strings.resx @@ -1238,6 +1238,10 @@ MSB4217: Task host node exited prematurely. Diagnostic information may be found in files in the temporary files directory named MSBuild_*.failure.txt. {0} {StrBegin="MSB4217: "} + + MSB4233: The task "{0}" from assembly "{1}" was specified to load with the .NET runtime, but this version of MSBuild does not support loading tasks with that runtime. To run .NET tasks, use "dotnet build" or Visual Studio 2026 or higher. + {StrBegin="MSB4233: "}{Locked=".NET"}{Locked="dotnet build"}{Locked="Visual Studio 2026"}LOCALIZATION: .NET, dotnet build, and Visual Studio 2026 should not be localized. + MSB4063: The "{0}" task could not be initialized with its input parameters. {1} {StrBegin="MSB4063: "} diff --git a/src/Build/Resources/xlf/Strings.cs.xlf b/src/Build/Resources/xlf/Strings.cs.xlf index 8a437b75511..f4f249457a3 100644 --- a/src/Build/Resources/xlf/Strings.cs.xlf +++ b/src/Build/Resources/xlf/Strings.cs.xlf @@ -926,6 +926,11 @@ Chyby: {3} MSB4181: Úloha {0} vrátila false, ale do protokolu se nezaznamenala chyba. {StrBegin="MSB4181: "} + + MSB4233: The task "{0}" from assembly "{1}" was specified to load with the .NET runtime, but this version of MSBuild does not support loading tasks with that runtime. To run .NET tasks, use "dotnet build" or Visual Studio 2026 or higher. + MSB4233: The task "{0}" from assembly "{1}" was specified to load with the .NET runtime, but this version of MSBuild does not support loading tasks with that runtime. To run .NET tasks, use "dotnet build" or Visual Studio 2026 or higher. + {StrBegin="MSB4233: "}{Locked=".NET"}{Locked="dotnet build"}{Locked="Visual Studio 2026"}LOCALIZATION: .NET, dotnet build, and Visual Studio 2026 should not be localized. + {0}{1} test {2} ({3}s) {0}{1} – test {2} ({3} s) diff --git a/src/Build/Resources/xlf/Strings.de.xlf b/src/Build/Resources/xlf/Strings.de.xlf index 0a8f7dc1ea8..9594d3f629a 100644 --- a/src/Build/Resources/xlf/Strings.de.xlf +++ b/src/Build/Resources/xlf/Strings.de.xlf @@ -926,6 +926,11 @@ Fehler: {3} MSB4181: Die Aufgabe "{0}" hat FALSE zurückgegeben, jedoch keinen Fehler protokolliert. {StrBegin="MSB4181: "} + + MSB4233: The task "{0}" from assembly "{1}" was specified to load with the .NET runtime, but this version of MSBuild does not support loading tasks with that runtime. To run .NET tasks, use "dotnet build" or Visual Studio 2026 or higher. + MSB4233: The task "{0}" from assembly "{1}" was specified to load with the .NET runtime, but this version of MSBuild does not support loading tasks with that runtime. To run .NET tasks, use "dotnet build" or Visual Studio 2026 or higher. + {StrBegin="MSB4233: "}{Locked=".NET"}{Locked="dotnet build"}{Locked="Visual Studio 2026"}LOCALIZATION: .NET, dotnet build, and Visual Studio 2026 should not be localized. + {0}{1} test {2} ({3}s) {0}{1} Test {2} ({3}s) diff --git a/src/Build/Resources/xlf/Strings.es.xlf b/src/Build/Resources/xlf/Strings.es.xlf index b9d175655d3..c9589c0fbbe 100644 --- a/src/Build/Resources/xlf/Strings.es.xlf +++ b/src/Build/Resources/xlf/Strings.es.xlf @@ -926,6 +926,11 @@ Errores: {3} MSB4181: La tarea "{0}" devolvió false, pero no registró un error. {StrBegin="MSB4181: "} + + MSB4233: The task "{0}" from assembly "{1}" was specified to load with the .NET runtime, but this version of MSBuild does not support loading tasks with that runtime. To run .NET tasks, use "dotnet build" or Visual Studio 2026 or higher. + MSB4233: The task "{0}" from assembly "{1}" was specified to load with the .NET runtime, but this version of MSBuild does not support loading tasks with that runtime. To run .NET tasks, use "dotnet build" or Visual Studio 2026 or higher. + {StrBegin="MSB4233: "}{Locked=".NET"}{Locked="dotnet build"}{Locked="Visual Studio 2026"}LOCALIZATION: .NET, dotnet build, and Visual Studio 2026 should not be localized. + {0}{1} test {2} ({3}s) {0}{1} prueba{2} ({3}s) diff --git a/src/Build/Resources/xlf/Strings.fr.xlf b/src/Build/Resources/xlf/Strings.fr.xlf index cc2530e3f00..598b0044552 100644 --- a/src/Build/Resources/xlf/Strings.fr.xlf +++ b/src/Build/Resources/xlf/Strings.fr.xlf @@ -926,6 +926,11 @@ Erreurs : {3} MSB4181: la tâche "{0}" a retourné false mais n'a pas journalisé d'erreur. {StrBegin="MSB4181: "} + + MSB4233: The task "{0}" from assembly "{1}" was specified to load with the .NET runtime, but this version of MSBuild does not support loading tasks with that runtime. To run .NET tasks, use "dotnet build" or Visual Studio 2026 or higher. + MSB4233: The task "{0}" from assembly "{1}" was specified to load with the .NET runtime, but this version of MSBuild does not support loading tasks with that runtime. To run .NET tasks, use "dotnet build" or Visual Studio 2026 or higher. + {StrBegin="MSB4233: "}{Locked=".NET"}{Locked="dotnet build"}{Locked="Visual Studio 2026"}LOCALIZATION: .NET, dotnet build, and Visual Studio 2026 should not be localized. + {0}{1} test {2} ({3}s) {0}Test de {1} : {2} ({3} s) diff --git a/src/Build/Resources/xlf/Strings.it.xlf b/src/Build/Resources/xlf/Strings.it.xlf index e3f4dcc4d19..83149219553 100644 --- a/src/Build/Resources/xlf/Strings.it.xlf +++ b/src/Build/Resources/xlf/Strings.it.xlf @@ -926,6 +926,11 @@ Errori: {3} MSB4181: l'attività "{0}" ha restituito false, ma non è stato registrato alcun errore. {StrBegin="MSB4181: "} + + MSB4233: The task "{0}" from assembly "{1}" was specified to load with the .NET runtime, but this version of MSBuild does not support loading tasks with that runtime. To run .NET tasks, use "dotnet build" or Visual Studio 2026 or higher. + MSB4233: The task "{0}" from assembly "{1}" was specified to load with the .NET runtime, but this version of MSBuild does not support loading tasks with that runtime. To run .NET tasks, use "dotnet build" or Visual Studio 2026 or higher. + {StrBegin="MSB4233: "}{Locked=".NET"}{Locked="dotnet build"}{Locked="Visual Studio 2026"}LOCALIZATION: .NET, dotnet build, and Visual Studio 2026 should not be localized. + {0}{1} test {2} ({3}s) {0}{1} test {2} {3} diff --git a/src/Build/Resources/xlf/Strings.ja.xlf b/src/Build/Resources/xlf/Strings.ja.xlf index 0049e58c17d..750c05f1498 100644 --- a/src/Build/Resources/xlf/Strings.ja.xlf +++ b/src/Build/Resources/xlf/Strings.ja.xlf @@ -926,6 +926,11 @@ Errors: {3} MSB4181: "{0}" タスクから false が返されましたが、エラーがログに記録されませんでした。 {StrBegin="MSB4181: "} + + MSB4233: The task "{0}" from assembly "{1}" was specified to load with the .NET runtime, but this version of MSBuild does not support loading tasks with that runtime. To run .NET tasks, use "dotnet build" or Visual Studio 2026 or higher. + MSB4233: The task "{0}" from assembly "{1}" was specified to load with the .NET runtime, but this version of MSBuild does not support loading tasks with that runtime. To run .NET tasks, use "dotnet build" or Visual Studio 2026 or higher. + {StrBegin="MSB4233: "}{Locked=".NET"}{Locked="dotnet build"}{Locked="Visual Studio 2026"}LOCALIZATION: .NET, dotnet build, and Visual Studio 2026 should not be localized. + {0}{1} test {2} ({3}s) {0}{1} テスト {2} ({3} 秒) diff --git a/src/Build/Resources/xlf/Strings.ko.xlf b/src/Build/Resources/xlf/Strings.ko.xlf index 4e854a096e3..5472cc29cca 100644 --- a/src/Build/Resources/xlf/Strings.ko.xlf +++ b/src/Build/Resources/xlf/Strings.ko.xlf @@ -926,6 +926,11 @@ Errors: {3} MSB4181: "{0}" 작업이 false를 반환했지만 오류를 기록하지 않았습니다. {StrBegin="MSB4181: "} + + MSB4233: The task "{0}" from assembly "{1}" was specified to load with the .NET runtime, but this version of MSBuild does not support loading tasks with that runtime. To run .NET tasks, use "dotnet build" or Visual Studio 2026 or higher. + MSB4233: The task "{0}" from assembly "{1}" was specified to load with the .NET runtime, but this version of MSBuild does not support loading tasks with that runtime. To run .NET tasks, use "dotnet build" or Visual Studio 2026 or higher. + {StrBegin="MSB4233: "}{Locked=".NET"}{Locked="dotnet build"}{Locked="Visual Studio 2026"}LOCALIZATION: .NET, dotnet build, and Visual Studio 2026 should not be localized. + {0}{1} test {2} ({3}s) {0}{1} 테스트 {2}({3}초) diff --git a/src/Build/Resources/xlf/Strings.pl.xlf b/src/Build/Resources/xlf/Strings.pl.xlf index a6bc2289903..ee08e7b42d7 100644 --- a/src/Build/Resources/xlf/Strings.pl.xlf +++ b/src/Build/Resources/xlf/Strings.pl.xlf @@ -926,6 +926,11 @@ Błędy: {3} MSB4181: Zadanie „{0}” zwróciło wartość false, ale nie zarejestrowało błędu. {StrBegin="MSB4181: "} + + MSB4233: The task "{0}" from assembly "{1}" was specified to load with the .NET runtime, but this version of MSBuild does not support loading tasks with that runtime. To run .NET tasks, use "dotnet build" or Visual Studio 2026 or higher. + MSB4233: The task "{0}" from assembly "{1}" was specified to load with the .NET runtime, but this version of MSBuild does not support loading tasks with that runtime. To run .NET tasks, use "dotnet build" or Visual Studio 2026 or higher. + {StrBegin="MSB4233: "}{Locked=".NET"}{Locked="dotnet build"}{Locked="Visual Studio 2026"}LOCALIZATION: .NET, dotnet build, and Visual Studio 2026 should not be localized. + {0}{1} test {2} ({3}s) {0}{1} test {2} ({3}s) diff --git a/src/Build/Resources/xlf/Strings.pt-BR.xlf b/src/Build/Resources/xlf/Strings.pt-BR.xlf index 4bb69ae2752..1e09c20fd5f 100644 --- a/src/Build/Resources/xlf/Strings.pt-BR.xlf +++ b/src/Build/Resources/xlf/Strings.pt-BR.xlf @@ -926,6 +926,11 @@ Erros: {3} MSB4181: A tarefa "{0}" retornou false, mas não registrou um erro. {StrBegin="MSB4181: "} + + MSB4233: The task "{0}" from assembly "{1}" was specified to load with the .NET runtime, but this version of MSBuild does not support loading tasks with that runtime. To run .NET tasks, use "dotnet build" or Visual Studio 2026 or higher. + MSB4233: The task "{0}" from assembly "{1}" was specified to load with the .NET runtime, but this version of MSBuild does not support loading tasks with that runtime. To run .NET tasks, use "dotnet build" or Visual Studio 2026 or higher. + {StrBegin="MSB4233: "}{Locked=".NET"}{Locked="dotnet build"}{Locked="Visual Studio 2026"}LOCALIZATION: .NET, dotnet build, and Visual Studio 2026 should not be localized. + {0}{1} test {2} ({3}s) {0}{1} teste {2} ({3}s) diff --git a/src/Build/Resources/xlf/Strings.ru.xlf b/src/Build/Resources/xlf/Strings.ru.xlf index 78d728ca654..3f3e3b93337 100644 --- a/src/Build/Resources/xlf/Strings.ru.xlf +++ b/src/Build/Resources/xlf/Strings.ru.xlf @@ -926,6 +926,11 @@ Errors: {3} MSB4181: задача "{0}" возвратила значение false, но не зарегистрировала ошибку. {StrBegin="MSB4181: "} + + MSB4233: The task "{0}" from assembly "{1}" was specified to load with the .NET runtime, but this version of MSBuild does not support loading tasks with that runtime. To run .NET tasks, use "dotnet build" or Visual Studio 2026 or higher. + MSB4233: The task "{0}" from assembly "{1}" was specified to load with the .NET runtime, but this version of MSBuild does not support loading tasks with that runtime. To run .NET tasks, use "dotnet build" or Visual Studio 2026 or higher. + {StrBegin="MSB4233: "}{Locked=".NET"}{Locked="dotnet build"}{Locked="Visual Studio 2026"}LOCALIZATION: .NET, dotnet build, and Visual Studio 2026 should not be localized. + {0}{1} test {2} ({3}s) {0}{1} (тест) {2} ({3} с) diff --git a/src/Build/Resources/xlf/Strings.tr.xlf b/src/Build/Resources/xlf/Strings.tr.xlf index b93685a4a56..2a4a1b9863b 100644 --- a/src/Build/Resources/xlf/Strings.tr.xlf +++ b/src/Build/Resources/xlf/Strings.tr.xlf @@ -926,6 +926,11 @@ Hatalar: {3} MSB4181: "{0}" görevi false değerini döndürdü ancak günlüğe hata kaydetmedi. {StrBegin="MSB4181: "} + + MSB4233: The task "{0}" from assembly "{1}" was specified to load with the .NET runtime, but this version of MSBuild does not support loading tasks with that runtime. To run .NET tasks, use "dotnet build" or Visual Studio 2026 or higher. + MSB4233: The task "{0}" from assembly "{1}" was specified to load with the .NET runtime, but this version of MSBuild does not support loading tasks with that runtime. To run .NET tasks, use "dotnet build" or Visual Studio 2026 or higher. + {StrBegin="MSB4233: "}{Locked=".NET"}{Locked="dotnet build"}{Locked="Visual Studio 2026"}LOCALIZATION: .NET, dotnet build, and Visual Studio 2026 should not be localized. + {0}{1} test {2} ({3}s) {0}{1} testi {2} ({3}s) diff --git a/src/Build/Resources/xlf/Strings.zh-Hans.xlf b/src/Build/Resources/xlf/Strings.zh-Hans.xlf index 1b74008c385..6e6bfd7b1df 100644 --- a/src/Build/Resources/xlf/Strings.zh-Hans.xlf +++ b/src/Build/Resources/xlf/Strings.zh-Hans.xlf @@ -926,6 +926,11 @@ Errors: {3} MSB4181: “{0}”任务返回了 false,但未记录错误。 {StrBegin="MSB4181: "} + + MSB4233: The task "{0}" from assembly "{1}" was specified to load with the .NET runtime, but this version of MSBuild does not support loading tasks with that runtime. To run .NET tasks, use "dotnet build" or Visual Studio 2026 or higher. + MSB4233: The task "{0}" from assembly "{1}" was specified to load with the .NET runtime, but this version of MSBuild does not support loading tasks with that runtime. To run .NET tasks, use "dotnet build" or Visual Studio 2026 or higher. + {StrBegin="MSB4233: "}{Locked=".NET"}{Locked="dotnet build"}{Locked="Visual Studio 2026"}LOCALIZATION: .NET, dotnet build, and Visual Studio 2026 should not be localized. + {0}{1} test {2} ({3}s) {0}{1} 测试 {2} ({3} 秒) diff --git a/src/Build/Resources/xlf/Strings.zh-Hant.xlf b/src/Build/Resources/xlf/Strings.zh-Hant.xlf index d61942aa686..0e2663fee28 100644 --- a/src/Build/Resources/xlf/Strings.zh-Hant.xlf +++ b/src/Build/Resources/xlf/Strings.zh-Hant.xlf @@ -926,6 +926,11 @@ Errors: {3} MSB4181: "{0}" 工作傳回了 False,但未記錄錯誤。 {StrBegin="MSB4181: "} + + MSB4233: The task "{0}" from assembly "{1}" was specified to load with the .NET runtime, but this version of MSBuild does not support loading tasks with that runtime. To run .NET tasks, use "dotnet build" or Visual Studio 2026 or higher. + MSB4233: The task "{0}" from assembly "{1}" was specified to load with the .NET runtime, but this version of MSBuild does not support loading tasks with that runtime. To run .NET tasks, use "dotnet build" or Visual Studio 2026 or higher. + {StrBegin="MSB4233: "}{Locked=".NET"}{Locked="dotnet build"}{Locked="Visual Studio 2026"}LOCALIZATION: .NET, dotnet build, and Visual Studio 2026 should not be localized. + {0}{1} test {2} ({3}s) {0}{1} 測試 {2} ({3} 秒)