You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The consuming project is a netcoreapp1.1. The task fails with an
System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.CodeAnalysis, Version=2.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
File name: 'Microsoft.CodeAnalysis, Version=2.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
exception.
When trying to load the package reference via AssemblyLoadContext.Default.LoadFromAssemblyPath I get
Could not load file or assembly 'Microsoft.CodeAnalysis, Version=2.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.
without any additional information. This does not work when running in a .net core console application either. I tried a second (simpler) package, which can be loaded via LoadFromAssemblyPath in a .net core console application, but still it does not work when running as dotnet build Task.
Both assemblies can be loaded when running in classical net4.6 with Assembly.LoadFile in a console application and when running as Task though.
The text was updated successfully, but these errors were encountered:
Dresel
changed the title
[Question] Can Microsoft.CodeAnalysis be referenced within a Task?
[Question] Can package references be referenced within a Task when running with dotnet build?
Jun 9, 2017
No, this isn't currently possible. Nothing can read the dependencies of the DLL delivers the task to correlate them with the dependencies of MSBuild itself and have the loader figure out what to load.
What you can do is redistribute the (closure of) dependencies of your task assembly in the same folder as the task, and MSBuild's loader will find them there.
I'm going to close this in favor of #1756 and whatever eventual design comes out of that.
Is it possible to use package references like Microsoft.CodeAnalysis within a Microsoft Build Task running with dotnet build?
I'm using
netstandard1.5
for the task library and the following package references:The consuming project is a
netcoreapp1.1
. The task fails with anexception.
When trying to load the package reference via
AssemblyLoadContext.Default.LoadFromAssemblyPath
I getCould not load file or assembly 'Microsoft.CodeAnalysis, Version=2.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.
without any additional information. This does not work when running in a .net core console application either. I tried a second (simpler) package, which can be loaded via
LoadFromAssemblyPath
in a .net core console application, but still it does not work when running as dotnet build Task.Both assemblies can be loaded when running in classical net4.6 with
Assembly.LoadFile
in a console application and when running as Task though.The text was updated successfully, but these errors were encountered: