dotnet / dotnet/msbuild

[Built-in analyzer] Flag shared evaluations between restore and build targets

Open
#9,553 4 comments 4 reactions 0 assignees View on GitHub
Area: BuildCheck backlog BuildCheck Suggestion Feature: Warning Waves triaged
Dominant language
C#
Stars
5.5k
Forks
1.5k
Avg merge
1d 8h
Merged PRs (30d)
141

Description

See https://github.com/dotnet/runtime/blob/6d0a902c9585d98bfa44f514bac21a47eabe02fa/eng/testing/workloads-testing.targets#L195-L200 as an example.

Because the Restore and Pack target pass the same set of properties in, the underlying project evaluation evaluation is shared. This resulted in msbuild files restored via a `PackageReference` not being imported during the build.

I have been fixing so many of these code pieces in my career at Microsoft and it would really be helpful if msbuild could somehow indicate that a shared evaluation between `Restore` and `Build` or `Pack` is most certainly wrong. Sure, there are cases where a shared evaluation might be intentional, but that should < 1%.

Related: https://github.com/dotnet/msbuild/issues/2811

cc @akoeplinger @ericstj

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.