16

While the 'no-log' build seems to work smoothly with something like

"c:\Program Files\Microsoft Visual Studio 9.0\Common7\ide\VCSExpress" Project1.csproj /build

the following fails:

"c:\Program Files\Microsoft Visual Studio 9.0\Common7\ide\VCSExpress" Project1.csproj /build /Log=log.txt

showing a window with this text:

Missing switch argument. Configuration name required for /build switch.

Use: vcsexpress [solutionfile | projectfile | anyfile.ext] [switches]

The first argument for vcsexpress is usually a solution file or project file. You can also use any other file as the first argument if you want to have the file open automatically in an editor. When you enter a project file, the IDE looks for an .sln file with the same base name as the project file in the parent directory for the project file. If no such .sln file exists, then the IDE looks for a single .sln file that references the project. If no such single .sln file exists, then the IDE creates an unsaved solution with a default .sln file name that has the same base name as the project file.

Command line builds: vcsexpress solutionfile.sln /build [ solutionconfig ] [ /project projectnameorfile [ /projectconfig name ] ] Available command line switches:

/Log Logs IDE activity to the specified file for troubleshooting. /ResetSettings Restores the IDE's default settings, optionally resets to the specified VSSettings file. /SafeMode Launches the IDE in safe mode loading minimal windows.

Product-specific switches:

To attach the debugger from the command line, use: VsJITDebugger.exe -p

[I am using Visual Studio 2008 Express]

So, the questions are:

  • Is there a way to ensure that the log file is written somewhere?

  • Or is the /Log switch only supposed to be used when the IDE is run in GUI mode? If so, are there workarounds?

mlvljr
  • 4,066
  • 8
  • 44
  • 61
  • Why don't you use MSBuild for building? – Fyodor Soikin Mar 02 '11 at 23:40
  • @Fyodor Soikin Actually just having a log written would probably suffice (I'm doing just some small and dirty automation at the tme). – mlvljr Mar 02 '11 at 23:46
  • I'm not familiar with the Express product, but when I want to create a log using other tools, I just redirect the console output to a file. This assumes, of course, that there is some output to redirect. . . – Jim Mischel Mar 02 '11 at 23:54
  • 5
    I don't see how this answer justifies not using MSBuild. In case you don't know, you can just do `MSBuild.exe myproj1.csproj` and it will build it just like the Visual Studio does. Nothing complex at all. But in return, you get some extensibility and customization options. Like, for example, a file logger. – Fyodor Soikin Mar 02 '11 at 23:55
  • @Fyodor Soikin Well, I'll probably try it. But the initial question still bothers me (esp. after @Hans Passant's detailed but regrettably unhelpful answer). – mlvljr Mar 03 '11 at 00:22

3 Answers3

32

Under the hood, Visual Studio uses msbuild for all it's build magic. As far as I know, this applies to the Express editions as well.

If you don't have it already, MSBuild is a part of the .NET SDK.

Calling MSBuild has the advantage of doing the build directly - calling VCSExpress will just introduce overhead.

Here's the MSBuild commandline that I've used:

msbuild.exe <solution> 
    /t:rebuild 
    /verbosity:quiet 
    /logger:FileLogger,Microsoft.Build.Engine;logfile=<filePath>

Should work the same with <project> instead of <solution>.

Bevan
  • 43,618
  • 10
  • 81
  • 133
  • So, since I've got the (3.5?) sdk, I must have got the MSBuild too? (a quick search in "C:\program files" reveals nothing.. -- is it somehow hidden under a different name or smth?) – mlvljr Mar 03 '11 at 01:59
  • 2
    Seems to be at `%SystemRoot%\Microsoft.NET\Framework\v3.5`, many thanks. – mlvljr Mar 03 '11 at 02:16
  • I don't know about the solution, but I found when building a csproj, I also needed to provide the build Configuration. E.G. `msbuild.exe name.csproj /property:Configuration=Debug|Release` – xr280xr Sep 30 '14 at 20:55
4

You have to specify the configuration after the /build option. Also, the log file must already exist, it doesn't create one from scratch. Thus:

copy con > log.txt
^Z      // Type Ctrl+Z
"c:\Program Files\Microsoft Visual Studio 9.0\Common7\ide\VCSExpress" Project1.csproj /build debug /log log.txt
Hans Passant
  • 922,412
  • 146
  • 1,693
  • 2,536
  • (Strangely enough) This still does nothing on my machine. Even if the project cannot be built (a referenced dll is (deliberately made) missing), the log file is empty. But thanks for the hint on the 'Missing switch argument' responce anyway -- one must be more careful and not suppose he's being told nonsense (as I did). – mlvljr Mar 03 '11 at 00:06
  • The log file option is fairly weirdo. It doesn't log much either when I try. This doesn't get used often with msbuild around. – Hans Passant Mar 03 '11 at 00:26
  • Does the last MSBuild (the one that's coming with net 4 framework) allow to build net 3.5 projects with a net 3.5 compiler easily, btw? – mlvljr Mar 03 '11 at 00:51
  • 1
    Getting the build environment setup correctly ought to be a hassle, you are missing the .bat files (aka Visual Studio Command Prompt). And the SDK tools. Msbuild is probably okay but I'm not sure, I never mix. The odds are not good. – Hans Passant Mar 03 '11 at 01:05
2

In the window that pops up with all the info.. it gives you the error:

Missing switch argument. Configuration name required for /build switch.

And then it gives you a bunch of info including this:

Command line builds: vcsexpress solutionfile.sln /build [ solutionconfig ]

It just wants to know what kind of solution config you have - I think either "Release" or "Debug". Not sure if vcsexpress has the "Configuration Manager" or Solution Build Property Pages under the "Build" Menu.. but this would be where you could double check your current settings. See the "Active Solution Configuration".. this person ran into this, check out their screen shot of it: MSBuild task configuration property

jpaugh
  • 6,634
  • 4
  • 38
  • 90
Chelsea
  • 21
  • 1