Closed DevKumar4Git closed 5 years ago
Locator does not support .NET Standard, because it only supports two concrete implementations of MSBuild: netcoreapp2.0
and net46
(net472
for 16.0). That means you can't successfully run it from an arbitrary netstandard2.0
-compatible application.
For your multitargeting scenario, you'll need to multitarget to .NET Framework and .NET Core, like the sample app:
- If I have to put MSBuildLocator.RegisterDefaults(), I would load MSBuild defaults unnecessarily in the full app & not when its actually needed in 1 library.
Can you rephrase this, please? I don't understand what you're saying.
Thanks for the response. Let me rephrase 3. Its mostly performance hits my app has to take in doing this.
You only have to call Register
before calling any function that uses a type defined in an MSBuild assembly. You could call it in your subcommand.
That subcommand is built as a Net Standard 2.0 Library.
Why is that a hard requirement?
Its the way its built to work on Net Framework & Net Core, both using the same libraries. All the commands, sub commands are Net Standard 2.0 library & the app is just a wrapper calling it. Based on what you are suggesting, sounds like I would have to move the verbs out of Net Standard library.
Yes, to evaluate MSBuild projects, you'll have to specialize the library. A single implementation cannot work in both .NET and .NET Core.
Following on from our duplicate issue, to be clear, yes, we understand the difference between API surface area versus run time. We are talking about exposing it as an API surface area, whatever the ultimate run time might be. That's the point.
That means you can't successfully run it from an arbitrary netstandard2.0-compatible application.
A statement like this causes me to wonder whether there isn't confusion upstream from your subscribers. We are not trying to run anything from the API surface area. But we are working on managers or other scaffolds that stitch the experience together that eventually does get invoked by a run time, in a test environment, in an actual CLI tooling, or other run time environment.
@mwpowellhtx If I understand you correctly, you are looking for this:
MSBuildLocator.RegisterDefaults()
.RegisterDefaults()
call.You are asking for this scenario to work by providing the following:
@sharwell Along these lines, yes, I think so. But if I understand correctly, there are dependencies that Locator
leverages which themselves are run time only targets. If we have a naive notion of the scope, fair enough. I'm just stating the intended, expectation. Whether that's practical, attainable, is another question.
In a netstandard2.0 Sdk Style projects, try to install Microsoft.Build.Locator nuget package. In the code file, try using Microsoft.Build.Locator
Why do I need this?
Is there any good workaround for this, other than packaging the MsBuild dll's with my App.