Reputation: 1628
When building a project in Visual Studio at the Release target, I want to copy my binaries to a release folder which is under version control. To easily recognize the build time, a timestamp file in the form
__yyyy-MM-ddTHHmmss__
should be added.
Upvotes: 7
Views: 4269
Reputation: 9
In case someone is still looking for this, typing Time /T in the Post-build event command line works well.
Upvotes: 0
Reputation: 113
In case anybody stumbles across this question, this did the trick for me:
<PropertyGroup>
<Time>$([System.DateTime]::Now.ToString())</Time>
</PropertyGroup>
<Message Text="$(Time2)" Importance="High" />
Upvotes: 0
Reputation: 1628
I used the following:
At the beginning of my project file I added a timestamp property:
<?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>
Then one can use a postbuild event with $(Timestamp)
:
<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>
Upvotes: 10