2014-06-11 124 views

回答

7

我用下面的:

在我的項目文件的開頭我添加了一個時間戳屬性:

<?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> 

那麼可以使用postbuild事件與$(Timestamp)

<PostBuildEvent> 
    if $(ConfigurationName) == Production (

    mkdir "$(SolutionDir)__RELEASE__\$(TargetName)" 
    del /q "$(SolutionDir)__RELEASE__\$(TargetName)\*" 

    echo $(Timestamp)&gt; "$(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> 
0

如果有人絆倒這個問題,這爲我做了詭計:

<PropertyGroup> 
    <Time>$([System.DateTime]::Now.ToString())</Time> 
</PropertyGroup> 
<Message Text="$(Time2)" Importance="High" /> 
0

如果有人仍在尋找這個,在Post-build事件命令行中輸入Time/T效果很好。

相關問題