-
-
Notifications
You must be signed in to change notification settings - Fork 94
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PublishSingleFile
breaks IProjectAnalyzer.Build()
#224
Comments
Hi @chucker , I'll look into it and get back to you. |
Hi 😉 |
If @phmonte does not have time today (nor tomorrow), I'll give it a go. |
The problem occurs when you publish code that uses I don't know how to simulate it in unit tests but your sample project is good for replicate this behavior. I have change one line from: and start console in As you can see for normal build everything works as expected but when published as single file: and runs It hangs somewhere in Best regards, |
@Karql thanks, now it's possible to reproduce, I'm investigating. |
I believe I found the problem, it's here. |
Nice catch 👌 This could be a problem... As I understand correctly, that dll needs to exists on the disk in order to pass its path to For a moment, I wondered if it might be possible to get extract path from but from I hope you will find some alternatives 😉 Two ideas:
|
The msbuild result is captured through the log, there is a custom log that does all this work, removing it will be a bit complex, I'm thinking about other alternatives keeping the dll. |
Hi @Karql , If you are really going to remove the dll from the publish single file and you are unsuccessful with the alternatives, let us know and we can think of an alternative (search in the current directory or by parameter). |
I have seen the issue you mentioned 😉 For me after use it its still hangs. ConsoleApp1.Program.cs: using Buildalyzer;
using Buildalyzer.Logger;
string loggerPath = typeof(BuildalyzerLogger).Assembly.Location;
Console.WriteLine($"Logger path: {loggerPath}");
var manager = new AnalyzerManager();
var analyzer = manager.GetProject(@"../ClassLibrary1/ClassLibrary1.csproj");
Console.WriteLine("1");
_ = analyzer.Build();
Console.WriteLine("2"); ConsoleApp1.csproj ...
<Target Name="ExplicitRemoveFromFilesToBundle" BeforeTargets="GenerateSingleFileBundle" DependsOnTargets="PrepareForBundle">
<ItemGroup>
<FilesToRemoveFromBundle Include="@(FilesToBundle)" Condition="$([System.String]::new('%(Filename)').ToLower().Contains('buildalyzer.logger'))" />
</ItemGroup>
<Message Text="FilesToRemoveFromBundle '@(FilesToRemoveFromBundle)'" Importance="high" />
<ItemGroup>
<FilesToBundle Remove="@(FilesToRemoveFromBundle)" />
</ItemGroup>
</Target>
<Target Name="CopyFilesToRemoveFromBundle" AfterTargets="Publish">
<Copy SourceFiles="@(FilesToRemoveFromBundle)" DestinationFolder="$(PublishDir)" />
<Message Text="Copied files to remove from bundle to '$(PublishDir)'" Importance="high" />
</Target>
... but there is a small improvement - the path to the logger is good 😉 |
@Karql There are 2 dlls, could you test by removing them? I really believe it will solve your problem. |
I can confirm that after excluding those two dlls application works as expected 😉 I wonder if adding some fallbacks would be a nice addition (somthing like searching I have three in my mind:
|
Thanks for confirming, I believe it's not the best solution, but it's the only one that enables PublishSingleFile due to current restrictions. I will make some of your suggestions. |
btw. I really appreciate your help 😉 Have a great day! |
@Karql an environment variable was added for publish single file cases in version 7.0.2. I'll close the issue, any problems open a new one. |
@phmonte 👌 |
If I publish a .NET 6 app with
PublishSingleFile
enabled (PublishReadyToRun
andPublishTrimmed
don't seem to be related to the issue), it hangs as soon as I callBuild()
.For example, make a fresh class library (its code doesn't matter), and a console app with the following
Program.cs
: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.: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?
The text was updated successfully, but these errors were encountered: