dotnet / dotnet/sdk

Detect and warn when users consume OutputPath in Project files directly

Open
#41,852 0 comments 1 reaction 0 assignees View on GitHub
Area-NetSDK msbuild-analyzer-candidate untriaged
Dominant language
C#
Stars
3.2k
Forks
1.3k
PR merge metrics
PR metrics pending

Description

### Is your feature request related to a problem? Please describe.

There are many properties that are set by the SDK by default, but the SDK defers computing them until `.targets` files are evaluated to give users a chance to set these properties in .props and project files.

However, users also often _read_ these properties directly in props/project files, leading to scenarios where a property defined in a project file has an incorrect value after the rest of the SDK targets have run. A common property used in this way is `OutputPath`.

It's common to want to compute a path for some output that will live in the OutputPath of the project, but that final path isn't known until the SDK's DefaultOutputPath targets run. This means the _best_ way for a user to set properties that use OutputPath is to create a Target, tie that Target into the build, and then define their property just before usage.

We should detect the direct usage of properties in project files that are only set later in the SDK and warn users that the values may not be usable or trustworthy.

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.