dotnet / dotnet/msbuild

How to evaluate a project while resolving its imports?

Open
#5,819 4 comments 0 reactions 0 assignees View on GitHub
triaged
Dominant language
C#
Stars
5.5k
Forks
1.5k
Avg merge
1d 8h
Merged PRs (30d)
141

Description

MSBuild has APIs to just evaluate a project's properties and items without building it (being aware of the disclaimers of #1285) but these do not take into accound any properties that are defined in any of the project's `Import`s.

I have thought of the following workaround: I will tell the `BuildManager` to build a nonexistent target, while passing `BuildRequestDataFlags.SkipNonexistentTargets` in the `BuildRequestData`.

My questions are:

1. Is there anything problematic with the approach I described? MSBuild will fully evaluate the project file and "run" a target that does not exist, ignoring it as I told. The default target will be prevented from running.

2. How about concurrency? It seems to me that the `BuildManager` class is not thread-safe. So instead of locking around its use, I have thought of creating and reusing `BuildManager` per thread. Is that good? Documentation says that "Normally there is only one build manager in a process, and it is the default build manager." but doesn't say what would happen if more than one build managers exist.

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.