Reputation: 35
The Objective
I am writing a custom MSBuild task to handle Azure deployments locally (instead of Azure CLI, Azure Powershell, etc.). The task is using the Azure Resource Manager client library. Once the build is complete on a project, the task does authentication to Azure then uses reflection and performs the following:
The Problem
When running the build on the target project, the task is throwing the following exception (I've excluded the entire stacktrace for brevity):
error MSB4018: System.IO.FileNotFoundException: Could not load file or assembly 'Azure.ResourceManager, Version=1.11.0.0, Culture=neutral, PublicKeyToken=92742159e12e44c8'. The system cannot find the file specified. [C:\Development\Services\Service.csproj]
error MSB4018: File name: 'Azure.ResourceManager, Version=1.11.0.0, Culture=neutral, PublicKeyToken=92742159e12e44c8' [C:\Development\Services\Service.csproj]
error MSB4018: at System.Delegate.BindToMethodInfo(Object target, IRuntimeMethodInfo method, RuntimeType methodType, DelegateBindingFlags flags) [C:\Development\Services\Service.csproj]
...
This exception is being thrown from task at the following line:
Setup setup = setupMethodInfo.CreateDelegate<Setup>(azDeployment) as Setup;
It looks as though when attempting to create the delegate, its failing to find the assembly even though the target project builds just fine with the necessary references (Azure.ResourceManager). It seems to be searching by filename as per the second line in the exception output. Here is the method in the target project that is being loaded and converted to a delegate in the task:
private void Setup(ArmClient client){}
The Question
Why can't the task find the assembly in the CreateDelegate method? Why does it seem to be searching for a file with a full assembly name instead of an actual filename?
Upvotes: 0
Views: 52