views:

464

answers:

1

I am calling DevEnv from NAnt and normally all is good. However we occasionally have the issue where a developer has added a new project and has checked in the solution file but forgotton to add the new project to source control. Not sure how, but it happens.

In this situation Visual Studio puts up a dialog with an OK button saying that it cannot find the project file. Trouble is, this is on a headless build server that nobody is watching and the only thing we notice is that the build will timeout.

I would prefer it if DevEnv then exited with a failure, NAnt could pick that up and would fail the build which is the correct behaviour.

Is there a way of stopping Visual Studio from doing this, or as an alternative are there any good validators avaiable I could run before launching DevEnv to check that there is a good chance that it won't fall over with a silly dialog?

The resaon why I am calling DevEnv is that I need to build deployment projects and the only way to do this (available to us) is to use DevEnv.

RESOLUTION:

It turns out that my build script was explicitly calling devenv.exe. That is the gui form of Visual Studio. The resolution was to remove the .exe part of the call leaving the command processing to favour the .com over the .exe version. The devenv.com version doesn't display the dialog - it bombs out on the command line instead which is the behaviour I wanted.

+1  A: 

Have you tried using a command line build of Visual Studio. If a project is not available for a command line build, the process will display an error message but will popup no UI.

Example:

devenv.com SomeSolution.sln /build

On my machine, for a solution with a missing project, it will display the following output

Microsoft (R) Visual Studio Version 9.0.30729.1. Copyright (C) Microsoft Corp. All rights reserved.

One or more projects in the solution could not be loaded for the following reaso n(s):

The project file or web has been moved, renamed or is not on your computer.

These projects will be labeled as unavailable in Solution Explorer. Expand the p roject node to show the reason the project could not be loaded.------ Build star ted: Project: ConsoleApplication1, Configuration: Debug Any CPU ------ ConsoleApplication1 -> C:\Users\jaredpar\Documents\Visual Studio 2008\Projects\C onsoleApplication26\ConsoleApplication1\bin\Debug\ConsoleApplication1.exe ------ Build started: Project: WpfApplication1, Configuration: Debug Any CPU --- --- WpfApplication1 -> C:\Users\jaredpar\Documents\Visual Studio 2008\Projects\Conso leApplication26\WpfApplication1\bin\Debug\WpfApplication1.exe ========== Build: 2 succeeded or up-to-date, 0 failed, 0 skipped

JaredPar
I am calling devenv solution.sln /build Release /project DeployProject, normally it will build via the command line and all is good, however in the instance of project files missing or unreadable it throws up a horrible gui dialog.
Alan Mullett
doh! I'm calling devenv.EXE not devenv.COM I'll have a play with that.
Alan Mullett
Wow, devenv.EXE and devenv.COM in the same directory! Good going there Microsoft! :/
demoncodemonkey
@demoncodemonkey, this is actually intentional. The reason being that for CMD.exe, if you just type devenv it will bind to devenv.com before devenv.exe. That way you get command line behavior vs. a windows app.
JaredPar
OK, so I've removed the .exe from the devenv call - and it works just fine - it now errors in the log file rather than pushing up a dialog. The build now fails as expected rather than hangs. Now, why did we have the .exe in there in the first place? Who knows, but it's history now. Many Thanks.
Alan Mullett