Repository navigation
Labels
Description
Issue Description
(For context, I am trying to re-write dotnet/dotnet#7817 using TarDirectory).
Using the TarDirectory task can call msbuild to fail with an internal error
MSBUILD : error MSB1025: An internal failure occurred while running MSBuild. [dotnet-/repo-projects/runtime.proj]
Microsoft.Build.Framework.InternalErrorException: MSB0001: Internal MSBuild Error: Request 18180 expected to be in state Executing but state is actually Yielding
at Microsoft.Build.InternalError.Throw(String message)
at Microsoft.Build.BackEnd.Scheduler.ReportResult(Int32 nodeId, BuildResult result)
at Microsoft.Build.Execution.BuildManager.HandleResult(Int32 node, BuildResult result)
at Microsoft.Build.Execution.BuildManager.ProcessPacket(Int32 node, INodePacket packet)
at Microsoft.Build.Execution.BuildManager.ProcessWorkQueue(Action action)
--- End of stack trace from previous location ---
at Microsoft.Build.Execution.BuildManager.EndBuild()
at Microsoft.Build.Execution.BuildManager.EndBuild()
at Microsoft.Build.Execution.BuildManager.EndBuild()
at Microsoft.Build.CommandLine.MSBuildApp.BuildProject(String projectFile, String[] targets, String toolsVersion, Dictionary`2 globalProperties, Dictionary`2 restoreProperties, ILogger[] loggers, LoggerVerbosity verbosity, DistributedLoggerRecord[] distributedLoggerRecords, Int32 cpuCount, Boolean multiThreaded, Boolean enableNodeReuse, TextWriter preprocessWriter, TextWriter targetsWriter, Boolean detailedSummary, ISet`1 warningsAsErrors, ISet`1 warningsNotAsErrors, ISet`1 warningsAsMessages, Boolean enableRestore, ProfilerLogger profilerLogger, Boolean enableProfiler, Boolean interactive, ProjectIsolationMode isolateProjects, GraphBuildOptions graphBuildOptions, Boolean lowPriority, Boolean question, Boolean isTaskAndTargetItemLoggingRequired, Boolean isBuildCheckEnabled, String[] inputResultsCaches, String outputResultsCache, Boolean saveProjectResult, BuildResult& result, String[] commandLine)
MSBUILD : error MSB1025: An internal failure occurred while running MSBuild. [dotnet/repo-projects/runtime.proj]
Microsoft.Build.Framework.InternalErrorException: MSB0001: Internal MSBuild Error: Request 18180 expected to be in state Executing but state is actually Yielding
at Microsoft.Build.CommandLine.MSBuildApp.BuildProject(String projectFile, String[] targets, String toolsVersion, Dictionary`2 globalProperties, Dictionary`2 restoreProperties, ILogger[] loggers, LoggerVerbosity verbosity, DistributedLoggerRecord[] distributedLoggerRecords, Int32 cpuCount, Boolean multiThreaded, Boolean enableNodeReuse, TextWriter preprocessWriter, TextWriter targetsWriter, Boolean detailedSummary, ISet`1 warningsAsErrors, ISet`1 warningsNotAsErrors, ISet`1 warningsAsMessages, Boolean enableRestore, ProfilerLogger profilerLogger, Boolean enableProfiler, Boolean interactive, ProjectIsolationMode isolateProjects, GraphBuildOptions graphBuildOptions, Boolean lowPriority, Boolean question, Boolean isTaskAndTargetItemLoggingRequired, Boolean isBuildCheckEnabled, String[] inputResultsCaches, String outputResultsCache, Boolean saveProjectResult, BuildResult& result, String[] commandLine)
at Microsoft.Build.CommandLine.MSBuildApp.Execute(String[] commandLine, CommandLineSwitches preGatheredSwitchesFromAutoResponseFile, CommandLineSwitches preGatheredSwitchesNotFromAutoResponseFile)
Unhandled exception: Microsoft.Build.Framework.InternalErrorException: MSB0001: Internal MSBuild Error: Request 18180 expected to be in state Executing but state is actually Yielding
at Microsoft.Build.CommandLine.MSBuildApp.BuildProject(String projectFile, String[] targets, String toolsVersion, Dictionary`2 globalProperties, Dictionary`2 restoreProperties, ILogger[] loggers, LoggerVerbosity verbosity, DistributedLoggerRecord[] distributedLoggerRecords, Int32 cpuCount, Boolean multiThreaded, Boolean enableNodeReuse, TextWriter preprocessWriter, TextWriter targetsWriter, Boolean detailedSummary, ISet`1 warningsAsErrors, ISet`1 warningsNotAsErrors, ISet`1 warningsAsMessages, Boolean enableRestore, ProfilerLogger profilerLogger, Boolean enableProfiler, Boolean interactive, ProjectIsolationMode isolateProjects, GraphBuildOptions graphBuildOptions, Boolean lowPriority, Boolean question, Boolean isTaskAndTargetItemLoggingRequired, Boolean isBuildCheckEnabled, String[] inputResultsCaches, String outputResultsCache, Boolean saveProjectResult, BuildResult& result, String[] commandLine)
at Microsoft.Build.CommandLine.MSBuildApp.Execute(String[] commandLine, CommandLineSwitches preGatheredSwitchesFromAutoResponseFile, CommandLineSwitches preGatheredSwitchesNotFromAutoResponseFile)
at Microsoft.Build.CommandLine.MSBuildClientApp.Execute(String[] commandLineArgs, String msbuildLocation, Boolean multiThreaded, Boolean shutdownServerAfterBuild, CancellationToken cancellationToken)
at Microsoft.Build.CommandLine.MSBuildApp.Main(String[] args)
at Microsoft.DotNet.Cli.Utils.MSBuildForwardingAppWithoutLogging.ExecuteInProc(String[] arguments)
It looks like a threading issue?
Steps to Reproduce
This change to the VMR should be enough to demonstrate the issue:
--- a/src/arcade/src/Microsoft.DotNet.Build.Tasks.Archives/build/archives.targets
+++ b/src/arcade/src/Microsoft.DotNet.Build.Tasks.Archives/build/archives.targets
@@ -125,14 +115,13 @@
Overwrite="true"
DestinationFile="$(_DestinationFileName)"
Condition="'$(_CurrentArchiveFormat)' == 'zip'"/>
- <!-- use parallel gzip implementation when available -->
- <Exec Command="tar -cf - . | pigz > "$(_DestinationFileName)""
- WorkingDirectory="$(_OutputPathRoot)"
- Condition="'$(_CurrentArchiveFormat)' == 'tar.gz' and '$(_PigzFoundExitCode)' == '0'"/>
- <!-- otherwise, use built-in gzip feature (-z) -->
- <Exec Command="tar -czf "$(_DestinationFileName)" ."
- WorkingDirectory="$(_OutputPathRoot)"
- Condition="'$(_CurrentArchiveFormat)' == 'tar.gz' and '$(_PigzFoundExitCode)' != '0'"/>
+
+ <TarDirectory SourceDirectory="$(_OutputPathRoot)"
+ DestinationFile="$(_DestinationFileName)"
+ Compression="GZip"
+ Format="Gnu"
+ Overwrite="true"
+ Condition="'$(_CurrentArchiveFormat)' == 'tar.gz'" />
<Message Text="Successfully created archive -> '$(_DestinationFileName)' from '$(_OutputPathRoot)'" Importance="high" />
</Target>
Then build the VMR using the normal options:
./build.sh --prep --source-only
Expected Behavior
TarDirectory task works.
Actual Behavior
MSBUILD : error MSB1025: An internal failure occurred while running MSBuild
Analysis
An LLM thinks this is a result of threading issue.
Thread 76 Thread 122
───────── ──────────
Execute()
ExecuteAsync()
Yield() ← MSBuild records 76
start asynchronous archive write
await: operation isn't complete
ExecuteAsync returns a pending Task
GetResult() blocks thread 76
archive operation completes
resume ExecuteAsync()
finish writing / close streams
enter finally
Reacquire()
current thread = 122
recorded thread = 76
→ exception
GetResult() receives the exception
Execute() fails
Versions & Configurations
VMR commit a69d27567bd8be379e504329c965b9ca3fdf53fd
Reacted by Frulfump
Activity
omajid commentedon Oct 19, 2026
cc @RzkiM @baronfel @ViktorHofer @tmds
Fix TarDirectory on a different thread than Yield
am11 commentedon Oct 20, 2026
Fix in #15338. New added tests fail without the changes in
src/Tasksand pass with the fix. Would be nice if we backport the fix in .NET 11 release as it's a new feature in this release.Reacquire on Yield thread in TarDirectory and Untar
[vs18.12] Reacquire on Yield thread in TarDirectory and Untar (#15378)
JanProvaznik commentedon Nov 18, 2026
This fix has no effect in VS:
TarDirectory/Untarare .NET-only and aren't available in VS's MSBuild.exe. The fix was inserted into VS only to keep the VS and .NET SDK commit histories in step.ViktorHofer commentedon Nov 18, 2026
These tasks are usable with VS msbuild. They aren't compiled for .NET Framework but are invoked via the Runtime="NET" task host feature. Btw @JanProvaznik is your above comment in response to something?
JanProvaznik commentedon Nov 18, 2026
oops I meant to post it in VS validation thread about the bug and it double posted here