What does "exited with code 9009" mean during this build?

.NetVisual Studio

.Net Problem Overview


What does this error message mean? What could I do to correct this issue?

> AssemblyInfo.cs exited with code 9009


The problem is probably happening as part of a post-build step in a .NET solution in Visual Studio.

.Net Solutions


Solution 1 - .Net

Did you try to give the full path of the command that is running in the pre- or post-build event command?

I was getting the 9009 error due to a xcopy post-build event command in Visual Studio 2008.

> The command "xcopy.exe /Y C:\projectpath\project.config C:\compilepath\" exited with code 9009.

But in my case it was also intermittent. That is, the error message persists until a restart of the computer, and disappears after a restart of the computer. It is back after some remotely related issue I am yet to discover.

However, in my case providing the command with its full path solved the issue:

c:\windows\system32\xcopy.exe /Y C:\projectpath\project.config C:\compilepath\ 

Instead of just:

xcopy.exe /Y C:\projectpath\project.config C:\compilepath\

If I do not have the full path, it runs for a while after a restart, and then stops.

Also as mentioned on the comments to this post, if there are spaces in full path, then one needs quotation marks around the command. E.g.

"C:\The folder with spaces\ABCDEF\xcopy.exe" /Y C:\projectpath\project.config C:\compilepath\

Note that this example with regards to spaces is not tested.

Solution 2 - .Net

Error Code 9009 means error file not found. All the underlying reasons posted in the answers here are good inspiration to figure out why, but the error itself simply means a bad path.

Solution 3 - .Net

It happens when you are missing some environment settings for using Microsoft Visual Studio x86 tools.
Therefore, try adding as a first command in your post-build steps:

For Visual Studio 2010 use:

call "$(DevEnvDir)..\Tools\vsvars32.bat"

As @FlorianKoch mentioned in comments, for VS 2017 use:

call "$(DevEnvDir)..\Tools\VsDevCmd.bat"

It should be placed before any other command.
It will set environment for using Microsoft Visual Studio x86 tools.

Solution 4 - .Net

Most probably you have space in your resultant path.

You can work around this by quoting the paths, thus allowing spaces. For example:

xcopy "$(SolutionDir)\Folder Name\File To Copy.ext" "$(TargetDir)" /R /Y /I

Solution 5 - .Net

Had the same variable after changing PATH variable from Environmental Variables in Win 7. Changing back to default helped.

Solution 6 - .Net

I have had the error 9009 when my post build event script was trying to run a batch file that did not exist in the path specified.

Solution 7 - .Net

My exact error was

The command "iscc /DConfigurationName=Debug "C:\Projects\Blahblahblah\setup.iss"" exited with code 9009.

9009 means file not found, but it actually couldn't find the "iscc" part of the command.

I fixed it by adding ";C:\Program Files\Inno Setup 5 (x86)\" to the system environment variable "path"

Solution 8 - .Net

In my case I had to "CD" (Change Directory) to the proper directory first, before calling the command, since the executable I was calling was in my project directory.

Example:

cd "$(SolutionDir)"
call "$(SolutionDir)build.bat"

Solution 9 - .Net

I caused this error to happen when I redacted my Path environment variable. After editing, I accidentally added Path= to the beginning of the path string. With such a malformed path variable, I was unable to run XCopy at the command line (no command or file not found), and Visual Studio refused to run post-build step, citing error with code 9009.

XCopy commonly resides in C:\Windows\System32. Once the Path environment variable allowed XCopy to get resolved at DOS prompt, Visual Studio built my solution well.

Solution 10 - .Net

If the script actually does what it needs to do and it's just Visual Studio bugging you about the error you could just add:

exit 0

to the end of you script.

Solution 11 - .Net

Check the spelling. I was trying to call an executable but had the name misspelled and it gave me the exited with code 9009 message.

Solution 12 - .Net

Another variant:

today I call python interpreter from cron in win32 and take ExitCode (%ERRORLEVEL%) 9009, because system account used by cron don't have path to Python directory.

Solution 13 - .Net

The problem in my case occurred when I tried to use a command on the command-line for the Post-build event in my Test Class Library. When you use quotation marks like so:

"$(SolutionDir)\packages\NUnit.Runners.2.6.2\tools\nunit" "$(TargetPath)" 

or if you're using the console:

"$(SolutionDir)\packages\NUnit.Runners.2.6.2\tools\nunit-console" "$(TargetPath)"

This fixed the issue for me.

Solution 14 - .Net

tfa's answer has been downvoted, but actually can cause this issue. Thanks to hanzolo, I looked in the output window and found the following:

3>'gulp' is not recognized as an internal or external command,
3>operable program or batch file.
3>D:\dev\<filepath>\Web.csproj(4,5): error MSB3073: The command "gulp clean" exited with code 9009.

After running npm install -g gulp, I stopped getting this error. If you're getting this error in Visual Studio, check the output window and see if the issue is an unset environment variable.

Solution 15 - .Net

Also, make sure there are no line breaks in the post build event editing window on your project. Sometimes copying the xcopy command from the web when it's multi-line and pasting it into VS will cause a problem.

Solution 16 - .Net

I added "> myFile.txt" to the end of the line in the pre-build step and then inspected the file for the actual error.

Solution 17 - .Net

I fixed this by simply restarting Visual Studio - I had just run dotnet tool install xxx in a console window and VS hadn't yet picked up the new environment variables and/or path settings that were changed, so a quick restart fixed the issue.

Solution 18 - .Net

For me, disk space was low, and files that couldn't be written were expected to be present later. Other answers mentioned missing files (or misnamed/improperly referenced-by-name files)--but the root cause was lack of disk space.

Solution 19 - .Net

For me it happened after upgrade nuget packages from one PostSharp version to next one in a big solution (~80 project). I've got compiler errors for projects that have commands in PreBuild events.

'cmd' is not recognized as an internal or external command, operable program or batch file. C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets(1249,5): error MSB3073: The command "cmd /c C:\GitRepos\main\ServiceInterfaces\DEV.Config\PreBuild.cmd ServiceInterfaces" exited with code 9009.

PATH variable was corrupted becoming too long with multiple repeated paths related to PostSharp.Patterns.Diagnostics. When I closed Visual Studio and opened it again, the problem was fixed.

Solution 20 - .Net

Yet another variant of file not found, because of spaces in the path. In my case in the msbuild script. I needed to use HTML style &quot; strings within the exec command.

<!-- Needs quotes example with my Buildscript.msbuild file --> 
<Exec Command="&quot;$(MSBuildThisFileDirectory)\wix\wixscript.bat&quot; $(VersionNumber) $(VersionNumberShort)" 
	ContinueOnError="false" 
	IgnoreExitCode="false" 
	WorkingDirectory="$(MSBuildProjectDirectory)\wix" />


	

Solution 21 - .Net

Same as the other answers, in my case it was because of the missing file. To know what is the missing file, you can go to the output window and it will show you straight away what went missing.

To open the output window in Visual Studio:

  1. Ctrl+Alt+O
  2. View > Output

enter image description here

Solution 22 - .Net

This is pretty basic, I had this problem, and embarrassing simple fail.

Application use Command line arguments, I removed them and then added them back. Suddenly the project failed to build.

Visual Studio -> Project Properties -> verify that you use 'Debug' tab (not 'Build Events' tab) -> Command Line Arguments

I used the and Post/Pre-build text area, which was wrong this case.

Solution 23 - .Net

My solution was just simple as: have you tried turning it off and on again? So I restarted the computer and the issue was gone.

Solution 24 - .Net

I also ran into this 9009 problem when facing an overwrite situation.

Basically, if the file already exists and you have not specified the /y switch (which automatically overwrites) this error can happen when run from a build.

Solution 25 - .Net

Happened with a colleague. If development environment is windows and visual studio project is on C: drive.. Than make sure that visual studio is run with administrator right.. simply right click and 'Run as administrator'. You can also go to the properties of visual studio project -> Advance -> and enable 'Run as administrator'.

Solution 26 - .Net

I had the same error caused by my post build script and I tried to run the script line by line in the command prompt. Finally I found out the root cause is I did not populate the missing information in the .nuspec file, i.e. replacing all the variables between $ and $ with the actual value, e.g. replacing $author$ with my name

Solution 27 - .Net

Check the Output tab carefully.

That should reveal the issue reason.

(E.g. in my case it was related to a comment: '#' is not recognized as an internal or external command, operable program or batch file.)

Solution 28 - .Net

Actually I noticed that for some reason the %windir% environment variable sometimes get erased. What worked for me was re-set the windir environment variable to c:\windows, restart VS, and that's it. That way you prevent having to modify the solution files.

Solution 29 - .Net

At least in Visual Studio Ultimate 2013, Version 12.0.30723.00 Update 3, it's not possible to separate an if/else statement with a line break:

works:

if '$(BuildingInsideVisualStudio)' == 'true' (echo local) else (echo server)

doesn't work:

if '$(BuildingInsideVisualStudio)' == 'true' (echo local) 
else (echo server)

Solution 30 - .Net

Yet another reason: If your pre-build event references another projects bin path and you see this error when running msbuild, but not Visual Studio, then you have to manually arrange the projects in the *.sln file (with a text editor) so that the project you are targeting in the event is built before the event's project. In other words, msbuild uses the order that projects are listed in the *.sln file whereas VS uses knowledge of project dependencies. I had this happen when a tool that creates a database to be included in a wixproj was listed after the wixproj.

Solution 31 - .Net

I think in my case there were russian symbols in path (all projects were in user folder). When I put solution in another folder (directly on disk), everything became ok.

Solution 32 - .Net

My solution was to create a copy of the file and add a step to the build task to copy my file over the original.

Solution 33 - .Net

You need to make sure you have installed grunt globally

Solution 34 - .Net

it happen with me when i change properties of App.config to be Copy Always

and fix it by undo all my edits then build to make sure it worked

finally reset it again copy always and build it worked

Solution 35 - .Net

I actually got this error message when signtool.exe itself could not be found. To fix this I added the folder path to the PATH environment variable and restarted Visual Studio.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestiondgoView Question on Stackoverflow
Solution 1 - .NetthehhvView Answer on Stackoverflow
Solution 2 - .NetChris MoschiniView Answer on Stackoverflow
Solution 3 - .NetHRKoderView Answer on Stackoverflow
Solution 4 - .NetNileshChauhanView Answer on Stackoverflow
Solution 5 - .NetRadomir SzewczykView Answer on Stackoverflow
Solution 6 - .NetSleepyBoBosView Answer on Stackoverflow
Solution 7 - .NetscwView Answer on Stackoverflow
Solution 8 - .NetMathias Lykkegaard LorenzenView Answer on Stackoverflow
Solution 9 - .NetGregCView Answer on Stackoverflow
Solution 10 - .NethakksorView Answer on Stackoverflow
Solution 11 - .NetMarkView Answer on Stackoverflow
Solution 12 - .NetDenis BarmenkovView Answer on Stackoverflow
Solution 13 - .NetpdvriesView Answer on Stackoverflow
Solution 14 - .NetR. SalisburyView Answer on Stackoverflow
Solution 15 - .Netjesse pView Answer on Stackoverflow
Solution 16 - .NetPhilipView Answer on Stackoverflow
Solution 17 - .Netkeithl8041View Answer on Stackoverflow
Solution 18 - .NetErikEView Answer on Stackoverflow
Solution 19 - .NetMichael FreidgeimView Answer on Stackoverflow
Solution 20 - .NetBen ButzerView Answer on Stackoverflow
Solution 21 - .NetMarvin Glenn LacunaView Answer on Stackoverflow
Solution 22 - .NetNiike2View Answer on Stackoverflow
Solution 23 - .Netkrzyszt0fdView Answer on Stackoverflow
Solution 24 - .NetTravis VromanView Answer on Stackoverflow
Solution 25 - .NetMohit PundirView Answer on Stackoverflow
Solution 26 - .Netyangli.liyView Answer on Stackoverflow
Solution 27 - .NetChris WView Answer on Stackoverflow
Solution 28 - .NetCharles FView Answer on Stackoverflow
Solution 29 - .Netelse42.deView Answer on Stackoverflow
Solution 30 - .NetNovaterataView Answer on Stackoverflow
Solution 31 - .NetDmitriy DokshinView Answer on Stackoverflow
Solution 32 - .Netjohnrizzo1View Answer on Stackoverflow
Solution 33 - .NettfaView Answer on Stackoverflow
Solution 34 - .NetAhmed SalemView Answer on Stackoverflow
Solution 35 - .NetAdam ShortView Answer on Stackoverflow