Skip to content

Microsoft.NET.Publish.Tests.PublishItemsOutputGroupOutputsTests.RunPublishItemsOutputGroupOutputsTest fails for single-file win-x86 publishing #49926

Closed as duplicate

Description

@baronfel

Describe the bug

This test fails for the single-file, RID-specific publish because the single-file apphost is locked when we try to take a file read:

  TestPublishItemsOutputGroupOutputs failed with 1 error(s) (4.2s) → TestPublishItemsOutputGroupOutputs/bin/Debug/net6.0/win-x86/TestPublishItemsOutputGroupOutputs.dll
    /workspaces/sdk/artifacts/bin/redist/Debug/dotnet/sdk/10.0.100-dev/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Publish.targets(1132,5): error MSB4018: 
      The "GenerateBundle" task failed unexpectedly.
      System.IO.IOException: The process cannot access the file '/workspaces/sdk/artifacts/tmp/Debug/testing/RunPublishIte---00D00966/TestPublishItemsOutputGroupOutputs/obj/Debug/net6.0/win-x86/singlefilehost.exe' because it is being used by another process.
         at Microsoft.Win32.SafeHandles.SafeFileHandle.Init(String path, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize, Int64& fileLength, UnixFileMode& filePermissions)
         at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize, UnixFileMode openPermissions, Int64& fileLength, UnixFileMode& filePermissions, Boolean failForSymlink, Boolean& wasSymlink, Func`4 createOpenException)
         at System.IO.Strategies.OSFileStreamStrategy..ctor(String path, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize, Nullable`1 unixCreateMode)
         at System.IO.File.OpenRead(String path)
         at Microsoft.NET.HostModel.Bundle.Bundler.GenerateBundle(IReadOnlyList`1 fileSpecs)
         at Microsoft.NET.Build.Tasks.GenerateBundle.ExecuteCore() in /workspaces/sdk/src/Tasks/Microsoft.NET.Build.Tasks/GenerateBundle.cs:line 81
         at Microsoft.NET.Build.Tasks.TaskBase.Execute() in /workspaces/sdk/src/Tasks/Common/TaskBase.cs:line 36
         at Microsoft.Build.BackEnd.TaskExecutionHost.Execute()
         at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(TaskExecutionHost taskExecutionHost, TaskLoggingContext taskLoggingContext, TaskHost taskHost, ItemBucket bucket, TaskExecutionMode howToExecuteTask)

The GenerateBundle task in question is calling into the runtime-provided APIs for making the single-file apphost for this project, and as part of that a File.OpenRead cannot be taken.

Activity

  1. added theissue type on Jul 24, 2025
  2. baronfel commented on Jul 24, 2025

    @baronfel
    MemberAuthor

    From @elinor-fung in #49740 (comment) for a similar issue:

    That does not look familiar to me. It would be from https://github.com/dotnet/runtime/blob/b306971348daefc65862fc446272a832b17aa71f/src/installer/managed/Microsoft.NET.HostModel/Bundle/Bundler.cs#L330

    dotnet/runtime#116659 did change how we read the original singlefilehost executable and write out the bundle - cc @jtschuster in case you have seen something like it / have ideas. Only thing I could think is we might be hitting anti-virus software sadness again? If it is scanning the original source in the obj/ directory when we try to read it in?

    Side note: do we still really need to test targeting win7?

    This one isn't win7, but it is win-x86. How much do we care/support this target still?

  3. SimonZhao888 commented on Aug 5, 2025

    @SimonZhao888
    Member

    Close this issue as it has been reopened by #50031.

  4. marcpopMSFT commented on Sep 25, 2025

    @marcpopMSFT
    Member

    track with 50784 which uses the known issue infra.

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

Metadata

Metadata

Assignees

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions