Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Defining custom macros to be used in build events

I am trying to define custom macros like pretty commonly done in c++ solutions to be used in, but not limited to, build events in .net core. For example, I would like to extend pre-defined macros such as $(SolutionDir) or $(ProjectDir) into $(MyCustomPath) = $(SolutionDir)\Data. Then in post build event I would like refer to the newly created $(MyCustomPath) such as

dotnet abc.dll MyCustomPath

I have reached the properties page but I have not seen where I can define new ones enter image description here

like image 458
Hasan Emrah Süngü Avatar asked Oct 30 '25 05:10

Hasan Emrah Süngü


1 Answers

I have never done this before, however you can do this

Edit your project file,

<PropertyGroup>
  <MYMACRO>Whatever you want here</MYMACRO>
  ...
</PropertyGroup>

Then in your build events you can call

$(MYMACRO)

To prove it works

enter image description here


enter image description here


enter image description here

like image 98
TheGeneral Avatar answered Nov 01 '25 20:11

TheGeneral



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!