GrayFox
Posts: 8
Joined: Wed Jan 23, 2019 9:07 pm

Post-Build Event write to txt

I have a Post-Build Event that should write the [ProductVersion] to a txt file. I have the following parameter set for the event. When I build the event CMD launches but the arguments aren't getting passed. Any thoughts?

Command: cmd.exe
Arguments: echo [|ProductVersion] > C:\inetpub\wwwroot\Builds\version.txt
Catalin
Posts: 6585
Joined: Wed Jun 13, 2018 7:49 am

Re: Post-Build Event write to txt

Hello,

The "Launch File" custom action is basically a "CreateProcess" function.

This custom action is similar to the run (WIN+R) command from the Windows OS.

For testing purposes, you could try to run the whole command in a run window (simply press WIN+R button). It would look something as it follows:

Code: Select all

cmd.exe echo Something > C:\inetpub\wwwroot\Builds\something.txt
The result will be the same as from within the "Launch File" custom action, the arguments will not be passed to the command prompt.

In order to make this work, we can make use of the following option: "/c". This command will create a process which will run command and then terminate after the command execution is completed. The whole command would look something as it follows:

Code: Select all

cmd.exe /c echo Something > C:\inetpub\wwwroot\Builds\something.txt
Additionally, your custom action should look something as it follows:

File to launch: cmd.exe
Command line: /c echo Something > C:\inetpub\wwwroot\Builds\something.txt


Hope this helps.

All the best,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
GrayFox
Posts: 8
Joined: Wed Jan 23, 2019 9:07 pm

Re: Post-Build Event write to txt

Thanks! Adding the /c to the argument worked!
Catalin
Posts: 6585
Joined: Wed Jun 13, 2018 7:49 am

Re: Post-Build Event write to txt

You are always welcome.

Glad I could help.

All the best,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”