I'm trying to call a script via bash.exe in the post-build events from visual studio (actually atmel studio 7.0, which is based on vs)
I'm getting the following error when i try this:
"$(SystemRoot)\System32\bash.exe"
The following error is reported:
Task "Exec"
"C:\Windows\System32\bash.exe"
'"C:\Windows\System32\bash.exe"' is not recognized as an internal or
external command, operable program or batch file.
C:\Program Files (x86)\Atmel\Studio\7.0\Vs\Avr.common.targets(36,5): error: MSB3073:
The command ""C:\Windows\System32\bash.exe" " exited with code 9009.
I even tried copying bash.exe to another destination, but that had the same problem.
Any advice?
Thanks!
solution found here: https://gist.github.com/m93a/cb41dcbd72ee7ff9fea3726a28d9f895
don't call bash.exe directly, but call this .bat file instead
Related
This is somewhat similar to the question asked here.
Issue in VS 2019 build with editbin.exe location
I have a post build task in my project like this:
call "%VS160COMNTOOLS%VsDevCmd.bat"
gacutil.exe /f /silent /i "$(TargetDir)$(TargetFileName)
Visual Studio upon building, is unable to resolve the macro, %VS160COMNTOOLS% - it resolves to an empty string with the following output:
'"VsDevCmd.bat"' is not recognized as an internal or external command, operable program or batch file.
'gacutil.exe' is not recognized as an internal or external command, operable program or batch file.
Why is this and how do we make Visual Studio recognize the macro? The same macro resolves correctly in VS2019 command prompt. Why is this?
Visual Studio 2019, Windows 11. IBM Blockchain Platform Tutorial, A5: Invoking a smart contract from an external application, step A5.26: In the main VS Code menu, click 'Terminal' -> 'Run Build Task...':
I get the error below:
Executing task in folder src: msbuild /property:GenerateFullPaths=true /t:build /consoleloggerparameters:NoSummary
'msbuild' is not recognized as an internal or external command,
operable program or batch file.
The terminal process "C:\WINDOWS\System32\cmd.exe /d /c msbuild /property:GenerateFullPaths=true /t:build /consoleloggerparameters:NoSummary" terminated with exit code: 1.
Every step runs good to this point. VS is updated. Need help. If you offer any advice, please be specific. I am not a programmer or developer, have some experience but not much. I won't know what runs on /PATH/xxx/version...unless you tell me what 'xxx' is. I have written a blockchain (through a tutorial) and got it to run. Thanks. Just trying to learn.
Start VS Code by running code.exe from a Developer Command Prompt for VS 2019 (which is in the the Windows start menu under Visual Studio 2019). That will setup the path correctly to use VS2019 tools, including msbuild. And VS Code will inherit that path so will have access to msbuild.
When I try to call vscall.bat or vcvarsall.bat in my x64 Native Tools Command Prompt for VS 2019, I get the error showed in the title. I tried following this tutorial: How to tell CMake where to find the compiler?
Does anyone know how to fix this?
When I try to call vscall.bat or vcvarsall.bat in my x64 Native Tools Command Prompt for VS 2019
Since you are already in the x64 Native Tools Command Prompt for VS 2019 you do not need to call vcvarsall.bat. It was already done when you opened that command prompt.
I am using VS2019 community and I've set pre-build event:
msbuild "$(ProjectPath)" /t:Clean
I am getting error:
'MSBuild' is not recognized as an internal or external command,
operable program or batch file
How is this possible? Isn't this command supposed to be build into visual studio?
I've checked this and tried to set path environment, but it doesn't help.
Does anybody else has the same problem with this command in VS2019?
Steps that work in my machine:
See this, first we need to make sure MSBuild can be recognized by cmd.exe.
If the command can be recognized by cmd.exe but not build-event from VS, restart the PC can help resolve this issue.
(Something strange is that for my VS still can't recognize it until a restart of the computer)
For VS2019, the correct msbuild path is C:\Program Files (x86)\Microsoft Visual Studio\2019\xxx\MSBuild\Current\Bin
And here's another workaround:
Apart from adding the path of msbuild.exe into Environment Path and call it in pre-build event, you can also consider using MSBuild Task.
Add script below into xx.csproj:(work for .net framework...)
<Target Name="MyCleanBeforeBuild" BeforeTargets="BeforeBuild">
<MSBuild Projects="$(ProjectPath)" Targets="clean"/>
<!--<Message Text="Custom Clean" Importance="high"/>-->
</Target>
With latest update to VS2019 - version 16.3.4 - the error is no longer there.
Using "dotnet" instead of "msbuild" could work if you got that installed.
So, in my case, instead of running "msbuild /t:restore" I figured I can use "dotnet build" and have the same result.
Here's the documentation in case you want to see more equivalent commands.
https://learn.microsoft.com/en-us/dotnet/core/tools/
Hi I am running following command from my post build event:
C:\Program Files\Microsoft SDKs\Windows\v7.0A\bin\mt.exe -manifest "$(ProjectDir)$(TargetName).exe.manifest" -updateresource:"$(TargetDir)$(TargetName).exe;#1"
It is failing with Exited with code 9009... I don't understand why this happens; any suggestions?
Try adding quotes around the mt.exe path, e.g.:
"C:\Program Files\Microsoft SDKs\Windows\v7.0A\bin\mt.exe"
Also, make sure that path is valid.
Hope this helps. I've been beating my head against code 9009 all day and a full quoted path seem to make it work.
Exit code 9009 is a file not found error. The spaces that exist in your path to the post build command cause errors in a command prompt unless you include quotes around the entire path and executable name. Essentially, in your post-build command, it is trying to execute C:\Program with the arguments:
Files\Microsoft
SDKs\Windows\v7.0A\bin\mt.exe
-manifest "$(ProjectDir)$(TargetName).exe.manifest"
-updateresource:"$(TargetDir)$(TargetName).exe;#1"
Since obviously you don't have a file called Program residing in your root directory, this entire command fails. Encapsulating the path and executable in quotes will cause the entire expression to be evaluated as a single command, so everything should work fine if you change the post-build command to:
"C:\Program Files\Microsoft SDKs\Windows\v7.0A\bin\mt.exe" -manifest "$(ProjectDir)$(TargetName).exe.manifest" -updateresource:"$(TargetDir)$(TargetName).exe;#1"
Or use for VisualStudio x86 in Windows x64
"C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\bin\mt.exe"
Here is a potential solution:
You can use the Post build event
functionality of Visual Studio to do
this typing the command above: mt.exe
-manifest app.manifest -outputresource:myapplication.exe;#1. This probably won't work and Visual
Studio will give you an error like
"...exited with code 9009...".
You have to edit the csproj file using
for example the notepad and uncomment
the XML tags related to the Target
Name="AfterBuild" (you can find them
at the end of the file usually). Then,
place the tags related to the
PostBuildEvent within the tags related
to the AfterBuild and then, reload the
project and compile. It will produce a
.exe file that needes to be execute
with Administrator permissions.
Until reading this thread, I foolishly assumed VS would know where mt.exe lives. +1 to #james
Since there's no built-in macro for the current SDK, I relied on the system envar, windowssdkdir
"%windowssdkdir%\bin\mt.exe"