Microsoft has good documentation on writing custom build tasks, but it contains snippets and doesn't give the full picture.
What does a minimal but complete project that achieves the following look like?
- Builds an executable that is written in C#
- Executes a build task that is written in C#
A valid example could be a build task that does nothing, but runs, and an application that does nothing except return 0.
If the answer is different for .NET Framework v4.5 vs .NET Core 2.0, then it would be good to know what that difference is. I anticipate that there are several valid configurations, such as
- Application and build tasks are separate csproj files, or a single one.
- Building the tasks into a separate dll or not.
- Running the task before/after compiling the application or when the solution is loaded or not running it automatically at any point, but making it available to batch scripts and on the command line.
So the question is, which configuration is the most minimal and what does it look like?
.
Additional background: The only bit of documentation I've been able to find about connecting the task to your project recommends UsingTask, which references a DLL that contains the task. This implies having the task in a separate csproj or even solution, and building separately. However, the examples I was able to find on GitHub where people appear to be using custom build tasks do not use this approach. I have, for example, a 3rd-party sln loaded right now where UsingTask is nowhere in sight, yet Visual Studio shows and runs a custom build task .cs file in the solution explorer underneath one of the projects (even though that .cs file is not mentioned anywhere in the project's .csproj file!). So it seems to me that UsingTask is not the only way to achieve project/task linkage, and probably not the simplest either.