2013-11-15 31 views
0

TLDR; devenv似乎與GUI中最後選擇的任何配置/平臺建立依賴關係,而不是/ projectconfig所說的。想法?vs2012不會將/ projectconfig傳遞給依賴關係?


我有一個Visual Studio 2012的解決方案,建立調試&版本的Win32 & 64。它有兩個項目

  • 「共同」 產生一個靜態庫
  • 「富」 產生一個DLL,並與common.lib鏈接

兩個項目輸出到$(SolutionDir)$(配置)_ $(平臺),例如myTest/Release_Win32,所以我可以很容易地在配置之間切換。

項目foo取決於common,當我明確地建立foo在完整的GUI它正確地建立common第一,無論哪個配置/平臺我目前靶向。

但是,如果我在命令行運行

devenv.exe myTest/myTest.sln /project foo /projectconfig "Release|x64" /build

然後,它會失敗,因爲連接時,它無法找到common.lib。的確,沒有myTest/Release_x64/common.lib,但是那裏是myTest/Debug_Win32/common.lib。我可以驗證這是由devenv命令引起的,它在刪除所有目錄後重新出現。

看來devenv正在嘗試構建common作爲依賴項,但未能指定projectconfig並回退到Win32的默認調試&。

我可以在嘗試構建foo之前手動構建common來解決此問題,但我更喜歡它自動發生。是否有其他人遇到過這種情況,或者有解決方法/解決方案?


這裏的演示該問題的解決方案,以及如何創建它:

http://beanalby.net/stackExchange/vsDepends.zip

  • 創造「共同」的靜態庫與新的解決方案
  • 創建「富」作爲控制檯該解決方案中的應用程序
  • 添加了$(OutDir)common.lib作爲鏈接器/輸入下的所有配置的附加依賴關於foo
  • 標有 「富」 依賴於 「共同」
  • 退出Visual Studio中,節能項目&解決方案

運行devenv myTest/myTest.sln /project foo /projectconfig "Release|x64" /build生產:

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 ========== 

如果打開Visual Studio中,改變平臺/配置到其他任何東西,並退出(它不會要求保存),然後common將構建爲該平臺/配置。

這發生在VS2012 x64 Cross Tools Command PromptVS2012 x86 Native Tools Command Prompt

+1

建築與devenv.exe已被棄用,而不是使用MSBuild.exe。 –

回答

0

確認漢斯帕桑特的評論,該docs for devenv說:

Note 
For build-related tasks, it is now recommended that you use MSBuild 
instead of devenv. For more information, see MSBuild Command-Line Reference. 

使用MSBuild不是作爲

MSBuild.exe myTest/myTest.sln /t:foo /p:Configuration=Release;Platform=x64 

讓它獲得平臺&配置正確。對於那些在命令行中仍然使用devenv的人,此Q/A將作爲警告。悔改&切換!

相關問題