phmonte / Buildalyzer

A utility to perform design-time builds of .NET projects without having to think too hard about it.
MIT License
611 stars 94 forks source link

Consecutive build fails #133

Closed jonas-johansson closed 8 months ago

jonas-johansson commented 4 years ago

When doing two consecutive builds I get the following errors on the second build.

The process cannot access the file 'X' because it is being used by another process. Cannot create a file when that file already exists.

It is repeated for a number of files.

If I add a long pause between the builds it builds successfully.

It appears as if Buildalyzer doesn't wait for some process to finish.

jonas-johansson commented 4 years ago

I'm getting the issue, but I see that I occasionally get it on the first build as well. Not sure what's causing it.

daveaglick commented 4 years ago

Did you mean to close this issue?

Are you able to tell which part of the build process is producing the error message? I'm mainly wondering if it's coming from the NuGet tasks or the main MSBuild tasks. The NuGet tasks are kind of their own little system so if the error is happening during restore that might suggest a whole separate set of problems from the build tasks.

Another thing to try is generating a binlog file and then opening it in the Structured Log Viewer. That should tell us exactly which build task is producing the error message.

You can turn on binary logging in your ProjectAnalyzer like this:

analyzer.AddBinaryLogger(@"C:\SomePath\log.binlog");
jonas-johansson commented 4 years ago

Hey @daveaglick!

Yeah, I closed the issue because I felt that I had framed it incorrectly. I opened it up now, and added more information below:

As I mentioned, I'm getting The process cannot access the file 'X' because it is being used by another process. The file in question is always SomeRandomProject\obj\SomeRandomProject.csproj.nuget.dgspec.json. Sometimes the build passes, but often it's one of the most low-level projects with a high number of projects referencing it.

I'm going to try out the binlog!

jonas-johansson commented 4 years ago

Thanks for the binlog tip @daveaglick!

Here's what I can see in one of the cases I reproduced:

I previously explored the following NuGet.Client issue because of the error message I received: https://github.com/NuGet/NuGet.Client/pull/3170. I updated Visual Studio (and I assume NuGet is part of that process) but I still get the issue.

Any ideas?

phmonte commented 9 months ago

Hello @jonas-johansson, after new versions do you still have this problem?

jonas-johansson commented 8 months ago

Hello @jonas-johansson, after new versions do you still have this problem?

I'm not using Buildalyzer right now so unfortunately I can't comment on that.

phmonte commented 8 months ago

Thanks for the feedback, I'll close the issue, if anyone has the same problem, please open a new issue.