views:

1357

answers:

2

I believe the problem is documented here and looks like it might be a bug in visual studio, but I'm wondering if anyone knows of a workaround.

Basically I have the following 2 lines (among other things) one right after the other in the prebuild event.

"C:\WINDOWS\Microsoft.NET\Framework\v3.5\MSBuild.exe" /p:configuration=Release;platform=x86 /t:rebuild "$(SolutionDir)Folder1\Project1.csproj"

"C:\WINDOWS\Microsoft.NET\Framework\v3.5\MSBuild.exe" /p:configuration=Release;platform=x86 /t:rebuild "$(SolutionDir)Folder2\Folder3\Project2.csproj"

The first one succeeds and the other fails saying that "The command ""C:\WINDOWS\Microsoft.NET\Framework\v3.5\MSBuild.exe" /p:configuration=Release;platform=x86 /t:rebuild "*Undefined *Folder2\Folder3\Project2.csproj"" exited with code 1.

(Space inserted between astrisk cause of SO formatting)

Edit: Figured out the problem was that one of the other projects with the same line as it's prebuild failed, since MSBuild itself doesn't know about the macros.

A: 

Do you think that it did not exit with code 1?

What happens if you comment out the first line?

John Saunders
It did exit with code 1 because the path to the file "*Undefined *Folder2\Folder3\Project2.csproj" obviously isn't valid
Davy8
A: 

You don't specify if this happens for many projects or just one or two.

If it is only in one or two projects, a temporary workaround might be to replace $(SolutionDir) with the explicit path that Folder2 is located in. For example, something like:

"C:\WINDOWS\Microsoft.NET\Framework\v3.5\MSBuild.exe" /p:configuration=Release;platform=x86 /t:rebuild "C:\AllSolutions\ExampleSolutions\Folder2\Folder3\Project2.csproj"

but with the correct path for your project.

JeffH