简体   繁体   中英

Post Build event that zip files with timestamp in name

I'm trying to make a post-build event that zip release files with a timestamp as a part of folder name. I am creating zip file like this:

if $(ConfigurationName) == Release (powershell Compress-Archive -Path '$(ProjectDir)$(OutDir)' -DestinationPath '$(ProjectDir)bin\MyFile.zip' -Force)

Now I have zip file named "MyFile.zip" but I want it to have date in its name, like "04.12.2020.MyFile.zip".

Does anyone have any idea how to do that?

You could try using MSBuild property functions.

This is modified build step:

if $(ConfigurationName) == Debug (powershell Compress-Archive -Path '$(ProjectDir)$(OutDir)' -DestinationPath '$(ProjectDir)bin\MyFile_$([System.DateTime]::Now.Year)-$([System.DateTime]::Now.Month)-$([System.DateTime]::Now.Day).zip' -Force)

You can tweak it to have desired format.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM