Skip to content

Resolve MSB3026 warnings in LFMerge build #285

@rmunn

Description

@rmunn

When compiling LfMerge now that #284 has been merged, there are two warnings that show up a lot and fill the screen, both of which do not cause the build to fail. I propose suppressing both of them.

Warning 1: MSB3026

When compiling LfMerge on a fast machine, you will often see errors like:

warning MSB3026: Could not copy "/some/path/to/Some.dll" to "/some/destination". Beginning retry 1 in 1000ms. The process cannot access the file '/some/path/to/Some.dll' because it is being used by another process.

The cause of this error is that by default, MsBuild builds projects in parallel, using as many CPU cores as you have. If two or more projects are referencing the same DLL (for example, LfMerge.Core.dll), and they are equally fast to compile, then they will often try to copy it at the same time into their respective destinations, and each one will try to take out an exclusive lock on the file. (Which isn't necessary on Linux, but MsBuild was designed for Windows filesystems where that used to be necessary). The result is that some processes have to back off and try again, and MsBuild warns you about that.

There are two solutions. One is to add the -m:1 flag to the dotnet build command, meaning "Max processes: 1" so that the build runs in serial rather than in parallel. The other, IMHO better, solution is to add something like the following to the appropriate .csproj files (or to a common property file that gets inherited by all of them, similar to the way #124 moved a bunch of properties to a Directory.Build.props file):

  <PropertyGroup>
    <MSBuildWarningsAsMessages>$(MSBuildWarningsAsMessages);MSB3026</MSBuildWarningsAsMessages>
  </PropertyGroup>

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

Status

To Do

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions