Sandy
Sandy

Reputation: 1506

How to write to text file in post build event in Visual Studio?

I am creating a Windows Service in Visual Studio. On a post build event, I'd like to have 2 files created in the bin directory called install.bat and uninstall.bat. These files should have the name of the output EXE with a /u or /i in them. The name of the EXE should be dynamically written to the file, not hard coded. Is this possible?

Upvotes: 6

Views: 5640

Answers (1)

stijn
stijn

Reputation: 35901

Open the project properties, go to 'Build Events', click 'Edit Post-build ...' and make use of the provided 'Macros>>' to get the msbuild properties you're after. Something like this:

echo $(TargetFileName) /a > $(TargetDir)install.bat

Upvotes: 7

Related Questions