I'm a new to MSBuild and wanted to play around with it a bit, but I just cannot figure out why this isn't working.
So my solution has two projects: "Model" and "BuildTasks". BuildTasks just has a single class:
using Microsoft.Build.Utilities;
namespace BuildTasks
{
public class Test : Task
{
public override bool Execute()
{
Log.LogMessage( "FASDfasdf" );
return true;
}
}
}
And then in the Model.csproj I've added this:
<UsingTask TaskName="BuildTasks.Test" AssemblyFile="$(SolutionDir)src\BuildTasks\bin\BuildTasks.dll" />
<Target Name="AfterBuild">
<Test />
</Target>
I've set up the build order so "BuildTasks" gets built before "Model". But when I try to build Model I get this error:
The "BuildTasks.Test" task could not be loaded from the assembly C:\WIP\TestSolution\src\BuildTasks\bin\BuildTasks.dll. Could not load file or assembly 'file:///C:\WIP\TestSolution\src\BuildTasks\bin\BuildTasks.dll' or one of its dependencies. The system cannot find the file specified. Confirm that the <UsingTask> declaration is correct, and that the assembly and all its dependencies are available.
This file definitely exists, so why can't MSBuild find it?
I've even tried hard-coding "C:\WIP\TestSolution" in place of "$(SolutionDir)" and get the same error. However, if I copy that .dll to my desktop and hard-code the path to my desktop, it DOES work, which I can't figure out why.
EDIT: I don't have the path wrong. I modified the Debug/Release builds for BuildTasks to output the .dll to just the bin folder since I didn't want Debug/Release to have different paths.