Skip to content

TarDirectory task produces MSBUILD : error MSB1025: An internal failure occurred while running MSBuild #15331

Closed

Description

@omajid

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 &gt; &quot;$(_DestinationFileName)&quot;"
-          WorkingDirectory="$(_OutputPathRoot)"
-          Condition="'$(_CurrentArchiveFormat)' == 'tar.gz' and '$(_PigzFoundExitCode)' == '0'"/>
-    <!-- otherwise, use built-in gzip feature (-z) -->
-    <Exec Command="tar -czf &quot;$(_DestinationFileName)&quot; ."
-          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

Activity

  1. added theissue type on Oct 19, 2026
  2. omajid commented on Oct 19, 2026

    @omajid
    MemberAuthor
  3. self-assigned this
    on Oct 20, 2026
  4. self-assigned this
    on Oct 20, 2026
  5. added a commit that references this issue on Oct 20, 2026
    a6d47f5
  6. am11 commented on Oct 20, 2026

    @am11
    Member

    Fix in #15338. New added tests fail without the changes in src/Tasks and 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.

  7. added a commit that references this issue on Oct 20, 2026
    436b6db
  8. added a commit that references this issue on Nov 9, 2026
    8df097b
  9. JanProvaznik commented on Nov 18, 2026

    @JanProvaznik
    Member

    This fix has no effect in VS: TarDirectory/Untar are .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.

  10. ViktorHofer commented on Nov 18, 2026

    @ViktorHofer
    Member

    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?

  11. JanProvaznik commented on Nov 18, 2026

    @JanProvaznik
    Member

    oops I meant to post it in VS validation thread about the bug and it double posted here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions