Repository navigation
Move MSBuild initialization from MSBuildTestBase to MSBuildAssemblyResolver - #277
Conversation
|
Separately, is
If you prefer, I'm also happy to add a dependency on MSBuildLocation and mark MSBuildAssemblyResolver as obsolete instead. |
|
One more item: Though net462 doesn't support it natively, since the project targets a new enough version of C#, we could implement a module initializer ourselves so consumers don't need to do any registration / initialization at all. That however assumes:
I believe these things are both true, but I didn't want to jump to that conclusion without double-checking. |
I worked on MSBuildLocator and don't really like it. Its yet another assembly to do a simple thing (resolve MSBuild). It also doesn't use the defaults I think are best so I just implemented one here. If the one here is out of date or has an issue, we can reassess but for now I think its fine to have a custom one. |
The MSBuild location / initialization code was only available in the
MSBuildTestBaseabstract 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 fromMSBuildTestBasefor backwards compatibility.I wrapped registration in a
Lazyto 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).