1

I am trying to create a Microsoft.Build.Framework.ITask-implementation which shall be used to perform some tasks at design time of another project ("Main") in VS.

The task is defined via

<UsingTask TaskName="Example.ZebusTask" AssemblyFile="D:\Example\bin\Release\net5.0\Example.dll" />

in the csproj-file of the Main project, and called via

<Target Name="GenerateMessage" BeforeTargets="CompileDesignTime">
    <ZebusTask InputFiles="@(Messages)" />
</Target>

where the Messages are defined by other item groups.

Building the task succeeds with no errors, but there is an error for the main project which I cannot resolve:

The "Example.ZebusTask" task could not be loaded from the assembly 
D:\Example\bin\Release\net5.0\Example.dll. Could not load file or assembly 
'file:///D:\Example\bin\Release\net5.0\Example.dll' or one of its dependencies. The system 
cannot find the file specified. Confirm that the <UsingTask> declaration is correct, that the 
assembly and all its dependencies are available, and that the task contains a public class 
that implements Microsoft.Build.Framework.ITask.

Using the Dependencies-tool, I noticed that at least two referenced dlls are missing in the Example.dll, one of them is Microsoft.Build.Utilities.Core. However, it is properly referenced in the Example.csproj.

I do not understand why the dll is incomplete but the build process does not throw an error. I also do not understand why the dll is missing in the first place. The documentation and build messages did not help, how can I further try to resolve this problem?

Carrot
  • 23
  • 5
  • Might have something to do with trying to use it with a different version of msbuild and/or build tools than what the task was built with; bit hard to tell without more information. One thing you could do to rule out different versions is build the custom task on the fly as shown here: https://stackoverflow.com/questions/25089520/how-to-create-msbuild-inline-task-from-multiple-source-files/25113818#25113818the task – stijn Sep 15 '21 at 08:04

0 Answers0