用于发布的构建后事件命令 (Visual Studio 2010) [英] Post-build event command for publish (Visual Studio 2010)
问题描述
我在 Visual Studio 2010 中有一个项目.该项目具有以下构建后事件命令行:
I have a project in visual studio 2010. This project has the following post-build event command lines:
SET TARGET_PROJECT=TestMain
IF NOT EXIST "$(TargetDir)IceBox" (
XCOPY /E /I /Y "$(SolutionDir)Externals\IceBox" "$(TargetDir)IceBox"
)
IF NOT EXIST "$(TargetDir)bzip2.dll" (
COPY "$(SolutionDir)Externals\IceBox\bzip2.dll" "$(TargetDir)"
)
XCOPY /E /I /Y "$(SolutionDir)Externals\Infragistics" "$(TargetDir)"
但是此命令仅在我创建调试或发布时使用.当我发布我的项目时,这个命令会被忽略.是否可以在我发布项目时使用此命令?
But this commands are just used when I create a debug or a release. When I publish my project will this commands ignored. Gives it a possibility to use this commands when I publish the project?
感谢您的帮助.
推荐答案
我最近遇到了类似的问题.我想仅"在发布应用程序时运行命令,而不是在每次构建时运行.
I recently faced a similar problem. I wanted to run a command 'only' if I published the application and not with every build.
我添加了一个帖子发布任务.由于我不直接使用 MSBuild 我修改了我的解决方案 csproj 文件.
I added a post publish task. Since I don't use MSBuild directly I modified my solution csproj file.
示例:
解决方案名称: MyKillerApp
Solution Name: MyKillerApp
项目文件名: MyKillerApp.csproj
Project File name: MyKillerApp.csproj
用 Notepad++ 或其他文本编辑器打开文件并导航到文件末尾并找到此部分(应该几乎在末尾):
Open the file with Notepad++ or other text editor and navigate to the end of the file and find this section(should be almost at the end):
<PropertyGroup>
<PreBuildEvent>
</PreBuildEvent>
</PropertyGroup>
然后添加您的发布后任务
Then add your postpublish task
<PropertyGroup>
<PreBuildEvent>
</PreBuildEvent>
</PropertyGroup>
<Target Name="AfterPublish">
<Exec Command="..\..\Documentation\DoxyGenExe\createDocs.bat" />
</Target>
我的任务运行一个 bat 文件,该文件运行 Doxygen(一个非常好的文档创建程序)和其他一些任务.
My task runs a bat file that runs Doxygen (a very nice docs creation program) and some other tasks.
可以创建一个bat文件来运行任何命令,非常方便
You can create a bat file to run any commands is very handy
这篇关于用于发布的构建后事件命令 (Visual Studio 2010)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!