Skip to content

PublishSingleFile breaks IProjectAnalyzer.Build() #224

@chucker

Description

@chucker

If I publish a .NET 6 app with PublishSingleFile enabled (PublishReadyToRun and PublishTrimmed don't seem to be related to the issue), it hangs as soon as I call Build().

For example, make a fresh class library (its code doesn't matter), and a console app with the following Program.cs:

using Buildalyzer;

var manager = new AnalyzerManager();
var analyzer = manager.GetProject(@"path\to\ClassLibrary1\ClassLibrary1.csproj");

Console.WriteLine("1");

_ = analyzer.Build();

Console.WriteLine("2");

If you build and run it, you get both console outputs within a few seconds.

But if you then create a publish profile with PublishSingleFile enabled, e.g.:

<?xml version="1.0" encoding="utf-8"?>
<!--
https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project>
  <PropertyGroup>
    <Configuration>Release</Configuration>
    <Platform>Any CPU</Platform>
    <PublishDir>publish\</PublishDir>
    <PublishProtocol>FileSystem</PublishProtocol>
    <_TargetId>Folder</_TargetId>
    <TargetFramework>net6.0</TargetFramework>
    <RuntimeIdentifier>win-x86</RuntimeIdentifier>
    <SelfContained>true</SelfContained>
    <PublishSingleFile>true</PublishSingleFile>
  </PropertyGroup>
</Project>

and run that, it seems to hang after the first output.

My first hunch was that code trimming removed something crucial, but that seems to be inactive.

I tried to profile it, and it looks like some kind of deadlock?

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    ⚠ BugSomething isn't working as expected

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions