TLDR; devenv appears to build dependencies with whatever config/platform was last selected in the GUI, rather than what /projectconfig says. Ideas?
Both projects output to $(SolutionDir)$(Configuration)_$(Platform), e.g. myTest/Release_Win32
so I can easily swap between configs.
The project foo
depends on common
, and when I explicitly build foo
in the full GUI it properly builds common
first, for whichever configuration/platform I'm currently targetting.
However, If I run the command line
devenv.exe myTest/myTest.sln /project foo /projectconfig "Release|x64" /build
Then it will fail because it can't find common.lib
when linking. Indeed, there's no myTest/Release_x64/common.lib
, but there IS myTest/Debug_Win32/common.lib
. I can verify this is caused by that devenv command, it re-appears after removing all the directories.
It appears devenv is trying to build common
as a dependency, but failing to specify the projectconfig and falling back to the default Debug & Win32.
I can work around this by manually building common
before attempting to build foo
, but I'd prefer it to happen automagically. Has anyone else encountered this, or have a workaround/solution?
http://beanalby.net/stackExchange/vsDepends.zip
running devenv myTest/myTest.sln /project foo /projectconfig "Release|x64" /build
produces:
C:\Users\jason\Desktop>devenv myTest/myTest.sln /project foo /projectconfig "Release|x64" /build
Microsoft (R) Microsoft Visual Studio 2012 Version 11.0.60610.1.
Copyright (C) Microsoft Corp. All rights reserved.
1>------ Build started: Project: common, Configuration: Debug Win32 ------
1>Build started 11/15/2013 13:15:22.
1>PrepareForBuild:
1> Creating directory "C:\Users\jason\Desktop\myTest\Debug\".
1>InitializeBuildStatus:
1> Creating "Debug\common.unsuccessfulbuild" because "AlwaysCreate" was specified.
1>ClCompile:
1> stdafx.cpp
1>Lib:
1> common.vcxproj -> C:\Users\jason\Desktop\myTest\Debug\common.lib
1>FinalizeBuildStatus:
1> Deleting file "Debug\common.unsuccessfulbuild".
1> Touching "Debug\common.lastbuildstate".
1>
1>Build succeeded.
1>
1>Time Elapsed 00:00:00.52
2>------ Build started: Project: foo, Configuration: Release x64 ------
2>Build started 11/15/2013 13:15:22.
2>PrepareForBuild:
2> Creating directory "C:\Users\jason\Desktop\myTest\x64\Release\".
2>InitializeBuildStatus:
2> Creating "x64\Release\foo.unsuccessfulbuild" because "AlwaysCreate" was specified.
2>ClCompile:
2> stdafx.cpp
2> foo.cpp
2>LINK : fatal error LNK1181: cannot open input file 'C:\Users\jason\Desktop\myTest\x64\Release\comm
on.lib'
2>
2>Build FAILED.
2>
2>Time Elapsed 00:00:00.56
========== Build: 1 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
If you open Visual Studio, change the platform/config to anything else, and exit (it won't ask to save), then common
will build as THAT platform/config.
This happens with both the VS2012 x64 Cross Tools Command Prompt
and VS2012 x86 Native Tools Command Prompt
.
Confirming Hans Passant's comment, The docs for devenv say:
Note
For build-related tasks, it is now recommended that you use MSBuild
instead of devenv. For more information, see MSBuild Command-Line Reference.
Using MSBuild
instead as
MSBuild.exe myTest/myTest.sln /t:foo /p:Configuration=Release;Platform=x64
lets it get the platform & config properly. This Q/A shall serve as a warning to those still using devenv
on the command line. Repent & switch!