0

I want to stop msbuild default "build" target to stop building my code instead, i want to define my custom target which will build my application. how to achieve this?

Thanks,

golf89
  • 111
  • 1
  • 7

1 Answers1

1

Just open the csproj file of your project.

And add these at the bottom of the file:

<Target Name="Build">

//write your custom build function

</Target>

It will overwrite the default build and use yours.

Mr Qian
  • 21,064
  • 1
  • 31
  • 41
  • when i added this in csproj, not effect but when i added these line in my msbuild extension and i could see that default build is stopped. I ma checking further. – golf89 Feb 23 '21 at 11:16
  • Or you could create a file called Directory.Build.targets in your project folder and then add my function into the file. – Mr Qian Feb 23 '21 at 15:40
  • create a file and use the same thought under [this issue](https://stackoverflow.com/questions/66224433/c-sharp-nuget-package-output-location-advise). – Mr Qian Feb 24 '21 at 02:01
  • when i added above code in my csproj, it is not working. I have MSBuild extension in my project. as i mentioned earlier if i add this in extension, it works but in my case i want this behavior for few project and default build for few projects. Can you suggest what could be issue when i put in csproj file? – golf89 Feb 25 '21 at 04:18
  • Hi Perry Qian-MSFT , when I placed (Directory.Build.targets) in my project with Build target, worked for C# project, how ever when put same file in c++ project, Custom build target is not getting executed. Can you help for c++ project as well? – golf89 Jun 17 '21 at 05:56