在 Visual Studio 中以 Release 目标构建项目时,我想将我的二进制文件复制到受版本控制的发布文件夹。
为了轻松识别构建时间,格式为时间戳文件__yyyy-MM-ddTHHmmss__
应该添加。
最佳答案
我使用了以下内容:
在我的项目文件的开头,我添加了一个时间戳属性:
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Timestamp>$([System.DateTime]::Now.ToString("yyyy-MM-dd\THHmmss"))</Timestamp>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
然后可以使用带有
$(Timestamp)
的 postbuild 事件:<PostBuildEvent>
if $(ConfigurationName) == Production (
mkdir "$(SolutionDir)__RELEASE__\$(TargetName)"
del /q "$(SolutionDir)__RELEASE__\$(TargetName)\*"
echo $(Timestamp)> "$(SolutionDir)__RELEASE__\$(TargetName)\__$(Timestamp)__"
copy /Y "$(TargetDir)" "$(SolutionDir)__RELEASE__\$(TargetName)\"
del /q "$(SolutionDir)__RELEASE__\$(TargetName)\*.tmp"
del /q "$(SolutionDir)__RELEASE__\$(TargetName)\*.log"
del /q "$(SolutionDir)__RELEASE__\$(TargetName)\*.err"
TortoiseProc /command:add /path:"$(SolutionDir)__RELEASE__\"
)
</PostBuildEvent>
关于visual-studio - 如何在 Visual Studio 后期构建脚本中使用构建时间戳,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24169321/