VS2010如何在项目中包含文件,在构建或发布过程中自动将其复制到构建输出目录
任务是形成Visual Studio 2010项目,以便在任何构建或发布过程中应将某些foo.exe
实用程序复制到输出(bin
)目录.
Task is to form Visual Studio 2010 project so, that during any build or publish some foo.exe
utility should be copied to output (bin
) directory.
我很早就在.csproj(MSBuild文件)中创建了PostBuildEvent任务:
Early I have made PostBuildEvent task in .csproj (MSBuild-file):
<PropertyGroup>
<PostBuildEvent>
Copy "$(SolutionDir)Tools\foo.exe" "$(ProjectDir)$(OutDir)foo.exe"
</PostBuildEvent>
</PropertyGroup>
但这不是普遍的.发布期间(Visual Studio 2010)foo.exe
出现在bin
目录中,但未复制到输出发布目录中.也许我所做的一切完全错误,并且存在标准机制将文件包含在项目中,以便以后在构建或发布期间复制到bin
?
But this is not universal. During publishing (Visual Studio 2010) foo.exe
appears in bin
directory, but is not copied to output publish directory. Maybe I do everything completely wrong and there is standard mechanism to include files in projects to be later, during build or publish, copied to bin
?
有,并且不依赖于构建后事件.
There is and it is not dependent on post build events.
将文件添加到项目中,然后在文件属性中,在复制到输出目录"下,选择始终复制"或如果更新则复制".
Add the file to your project, then in the file properties select under "Copy to Output Directory" either "Copy Always" or "Copy if Newer".
请参见 MSDN .