[c#] How can I resolve the error: "The command [...] exited with code 1"?

I've read around many questions but I've not been able to find the right answer for me.

As I try to compile a project in VS2012 I have this result:

The command "....\tools\bin\nuget pack Packages\Lib.Html.nuspec - OutputDirectory ....\bin\Zip\Packages -NoPackageAnalysis" exited with code 1.

I looked for the line of code in my .csproj file, where the error should be, and there is:

<Exec Command="$(ProjectDir)..\..\tools\bin\nuget pack $(ProjectDir)Packages\Lib.Html.nuspec -OutputDirectory $(OutputPath)Packages -NoPackageAnalysis" />  

What am I doing wrong?

[EDIT] Launching the Debug of that project and ignoring "building errors", I have a new alert:

"Visual Studio cannot start debugging because the debug target '[project.exe path]' is missing. Please build the project and retry, or set OutputPath and AssemblyName properties appropriately to point at the correct location for the target assembly."

This question is related to c# visual-studio-2012

The answer is


I had the same issue. Tried all the above answers. It was actually complained about a .dll file. I clean the project in Visual Studio but the .dll file still remains, so I deleted in manually from the bin folder and it worked.


This builds on the answer from JaredPar... and is for VS2017. The same "Build and Run" options are present in Visual Studio 2017.

I was getting, The command "chmod +x """ exited with code 1

In the build output window, I searched for "Error" and found a few errors in the same general area. I was able to click on a link in the build output, and found that the error involved this entry in the .targets file:

  <Target Name="ChmodChromeDriver" BeforeTargets="BeforeBuild" Condition="'$(WebDriverPlatform)' != 'win32'">
    <Exec Command="chmod +x &quot;$(ChromeDriverSrcPath)&quot;" />
  </Target>

In the build output, I also found a more detailed error message that essentially stated that it couldn't find Selenium.WebDriver.ChromeDriver v2.36 in the packages folder it was looking in. I checked the project's NuGet packages, and version 2.36 was indeed in the list of installed packages. I did find the package files for 2.36, and changed the attributes on the folder, subfolders and files from "Read Only" to "Read/Write". Built, but same failure. Sometimes "updating" to a different version of the package and then updating back to the original can fix this type of error. So I "updated" the reference in Manage NuGet packages to 2.37, built, failed, then "updated" back to 2.36, built, and the build succeeded without the "chmod +x" error message.

The project I was building was based on a Visual Studio Project template for Appium test tooling, template name "Develop_Automated_Test".


I know this is too late for sure, but, this could help someone as well.

In my case, i found that the source file is being used by another process which was restricting from copying to the destination. I found that by using command prompt ( just copy paste the post build command to the command prompt and executed gave me the error info).

Make sure that you can copy from the command prompt,


For me : I have a white space in my path's folder name G:\Other Imp Projects\Mi.....

Solution 1 :

Remove white space from folder

Example: Other Imp Projects ->> Other_Imp_Projects

Solution 2:

add Quote ("") for your path.

Example: mkdir "$(ProjectDir)$(OutDir)Configurations" //see double quotes


Check your paths: If you are using a separate build server for TFS (most likely), make sure that all your paths in the .csproj file match the TFS server paths. I got the above error when checking in the *.csproj file when it had references to my development machine paths and not the TFS server paths.

Remove multi-line commands: Also, try and remove multi-line commands into single-line commands in xml as a precaution. I had the following xml in the *.proj that caused issues in TFS:

<Exec Condition="bl.." 
Command=" Blah...
..." </Exec>

Changing the above xml to this worked:

  <Exec Condition="bl.." Command=" Blah..." </Exec>

Try to open Visual Studio as admin.


Right click project -> Properties -> Build Events

Remove the text in Post-build event command line text block


For me, in VS 2013, I had to get rid of missing references under References in the UI project (MVC). Turns out, the ones missing were not referenced.