0

I am trying to build a C# ASP.NET project with MSBuild.exe on the command prompt in Windows 8.1, but am getting an error. The error message is extremely long but essentially is:

    error MSB3073: The command "mkdir..." exited with code 255

Here's the full one:

!https://i.stack.imgur.com/BKkxA.jpg

There seems to be some kind of trouble with a Temp directory. The project builds and runs on Visual Studio 2013 fine, but doesn't seem to be working here.

Things I've tried so far

  • Using different MSBuild locations
  • Specifying Visual Studio Version for MSBuild
  • Using the Visual Studio and regular command prompt to use MSBuild
  • Using different MSBuild versions
  • Moving the entire project to a file path without spaces

I'm suspicious that different build order between VS and MSBuild could be causing the issue, but I'm not sure if that is the case and if it is, what the best way to fix that would be.

EDIT

It's come to light that the issue likely has something to do with the Post-Build event. I've tried out a couple different ways of using quotes around the $(ProjectDir) in the Post-Build command, but to no avail. I've tried removing some of the Post-Build commands, and have narrowed the issue down to one of the following commands:

    mkdir "$(ProjectDir)Temp"

    for /r "$(ProjectDir)Module" %%I in (*.js)
  • To get more details of the error, have you tried setting verbosity to detailed? https://msdn.microsoft.com/en-us/library/ms171470.aspx – FailedUnitTest Nov 02 '15 at 15:55
  • I've tried setting it to detailed and to diagnostic, but the error message still looks the same. I've just included a link to a screenshot of it in my question. – Elliot Berman Nov 02 '15 at 16:22
  • Looks like you're using a Pre-build or Post-build event, could you add them to the question? From the image of your build errors, I'd try quotes around your file/directory paths or their macros. Without the quotes, the spaces in the paths may be causing trouble. – mcdon Nov 02 '15 at 16:59
  • @mcdon this is my exact command line command: `"C:\Program Files (x86)\MSBuild\12.0\Bin\msbuild.exe" source\Livamp.sln` – Elliot Berman Nov 02 '15 at 18:23
  • @ElliotBerman but what's the pre-build and post-build event in Api.Web.Ui.csproj? – mcdon Nov 02 '15 at 18:29
  • @mcdon the post-build is `mkdir $(ProjectDir)Temp for /r $(ProjectDir)Module\ %25%25I in (*.js) do $(ProjectDir)..\Tools\jsmin < %25%25I > $(ProjectDir)Temp\%25%25~nI.min.js type $(ProjectDir)Temp\api.min.js > $(ProjectDir)api.min.js del $(ProjectDir)Temp\api.min.js copy /b $(ProjectDir)api.min.js + $(ProjectDir)Temp\*min.js $(ProjectDir)api.min.js rmdir $(ProjectDir)Temp /s /q` I don't see a PreBuild though – Elliot Berman Nov 02 '15 at 18:42
  • @ElliotBerman those are the paths I'd put quotes around. Use project->properties->Build Events to edit the Post-Build rather than editing the xml directly so you don't have to worry about xml encoding (%25's, &lt, &gt, etc). like: mkdir "$(ProjectDir)Temp" – mcdon Nov 02 '15 at 19:05
  • @mcdon I changed it to this using that method but am getting a similar method... I think my formatting is off still? `mkdir "$(ProjectDir)Temp " for /r "$(ProjectDir)Module\ " %%I in (*.js) do "$(ProjectDir)..\Tools\jsmin " < %%I > "$(ProjectDir)Temp\%%~nI.min.js " type "$(ProjectDir)Temp\api.min.js " > "$(ProjectDir)api.min.js " del "$(ProjectDir)Temp\api.min.js " copy /b "$(ProjectDir)api.min.js " + "$(ProjectDir)Temp\*min.js " "$(ProjectDir)api.min.js " rmdir "$(ProjectDir)Temp " /s /q` – Elliot Berman Nov 02 '15 at 19:38
  • @ElliotBerman why the trailing space at the end of the paths (like "$(ProjectDir)Temp " instead of "$(ProjectDir)Temp"? – mcdon Nov 02 '15 at 19:49
  • I read here: [link](http://stackoverflow.com/questions/11587394/how-to-put-double-quotes-in-vs2010-post-build-step) that it was supposed to help with the space in the file path. I just tried building without the trailing space and got the same error as well. – Elliot Berman Nov 02 '15 at 20:36
  • @ElliotBerman it sounds like the link you provided is for issues specifically with subwcrev and it's argument parsing ([similar issue](https://github.com/cplussharp/graph-studio-next/issues/154)). I doubt it's a general solution for all paths that contain spaces. Try to narrow down which command in the post-build is causing the issue. start with one command `mkdir "$(ProjectDir)Temp"` and see if the command works, then add another command and retest. – mcdon Nov 02 '15 at 23:01
  • tried just mkdir "$(ProjectDir)Temp" but got a similar error.I scrolled up in the command prompt and found this: `C:\Program Files (x86)\MSBuild\12.0\bin\Microsoft.Common.CurrentVersion.targets (4548,5): error MSB3073: The command "mkdir "C:\Program Files ...Temp"\r [C:\Program Files...Api.Web.Ui.csproj ] C:\Program Files (x86)\MSBuild\12.0\bin\Microsoft.Common.CurrentVersion.targets (4548,5): error MSB3073: " exited with code 1.` – Elliot Berman Nov 03 '15 at 15:50
  • forgot to add @mcdon ^ – Elliot Berman Nov 03 '15 at 19:13
  • @ElliotBerman try with just a post build command of `mkdir "$(ProjectDir)Temp"`. assuming that works, I think %%I in the do part of your for loop needs quotes as it likely contains a space. so a for loop of `for /r "$(ProjectDir)Module\" %%I in (*.js) do "$(ProjectDir)..\Tools\jsmin" < "%%I" > "$(ProjectDir)Temp\%%~nI.min.js"` – mcdon Nov 04 '15 at 16:25
  • @mcdon just tried again with only `mkdir "$(ProjectDir)Temp"` Still getting error MSB3073 exiting with code 1. I also tried this out last night by moving the whole project to a file path without any spaces in it and still got the same error – Elliot Berman Nov 04 '15 at 16:47

0 Answers0