0

I am using MSBuild and I came across this topic called Targets that lets you perform some tasks before building the project.

I need to run a C++ function which is present in a .cpp file in my (.sln) solution file. I came across this example to run a task, but it is written in C#.

using System;
using Microsoft.Build.Utilities;

namespace SimpleTask1
{
    public class SimpleTask1: Task
    {
        public override bool Execute()
        {
            // This is where the task would presumably do its work.
            return true;
        }
    }
}

So basically, I want run a C++ function before the building my solution file and I am confused on how to use MSBuild tasks and targets for this purpose. This C++ function actually generates some code that is necessary for successful building, else the build would fail.

  • The C++ function needs to be built into a DLL where the function can be loaded from and "called". I assume that MSBuild have built-in functionality to do it using C#, but I have no idea if it's possible to do with C++. Perhaps if using managed C++ (C++/CLI) to build a .net module like is done for C#? – Some programmer dude May 12 '21 at 15:04
  • 1
    https://learn.microsoft.com/en-us/visualstudio/msbuild/task-writing?view=vs-2019 – rustyx May 12 '21 at 15:15

0 Answers0