tag:help.appveyor.com,2012-11-13:/discussions/questions/215-how-do-i-embed-the-build-version-in-an-artifact-nameAppVeyor: Discussion 2018-08-25T01:37:39Ztag:help.appveyor.com,2012-11-13:Comment/320061642014-03-10T07:59:04Z2014-03-10T07:59:05ZHow do I embed the build version in an artifact name?<div><p>I should also mention that I tried the following for "Deployment
Name":</p>
<pre>
<code>CIVersionTest-$env:APPVEYOR_BUILD_VERSION</code>
</pre>
<p>But that results in the following error:</p>
<pre>
<code>Packaging artifacts...The given path's format is not supported.</code>
</pre></div>jcwtag:help.appveyor.com,2012-11-13:Comment/320061642014-03-10T12:24:15Z2014-03-10T12:24:15ZHow do I embed the build version in an artifact name?<div><p>Try $("CIVersionTest-"+$env:APPVEYOR_BUILD_VERSION) ?</p></div>tonytag:help.appveyor.com,2012-11-13:Comment/320061642014-03-10T17:47:56Z2014-03-10T17:47:56ZHow do I embed the build version in an artifact name?<div><p>Deployment name is like an "artifact label" used to locate
artifact during deployment. To change artifact file name in a cloud
storage the only way is to use push artifact command: <a href=
"http://www.appveyor.com/docs/build-agent-api#push-artifact">http://www.appveyor.com/docs/build-agent-api#push-artifact</a>,
for example:</p>
<pre>
<code>Push-AppveyorArtifact artifact_local_file.zip -FileName "CIVersionTest-$(appveyor_build_version).zip"</code>
</pre>
<blockquote>
<p>I used double quotes to expand variable in PS string.</p>
</blockquote></div>Feodor Fitsnertag:help.appveyor.com,2012-11-13:Comment/320061642014-03-10T23:55:51Z2014-03-10T23:55:52ZHow do I embed the build version in an artifact name?<div><p>Ah, ok. Well I removed my artifact creation from the UI and am
doing it solely through the API now. In case anyone else wants to
do the same, I put the following script into Deployment ->
"Before deployment script" and now I get an artifact named
"CIVersionTest-v1.0.0.19.zip":</p>
<pre>
<code>function ZipFiles($zipfilename, $sourcedir)
{
[Reflection.Assembly]::LoadWithPartialName("System.IO.Compression.FileSystem")
$compressionLevel = [System.IO.Compression.CompressionLevel]::Optimal
[System.IO.Compression.ZipFile]::CreateFromDirectory($sourcedir, $zipfilename, $compressionLevel, $false)
}
# Step 1 - Sign all output assemblies
# TODO
# Step 2 - Zip up output directory (CIVersionTest\bin\Release)
$binPath = "c:\projects\test1\CIVersionTest\bin\"
$zipName = "CIVersionTest-v$($env:APPVEYOR_BUILD_VERSION).zip"
$zipFullPath = "$($binPath)$($zipName)"
ZipFiles "$($zipFullPath)" "$($binPath)Release" | Out-Null # out-null so that this command doesn't print anything
# Step 3 - Upload zip file as build artifact
Push-AppveyorArtifact "$($zipFullPath)" -FileName $zipName</code>
</pre></div>jcwtag:help.appveyor.com,2012-11-13:Comment/320061642014-03-10T23:59:34Z2014-03-10T23:59:34ZHow do I embed the build version in an artifact name?<div><p>Fantastic, thanks for sharing this!</p>
<p>Especially nice is <code>ZipFiles</code> function - it
demonstrates that .NET 4.5 assemblies can be easily called from PS
;)</p>
<p>Btw, there is <code>7z</code> on build servers, so that might be
an option too...</p></div>Feodor Fitsner