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.
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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With