Skip to content

[BuildCheck Suggestion]: Flag setting AssemblyName in Directory.Build.targets (or other 'core' values being changed after significant usage) #10614

Open
@baronfel

Description

@baronfel

Summary

It would be great to be able to detect an anti-pattern of some build assets taking a dependency on a Property or Item metadata and then changing that value in a destructive way later on in the build.

Background and Motivation

In SDK triage we responded to a user that had set AssemblyName to a custom value in their Directory.Build.targets and then was
confused when other build assets had already consumed that value by the time it was set.

Sample issue or antipattern that the check should be flagging

A simple example would be to create a project and a Directory.Build.targets and set AssemblyName in the Directory.Build.targets then run dotnet run.

Sample output

MSB0666 - property changed after being consumed. The property <property> has already been used by <other property> at <usage location>, but was set to <value> at <setting location>. This change will not be seen by <property>

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area: BuildCheckBuildCheck SuggestionSuggestion for a built in MSBuild analyzer. Label should be applied together with 'Area: BuildCheck'triaged

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions