VS2013 VC2013 VC 遠程調試 配置步驟


VC2013 遠程調試
1:下載vs2013的 remote tools http://www.microsoft.com/en-ca/download/details.aspx?id=44918 包括了x86 x64 arm多個版本,根據自己的平臺下載對應的版本
或者從安裝過VS2013的電腦上覆制Program Files(x86)\Mircrosofe Visual Studio 12.0\Common7\IDE\Remote Debugger也行
2:在遠端電腦上安裝remote tools,開始菜單裏面多出Visual Studio 2013
Remote Debugger Configuration Wizard是設置嚮導,但是經過測試,不要使用這個嚮導。
關於嚮導(可以直接跳過灰色字體)
這個嚮導把遠端調試器設置爲windows服務(安裝了兩個服務,名稱爲Remote Debugger,Visual Studio ETW Event Collection Service,而VS2008安裝的對應服務名稱爲Visual Studio 2008 Remote Debugger),完成開機自啓動,會遇到以下問題:
  • 開機啓動後,遠程調試時Local端彈出錯誤,大意爲服務無法和UI交互
  • 遠端調試器默認需要Windows Authentication,無法設置爲No Authentication,調試時需要輸入遠端的windows 登陸名和密碼,比較麻煩

我採用在開始菜單--啓動裏面創建對應的快捷方式,來完成自啓動功能,快捷方式參數如下
"C:\Program Files\Microsoft Visual Studio 12.0\Common7\IDE\Remote Debugger\x86\msvsmon.exe" /nostatus /timeout:9999999 /noauth /anyuser /noclrwarn /nosecuritywarn
3:Local端配置,請參考Set Up Remote Debugging for a Visual Studio Project https://msdn.microsoft.com/en-us/library/8x6by8d2.aspx
MyMfc project debugging property page

其中
Deploy Visual C++ Debug Runtime 項要選擇Yes,VS會自動複製mfc120ud.dll等dll到遠端位置,否則運行遠端軟件,會提示The Program can't start because mfc120ud.dll is missing from your computer,Try reinstalling the program to fix this problem
關於遠端電腦直接運行Debug版本的程序(可以直接跳過灰色字體)
如果編譯Debug版本,放到未安裝VS2013的電腦上,直接運行exe,會提示“The Program can't start because mfc120ud.dll is missing from your computer,Try reinstalling the program to fix this problem”。
這時會想到安裝Microsoft Visual C++ 2013 Redistributable,但是這個Release發行版,我們要運行的是Debug,那麼有沒有Debug版的Microsoft Visual C++ 2013 Redistributable ,答案是沒有(參考 Preparing a Test Machine To Run a Debug Executable https://msdn.microsoft.com/en-us/library/aa985618.aspx
解決方法:
從C:\program files\Microsoft Visual Studio 12.0\VC\redist\Debug_NonRedist 複製對應的dll到exe同目錄下,主要不要直接複製子文件,而是把所有子文件夾下的dll複製出來放到exe同目錄
Additional Files to Deploy 可以複製其他文件到遠端
當文件非常多,或者文件分了多個子文件夾時,再使用Additional Files to Deploy 就非常麻煩了,這時可以通過Build Event--Post-Build Event添加複製命令,把指定文件夾全部文件複製到遠端

if "$(DebuggerFlavor)" equ "WindowsRemoteDebugger" (goto RemoteMode) else (goto LocalMode)
goto End

:RemoteMode
echo "..\..\bin\$(Platform)\$(Configuration) \\$(RemoteDebuggerServerName)\zd\ZDTerminal\ /E /Y /F /I"
xcopy ..\..\bin\$(Platform)\$(Configuration) \\$(RemoteDebuggerServerName)\zd\ZDTerminal\ /E /Y /F /I /D /EXCLUDE:..\..\resource\uncopy.txt
goto End

:LocalMode
echo "not copy to $(RemoteDebuggerServerName)\zd\ZDTerminal"

:End

其中$(RemoteDebuggerServerName) 即爲上圖中的Remote Server Name ,他可以直接填寫ip地址,zd是該ip電腦上的共享文件夾名稱

上面的命令可以自動識別Remote Windows Debugger 和Local Windows Debugger,當選擇Local時不再複製文件到遠端

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章