Skip to content
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

[Question] Is it possible to dynamically load Microsoft.CodeAnalysis via LoadFromAssemblyPath? #20134

Closed
Dresel opened this issue Jun 9, 2017 · 1 comment

Comments

@Dresel
Copy link

Dresel commented Jun 9, 2017

I tried loading Microsoft.CodeAnalysis.dll via AssemblyLoadContext.Default.LoadFromAssemblyPath within a dotnet core application. This fails with an System.IO.FileLoadException: 'Could not load file or assembly 'Microsoft.CodeAnalysis, Version=2.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.' exception.

Is this supported or somehow possible?

@stazz
Copy link

stazz commented Jun 19, 2017

Hi Dresel,

Regarding you actual problem, loading third-party NuGet dependencies in MSBuild tasks: It seems you bumped into same problem as I did, and originally was discussed in msbuild/1756. Currently, there is no proper solution provided by framework when your MSBuild task references third-party nuget packages.

However, while the framework solution is incoming (if it is incoming), feel free to use UtilPack.NuGet.MSBuild library. It does not require you to redistribute the (closure of) dependencies of your task assembly with your NuGet package, and it does not even require you to place your assemblies in build folder (lib folder is enough, but build works too). It works by providing a task factory, which will then take care of dynamically loading the third-party nuget dependencies for your task.

Hope this helps you in your problem, feel free to tell me if it doesn't!

@Dresel Dresel closed this as completed Nov 21, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants