Skip to content
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

Resolve MSB3026 warnings in LFMerge build #285

Open
rmunn opened this issue Aug 20, 2022 · 0 comments
Open

Resolve MSB3026 warnings in LFMerge build #285

rmunn opened this issue Aug 20, 2022 · 0 comments
Assignees
Labels
easy A task that won't take long enhancement

Comments

@rmunn
Copy link
Collaborator

rmunn commented Aug 20, 2022

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>
@rmunn rmunn self-assigned this Aug 20, 2022
@rmunn rmunn added enhancement easy A task that won't take long labels Aug 20, 2022
@megahirt megahirt changed the title Suppress annoying-but-unimportant MsBuild warnings Resolve MSB3026 warnings in LFMerge build Aug 31, 2022
@megahirt megahirt assigned josephmyers and unassigned rmunn Aug 31, 2022
@josephmyers josephmyers removed their assignment Sep 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
easy A task that won't take long enhancement
Projects
Development

No branches or pull requests

2 participants