Mahima Chugh
Mahima Chugh

Reputation: 41

How to extend an existing rule in MS Build?

it's probably a stupid question, but I have wasted a lot of time.

I found this one and several other links where people are editing .xml, .props and .targets file to create a customization in Visual Studio build.

Adding new target to use ClCompile

Here he/she is extending CL rule in xml file and doing other things in .props and .targets file.

But as I am referring to MSBuild documentations, I cannot find a way to customize using these three files. I only found creating a custom target in .vcxproj file. However, when I try to extend a rule here, it just says

Rule is not an element of Project.

These are related documentations I found -

https://learn.microsoft.com/en-us/visualstudio/msbuild/customize-your-build?view=vs-2019

https://learn.microsoft.com/en-us/cpp/build/how-to-add-custom-build-tools-to-msbuild-projects?view=vs-2019

Has methods of adding customization changed or am I not referring to right documentations? Please help. Basically, I want to do what has been done in above stack overflow answer. (Create a preprocessing target which can get all properties/items of CLCompile target.)

Upvotes: 1

Views: 259

Answers (1)

Mahima Chugh
Mahima Chugh

Reputation: 1

I did manage to override ClCompile target by adding ClCompile.props and added my custom task in it by using Exec Command. It served my purpose and I didn't actually go through extending xml file.

Upvotes: 0

Related Questions