問題描述
C# 項目中的文件有Copy to Output Directory 屬性.但是在 VC++ 項目中它是不存在的.我知道,我可以在 VC++ 中使用 Build events 并在那里編寫類似
There is Copy to Output Directory property for files in C# projects. But in VC++ projects it is absent. I know, that I can use Build events in VC++ and write there something like
xcopy /y /d %(FullPath) $(OutDir)
有沒有辦法避免使用 CMD(和其他腳本方法)?在這種情況下,msbuild 可以提供幫助嗎?
Is there a way to avoid the use of CMD (and other scripting methods)? Can msbuild do something to help in this case?
推薦答案
這取決于您使用的 Visual Studio 版本.Visual Studio 2008 中的 VC++ 項目文件格式不是 MSBuild,因此在 PostBuildStep 中使用 xcopy 是一個不錯的選擇.
It depends on what version of Visual Studio you are using. Format of VC++ project file in Visual Studio 2008 is not MSBuild and so using xcopy in PostBuildStep is a good choice.
Visual Studio 2010 中的 VC++ 項目具有 MSBuild 格式.因此,就有了 MSBuild Copy 任務的功能.
VC++ project in Visual Studio 2010 has MSBuild format. Thus, there is functionality of MSBuild Copy task.
以下是示例:
<Copy
SourceFiles="%(FullPath)"
DestinationFolder="$(OutDir)"
/>
如果目標目錄不存在,則自動創建
If the destination directory does not exist, it is created automatically
MSDN Copy 任務參考位于此處
An MSDN Copy task reference is here
這篇關于在應用程序構建期間自動復制文件到輸出的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!