question

KeyhoonKo-6110 avatar image
0 Votes"
KeyhoonKo-6110 asked TianyuSun-MSFT commented

Post-buld event error

I have an error message when I put a command like "echo test2" in Post-build event command line as attached.
The command works in DOS command as shown 117494-post-build-error.jpg


vs-msbuild
post-build-error.jpg (111.5 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

KeyhoonKo-6110 avatar image
0 Votes"
KeyhoonKo-6110 answered TianyuSun-MSFT commented

Tianyu,
Thank you for your support.

I tried VS repair, but it doesn't work.
Please see the attached image which shows system environment variables.
119446-image.png



image.png (235.9 KiB)
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @KeyhoonKo-6110 , yes, the system environment variables are set well. Try this: reset VS settings, in VS > Tools > Import and Export Settings… > Reset all settings > select “No, just reset settings, overwriting my current settings > choose General > Finish”.

Besides, you can also try to start VS under safe mode, and this will avoid the other extensions’ impact, but may not work for WinForm project, as some components will not be loaded.

0 Votes 0 ·
KeyhoonKo-6110 avatar image
0 Votes"
KeyhoonKo-6110 answered TianyuSun-MSFT commented

Tianyu,
Thank you for your quick response.

I created a new win form application, and add post-bult with "Always" for Run the post-build event option as you recommended 2).
I captured the Output window with your suggestion of 3).

The highlighted Korean says
"C:\Users\=====" is not an internal or external command, executable or batch file.

However, I found my user path includes "(----)" as shown attached.


117955-image.png


117974-image.png



image.png (136.9 KiB)
image.png (124.6 KiB)
· 3
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @KeyhoonKo-6110 , thanks for the detailed information. Still, I can’t reproduce your issue. I wonder 1). did you change some settings of VS? 2). Did you set/modify/add the environment/system variable? 3). Did you install some extensions? 4). Could you please share me the snippets of your .csproj file?

0 Votes 0 ·

TTianyu,
I can't remember if I changed any settings, environment/system variables/extensions.
II created a project and just added post-build events.

I attached csproj file after changed its extension to log.

[1]: /answers/storage/attachments/119138-windowsformsapplication1.log

0 Votes 0 ·

Hi @KeyhoonKo-6110 , I tested with the proj file that you provided and even changed to use Korean, it passed on my side. Please check if the C:\windows\system32 environment variable has been set on your machine. And try to repair VS from VS Installer.

0 Votes 0 ·
TianyuSun-MSFT avatar image
0 Votes"
TianyuSun-MSFT answered

Hi @KeyhoonKo-6110 ,

Welcome to Microsoft Q&A forum.

Tested on my side, but failed to reproduce your issue, the echo test2 post-build event worked on my side.

Generally, this command should work. I suggest you check these aspects:

1). Rebuild your solution.

2). Change the Run the post-build event from On successful build to Always and then rebuild your project.

3). Please switch to check the Output window to see the detailed error message(Tools > Options > Projects and Solutions > Build And Run > MSBuild project build out verbosity: > Detailed/Diagnostic > OK).

4). Perhaps this error is caused by specific development environment, if this issue is reproducible(by using a new project), please share the steps with me to reproduce your issue.

Best Regards,
Tianyu


If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.