Move MSBuild initialization from MSBuildTestBase to MSBuildAssemblyResolver #277
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The MSBuild location / initialization code was only available in the
MSBuildTestBase
abstract class for unit tests.Using a base class for this purpose can create multiple inheritance problems when combined with other testing tools. To allow more flexibility in how the assembly resolution is done, I moved the code to
MSBuildAssemblyResolver.Register()
, and forward the call fromMSBuildTestBase
for backwards compatibility.I wrapped registration in a
Lazy
to prevent registration from happening multiple times. However, I don't think that's technically necessary, so I can remove that if desired.I also updated the README section on resolving MSBuild. I'm not an SDK resolution expert, but I believe the old option 2 was insufficient, so I removed it and added a new "preferred" method of using a Module initializer if possible (which is also morally equivalent).