Interpreting really strange error message - visual-studio-2013

I'm messing around with some very complex build definitions in VS/TFS 2013 and the build is failing with the following error message:
C:\Program Files (x86)\MSBuild\12.0\bin\Microsoft.Common.CurrentVersion.targets (1131): The command "cd C:\Builds\34\GEARView\Copy of GV-All\Sources\GEARView\RecordViewer\
attrib -r "C:\Builds\34\GEARView\Copy of GV-All\Sources\GEARView\RecordViewer*" /S /D
C:\Builds\34\GEARView\Copy of GV-All\Sources\GEARView\RecordViewer\Build.bat" exited with code 9009.
So what I don't get is what is failing? There's a "cd" at the beginning of the message, so is that failing or is it the "attrib" in the middle of the message or is it actually calling Build.bat and that's failing?
And while I'm here I might as well ask another question, which is what on earth could be calling Build.bat? I searched all files in source control and couldn't find the string "build.bat".

I took the spaces out of the name of the build definition and the problem went away ;-).

Related

Visual Studio Post Build Event if exists

I want to call a batch file in my post build step in Visual Studio. Locally the batch file exists, just the command
call "$(SolutionDir)PostBuildSen.bat" "$(TargetDir)" "$(TargetName)"
correctly calls and executes the batch file.
However when I want to check if the batch file exists first (since others will use the same Post Build Event), I get the error
:VCEnd" exited with code 255.
The command is
if exists "$(SolutionDir)PostBuildSen.bat" call "$(SolutionDir)PostBuildSen.bat" "$(TargetDir)" "$(TargetName)"
The Diagnostic output tells me
2> Done executing task "Exec" -- FAILED.
How do you handle this?
The Solution Directory contains a folder with an underscore, i.e. \Dev_Main\ and I have read that for the batch file that is to be called at least that doesn't work. However I am not sure if that is the issue with folders as well and how to cope with it. Also, since the call command works, I am not sure this is the problem.
Furthermore, if I replace the call with cmd /C, the exit code is 1 and the (minmal) output tells me
1>The filename, directory name, or volume label syntax is incorrect.
Also, I will add this as a custom command to a CMakeLists file later on, so the solution needs to work with that.
Thanks to Hans Passant's comment, I solved the problem. The query for the file needs to be if exist rather than if exists.

cmd.exe returns "Not enough storage is available to process this command."

...have been running Widows 7 Pro with STARTUP folder modified to run two BATs to create two CMD boxes, one left and one right. A few days ago at logoff time 13 updates to Windows7 were installed and at logon the next day the two CMD boxes had a new error message preceding the command prompt:
"Not enough storage is available to process this command."
Typing in "DIR /X" at the command prompt does return the directory list but with three error messages:
1. The system cannot find message text for message number 0x235f in the message file for Application.
2. The system cannot find message text for message number 0x235b in the message file for Application.
3. DNS bad key
...i.e. none of the usual DIR text annotations.
Now, from the command line, any BAT file with "cmd /k" in it produces the same box with the same errors.
Modifying a BAT file to call "C:Windows\System32\cmd.exe /k" instead of simply "cmd /k" solves the BAT problem on the command line...AND making this change in the two STARTUP BATs solves the problem at startup. However, this is just a temporary work-around. The bare "cmd" without the full path will fail.
CORRECTION: as suggested by Harry Johnston below, there was another cmd.exe present, this one in C: identical to the one in C:\Windows\System32 and after giving it an alias the STARTUP BATs work OK. So this post becomes a trivial anomaly which may or may not have resulted from a Windows update, and may be deleted.
Does anyone know what updates to Win7 caused this problem, and how they might be uninstalled. Good ol' WinXP would have a long list of them.
There's a lot of interesting and relevant info here:
https://superuser.com/questions/159034/spurious-out-of-memory
and here:
http://blog.airesoft.co.uk/2009/10/desktop-heap-monitor-vista-7/
but maybe someone has a quick answer.
..Thanks for any reply.
Encountered same problem, And there was a spurious copy of "cmd" sitting around. Tx

Why do all Pre-build or Post-build events in Visual Studio fail with exit code 1?

My goal is copying an .exe file from a bin folder of solution A to another solutions B resource folder on the post build event of solution A.
I created the necessary xcopy command and tried it out in powershell: It works perfectly.
Whenever I add any command to the actions in VS build fails with: "#command# exited with code 1", where #command# is, for example, the xcopy command.
I tried running VS as admin and currently I tried just running a .bat file that contains "#echo off #exit 0". That too leads to "#command# exited with code 1".
Have some example of what I tried out as VS post/pre-build command:
call "projdir\test.bat"
call projdir\test.bat
"projdir\test.bat"
projdir\test.bat... I tried projdir as "$(ProjectPath)" and manual path.
I put output to verbose and found the following:The command "C:\Users\Traubenfuchs\AppData\Local\Temp" is written incorrectly or couldn't be found. (That folder actually exists but I don't know what it wants to do it.)The same thing happens when I put an xcopy command in pre/post build.
Anyone knows what I am doing wrong?
Recently I met similar problem.
About your "hello world" post-build event :
try to call powershell directly
powershell -command "write-output 'hello world'; exit 0"
=================
My pre-build event looks like :
powershell -file scriptPath.ps1
My scriptPath.ps1 looks like :
<my epic powershell code>
...
exit 0
Note that without "exit 0" at the end I recieved return code 1 from my script.
We had this issue because of a "Software Restriction Policy" set up in a domain GPO. It appears that pre and post builds create a .cmd batch file in the temp folder. Here's what the logging showed me:
cmd.exe (PID = 8456) identified
C:\Users\brian\AppData\Local\Temp\tmp733425d2c0604973a90a0a175c13353e.exec.cmd
as Disallowed using default rule, Guid =
{11015445-d282-4f86-96a2-9e485f593302}
To fix this we modified the GPO that controlled the SRP so that it did not include .cmd files. After all, the goal of SRP is to block executable malware, not batch files. I may get some security blowback because of this. Hopefully someone knows a better way to fix this issue.
One possible issue is that you have to use $(ProjectDir) instead of $(ProjectPath)
When you use $(ProjectPath) it is actually: "C:\Users\....\Project\MyProject.csproj"
Versus $(ProjectDir) which is: "C:\Users\....\Project\"
Notice, that the first version is actually pointing to your project solution file... which would cause everything to fail.
Another is that that $(ProjectDir) automatically adds the trailing slash to the path. i.e. "$(ProjectDir)\test.bat" would actually translate to: "C:\Users\....\Project\\test.bat"
Also you have to make sure that you enclose all your file paths in double quotes
So the correct call would look like this:
call "$(ProjectDir)test.bat"
Other things to check out would be to make sure that the directory that the script is executing from is correct. See SO: visual studio 2012, postbuild event, bat file not creating new file (not executing)
Have you checked out the suggestions in this StackOverflow? Post Build exited with code 1
Edit
Try this:
echo Hello World
#exit 0
You need to end any commands with #exit 0 otherwise it doesn't think that it finished properly
Edit 2
Why do we use #exit 0 instead of exit 0? #Sunny has a good explanation of the At symbol - # here:
The # symbol tells the command processor to be less verbose; to only
show the output of the command without showing it being executed or
any prompts associated with the execution. When used it is prepended
to the beginning of the command, it is not necessary to leave a space
between the "#" and the command.
Essentially if you call xyz.bat by default every command in the .bat file is echoed back along with the actual output of the command. e.g.:
test.bat
echo Hello World
exit 0
Will output:
C:\>call test.bat
C:\>echo Hello World
Hello World
C:\>exit 0
C:\>
When we add a # in front of the commands, we only get the output of the commands themselves.
test2.bat
#echo Hello World
#exit 0
Will output:
C:\>call c.bat
Hello World
C:\>
#echo off is also a way to turn this off for the rest of the script. We typically do this simply to make the logs easier to read, as the text of the commands muddies the log output.

How to interpret pre build error codes from Visual Studio 2010

I have been working with Visual Studio pre build events and I find the error codes rather unhelpful
for example, adding a pre-build event like this:
$(ProjectPath)\DoStuff.exe
This gives me an error: exited with code 267
Or adding like this:
$(ProjectDir)\DoStuff.exe
This gives me an error: exited with code 9009
After a bit of poking about it's possible to figure out what needs to be changed to get the command line to work, but it would probably be far simpler if I could look up the error code and see what it meant.
I have tried google with some of these error codes but some are really hard to find any information about - for example 267 seems rather elusive.
Is there a list somewhere that defines all these error codes?
:)
Avoid shooting the messenger. Talk to the owner of DoStuff.exe and ask what these process exit codes mean.
If you have reason to believe that DoStuff is buggy and doesn't set the exit code properly then you can work around it by resetting the %errorlevel% value. Make it look like this:
dostuff.exe
cmd /c ""
The error codes you see could be Windows error codes as declared in the SDK's WinError.h file. Error 267 is ERROR_DIRECTORY, "The directory name is invalid". Error 9009 is DNS_ERROR_RCODE_NOTAUTH, "DNS server not authoritative for zone".

error MSB3073: copy /d "C:\LOANAPP\UX\UserControls\*.css" "C:\LOANAPP\UX\GetQuotations\ThirdPartyOperator\CSS"" exited with code 1

We get this error in a project in a web application solution which has VSS as source control. The project has a script in the pre-build event command line in the VS 2005 Project property page - Build event is as below :
copy /d "$(SolutionDir)UX\UserControls\*.ascx" "$(SolutionDir)UX\GetQuotations\ThirdPartyOperator\UserControls"
copy /d "$(SolutionDir)UX\UserControls\*.master" "$(SolutionDir)UX\GetQuotations\ThirdPartyOperator\UserControls"
copy /d "$(SolutionDir)UX\UserControls\*.js" "$(SolutionDir)UX\GetQuotations\ThirdPartyOperator\Javascript"
copy /d "$(SolutionDir)UX\UserControls\*.css" "$(SolutionDir)UX\GetQuotations\ThirdPartyOperator\CSS"
gives this below error:
=============================================================
C:\LOANAPP\UX\UserControls\dhtmlwindow.css
C:\LOANAPP\UX\UserControls\modal.css
2 file(s) copied.
C:\LOANAPP\UX\UserControls\dhtmlwindow.css
**Access is denied.**
C:\LOANAPP\UX\UserControls\modal.css
**Access is denied.**
0 file(s) copied.
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Microsoft.Common.targets(823,9): error MSB3073: copy /d "C:\LOANAPP\UX\UserControls\*.ascx" "C:\LOANAPP\UX\GetQuotations\ThirdPartyOperator\UserControls"
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Microsoft.Common.targets(823,9): error MSB3073: copy /d "C:\LOANAPP\UX\UserControls\*.ascx" "C:\LOANAPP\UX\GetQuotations\ThirdPartyOperator\UserControls"
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Microsoft.Common.targets(823,9): error MSB3073: copy /d "C:\LOANAPP\UX\UserControls\*.master" "C:\LOANAPP\UX\GetQuotations\ThirdPartyOperator\UserControls"
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Microsoft.Common.targets(823,9): error MSB3073: copy /d "C:\LOANAPP\UX\UserControls\*.js" "C:\LOANAPP\UX\GetQuotations\ThirdPartyOperator\Javascript"
**C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Microsoft.Common.targets(823,9): error MSB3073: copy /d "C:\LOANAPP\UX\UserControls\*.css" "C:\LOANAPP\UX\GetQuotations\ThirdPartyOperator\CSS" exited with code 1.**
Because of this error we have whole solution build failing.
Could anyone help us out, so that we would be able to proceed with...
I am currently encountering the same problem.
Deleting the Release/Debug build directory prior to building you solution solves the issue for one build.
When rebuilding it after that, this has to be done again though...
I'll post a real solution when I find one...
Edit:
After investigating the problem some more, I found out that the problem in my solution occured because the copy command in my post-build step resulted in questions about whether or not to overwrite existing files. This somehow generates this problem.
The solution for me was to add the '/y'option to the copy/xcopy command you execute so these overwrite questions won't be asked.
If you rename the project name or change the name of the output file, change it in the post-build events and this can be solved.
error MSB3073: copy /d "C:\LOANAPP\UX\UserControls*.css" "C:\LOANAPP\UX\GetQuotations\ThirdPartyOperator\CSS" exited with code 1.
When a pre/post build command "exits with code 1", that means it failed. Just like if you said, "copy *.* f:\lolusux" and you didn't have a writable f: drive.
The solution is to fix the error.
What is the error, you say? I don't know. But I know how I'd go about figuring it out.
Run the build. In the build output, copy the pre/post build commands as you did in order to paste them into your question. They will have all the macros filled in with actual values, which may be part of the issue.
Paste this into Notepad. Clean all the cruft away (i.e., delete non-command text such as "error MSB3073: " and keep command text like "copy /d "C:\LOANAPP\UX\UserControls*.css" "C:\LOANAPP\UX\GetQuotations\ThirdPartyOperator\CSS")
Open a command window. Browse to the output directory of the project that fails to build. That's the root directory where these commands execute.
(optional for post build) disable post build commands and build the solution; this may be needed to make sure the files are in the expected state when the post build commands run.
Copy each line of the pre/post build commands from notepad, paste them into the command window, and execute them. From first to last, one by one. You will see the command fail (if you did everything right, if not, go back) and get the exact error message/cause of the failure.
Fix the real issue.
Just in case anyone finds that their problem isn't resolved by any of the above, I found that the error was being caused by folders in the path with spaces in their names. For instance:
MyFolder\ThirdParty Test\Blah\MoreFolders\BuildDirectory
...would fail, but
MyFolder\ThirdPartyTest\Blah...
Would work without issue. If you need to have the space in the path, surround the entire directory call in double quotes, like:
"MyFolder\ThirdParty Test\Blah\MoreFolders\BuildDirectory"
Or just the offending folder:
MyFolder\"ThirdParty Test"\Blah\MoreFolders\BuildDirectory

Resources