Reputation: 323
I have a custom MSBuild task that is contained in a NuGet package. The build directory of the package has a target file that uses the task so the user only has to add a package reference for the MSBuild task to execute.
That part works fine. However, package dependencies for my custom task are not being resolved so MSBuild is throwing an exception saying the assembly is not found,
Any ideas?
Upvotes: 0
Views: 752
Reputation: 100581
You need to include all the dependencies next to your task dll file so MSBuild can find them. Those dependencies don't have anything to do with the dependencies or package dependency graph of the project being built but just MSBuild loading dll files.
I suggest having a look at https://github.com/AArnott/Nerdbank.MSBuildExtension which is a tool NuGet package that helps building MSBuild tasks that can work on .NET Core and .NET Framework MSBuild (dotnet
tools and msbuild.exe
) with a task base class that helps isolating dependencies, since you can't load assemblies that conflict with those loaded into VS already or conflict with dependencies of another task.
Upvotes: 1