dotnet / msbuild

The Microsoft Build Engine (MSBuild) is the build platform for .NET and Visual Studio.

Home Page:https://docs.microsoft.com/visualstudio/msbuild/msbuild

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Built-in analyzer] The same file is written by multiple tasks during the build

ladipro opened this issue · comments

Background

This issue tracks one of the BuildCheck analyzers we would like to ship in-box with MSBuild.

Goal

Implement an analyzer with the following rule: Each file written to disk during the build should be written only once. Also known as "double writes" analysis.

Notes

Writing the same file multiple times often leads to file access issues and non-deterministic builds. This analyzer will report the violation if it happens within one project as well as between multiple projects. It can be implemented by checking the parameters of well-known tasks like Copy and Csc (see the implementation in binlog viewer). Alternatively, it can be implemented based on target outputs, as used by the engine for up-to-date checks.

It would be nice if this further analyzed across projects for cases where the build invoked those projects in parallel.

The plan is for this to work across projects but if you mean building in VS, then yes, we will likely have to do extra work to make build analyzers work across projects when the build is orchestrated by VS.