-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve task DLL load behavior #1312
Comments
Would the |
@mwpowellhtx Not for free, and only for .NET Core. See the unimplemented plan: https://github.com/microsoft/msbuild/blob/master/documentation/specs/task-isolation-and-dependencies.md |
@rainersigwald When does the .deps.json file land in the folder? Seems like it only lands in the |
@rainersigwald Then the question would be, for those of us on .NET Standard 2 or .NET Core 2, that is. Rolling something custom along those lines.
Or roll our own approach. |
@rainersigwald The corehost_resolve_component_dependencies and corehost_set_error_writer callbacks seem to be the nerve center for the whole resolution procedure. Is there documentation for the hostpolicy.dll? More importantly, short of rolling our own v2 variations, these imported functions are accessible to netstandard2.0 targeted assemblies. |
@mwpowellhtx I don't think I see how your questions relate to this issue. Can you clarify? |
@rainersigwald I just followed the links in the MD. I see a Resolver that is "implemented", and my question is whether Host Policy is a v3 SDK thing, or whether that is exposed today in the v2 SDK. i.e. that we could back port that. |
@vitek-karas, do you know of docs on that? |
@rainersigwald @vitek-karas To be clear, from the MD here, and just followed the links. From there I did my due diligence as far as I could dig into the source code and suss out the invocations. @rainersigwald And please do not tell me TL;DL, that is just insert appropriate expletive lazy, IMO. |
I must admit I don't understand the other part of this discussion about when the
|
@vitek-karas My concern here would be that the Resolver is taking a dependency on @rainersigwald Also, to clarify, we are having this discussion because of precisely this issue. Dependencies are failing to resolve for build tasking. Specifically I have a Code Generation asset which I want to run internal to a project, that itself carries half a dozen mission critical unresolved dependencies. So this is a show stopper until we can put some sort of workaround, or longer range solution, into production. Our objective is to ensure that the dependencies have been resolved, and/or copied into the |
I don't believe depending on deps.json is the right path forward here. It is a runtime asset and not a build time one. What we should do is figure out what sorts of inputs you would need to hook your tasks for those inputs, if you are trying to find the right types, files, etc in your task. If you task itself will depend on varying degrees of assemblies, then Vitek proposal is the closer we have right now, but it is not implemented and we haven't taken that forward yet. I am sorry about that. |
@livarcocc Begging your pardon, but for us, the runtime happens to be a dotnet CLI tooling whose scope is build time. So, yes, we do need to resolve these dependencies during the build. If you'd like to discuss further or in more depth, we should establish an NDA. |
@livarcocc @vitek-karas I would also like to clarify the dependency System.Runtime.Loader is taking on
Specifically, the degree to which they may be exposed to v2 SDK. That is, whether they are; although at this point, we are inferring possibly they are only exposed to v3 SDK. Absent or short of that, what alternative paths or workarounds we can pursue on our end. |
@mwpowellhtx Since MSBuild will have no built-in support for .deps.json in SDK 2.x or 3.0, I think you should consider moving your codepath with complex dependencies into its own process and just invoking that during the build. |
I think we probably don't understand what you want to use the Let's assume that your task is called
If you want to "inspect" "a random" |
@vitek-karas My analysis thus far has us focused on the generators themselves, i.e. plug-ins to the Code Generation Engine. These are failing to load into the Code Generator assembly resolution, which I think, with 97% certainty, has to do with the failure to resolve the generators dependencies. Currently focused on a fat packaging approach for internal
Yes, we are trying to use the CompositeCompilationAssemblyResolver these during assembly resolution, but this is not working for the dotnet CLI tooling. Corollary with this approach, as we understand it, this may be similar to how NET Core / Standard are being built, but we did not receive adequate clues when we received feedback via Gitter channels in order to independently verify this. I apologize I do not have the comment link handy; through one of the pertinent MSBuild or CLI channels, I think. As long as our tooling can load the generator(s), including the generator dependency(ies), I think we have a path forward. Trying to at least verify that in the shortest distance possible. At the moment, using a custom build task and manually copying from the NuGet restored I should clarify here, restored and not resolved, because actual resolution is falling over at the moment. I do not think we are concerned about the target assembly, i.e. where the code generation will actually land. That is not the issue for us. Hopefully this helps improve the comprehension. |
Thanks a lot for your explanation. In this case you can at least try the It can also be the case that your generator has a dependency which something else already loaded and there's a version mismatch. In this case there's unfortunately not a simple solution. In theory you could be able to isolate your generator into its own But if it's only about not finding the right files, then the first approach should work - and that is pretty simple - look at the That said - if you build your generator as |
@vitek-karas This is the rub, at the moment this is part of the gap we must bridge. We need a |
@mwpowellhtx In that case:
|
@vitek-karas We are having this conversation because System.Runtime.Loader is failing to resolve those dependencies, at least in its current 4.3.0 form. See prior mentioned links, and please look at that so we're on the same page not talking past one another, if you please. Sounds like our near term path forward is in point of fact to dissect the .deps.json and do some manual, or at least custom task-based, resolving of the dependencies. |
@mwpowellhtx Sorry - I missed that part of your comment - my bad. It's hard to tell why it's failing... I can only guess:
I obviously don't know how exactly you build your generator component... when I try a simple Unfortunately we don't have good enough tracing available yet to be able to answer with relative ease exactly why it's failing. You should be getting at least an exception of some kind which should indicate which assembly is failing to resolve, but I personally don't have much experience with code generators in Roslyn. I just realized I didn't answer your question about the |
@vitek-karas No worries, I appreciate the clarification. So if we did anything with the .deps.json from a historical perspective, we would be considering contemporary API scaffold of sorts, that is, targeting the netstandard2.0, IL if you prefer, for purposes of rolling our own. That is if we found it necessary to peel that layer back at all. We are at a point, we are copying the asset dependencies from their resolved package locations, and poised to create a fat package. After that try to subscribe to it and use it as our code generator, including its dependencies in the package. We will see how far we get in that approach. Thanks again. |
@vitek-karas I should also mention, we do get an exception that the reference asset cannot be loaded, but that's all we get. There is no further detail, to my knowledge, no inner exception, etc, so it is not especially helpful. That is, was it because dependencies could not be loaded as well? Along these lines, as an educated guess-timate, at any rate. |
Can you share the type of exception you get? I'm just curious... we're working on improving diagnostics around the assembly loader/binder and it would help to know which cases are problematic. And yes - we know the diagnostics around this area right now is pretty bad, we're working on it (rather slowly unfortunately). |
@vitek-karas Sure, at the moment, along these lines:
In its current form, but I have been trying to wire out more informative messages in my working branch. However, I can say our Response File is trying to do the right thing. |
I find this interesting:
If that is running the code you're pointing at, it should pretty much never happen... or it could be bug in Microsoft.Extensions.DependencyModel - in which case I would be VERY interested. |
@vitek-karas As I stated earlier, I am mid-stream focusing on repackaging our code generation generators in a fat-package, and evaluating if that works any better resolving references. Will let you know how that goes. |
@vitek-karas Took me a bit longer than I anticipated to circle around on this one, however, it is still not working. I fat-packaged my code generators, the response file indicates those references would be loaded, ostensibly in the correct order, from least dependent to more dependent, and so on. The actual Response File my Code Generation facilitation generates is attached. Insofar as the dependencies have been correctly fat packaged, they are there in the references correctly, this much I can tell you at this moment. I need to review my code generation code re: the references in particular, but otherwise, I do not see how the assemblies could not be loaded. I will also add additional validation in my Edit: @vitek-karas The assets are indeed there, I validated my loaded
I will double check I am not simply loading the top-level asset, but indeed all of the actual dependency references. |
We have no plans to implement this for Full Framework MSBuild. We are working on this feature for .NET Core MSBuild using AssemblyLoadContext. |
@livarcocc Still unimplemented? https://github.com/dotnet/msbuild/blob/master/documentation/specs/task-isolation-and-dependencies.md mentions targeting .Net5. |
@zachrybaker We do not plan to change assembly loading behavior on .NET Framework. Further improving .NET Core/5.0+ load behavior is possible and tracked by #5037. |
This is a long-term feedback-desired issue.
See #1307 (comment), from @ericstj:
The text was updated successfully, but these errors were encountered: