tag:help.appveyor.com,2012-11-13:/discussions/problems/16572-sting-replace-in-appveyorymlAppVeyor: Discussion 2018-09-10T16:17:05Ztag:help.appveyor.com,2012-11-13:Comment/460458222018-09-08T05:08:17Z2018-09-08T05:08:19ZSting replace in appveyor.yml<div><p>I create my version in appveyor using the following template</p>
<pre>
<code>version: 1.0.{build}-{branch}</code>
</pre>
<p>Since we use slashes in the branch name, we get a version like "1.0.1-feature/my-nice-feature". This causes an issue when deploying to Octopus, since it requires a valid Semantic Version, which means the "/" is not allowed.</p>
<p>Is there a way to reformat the branch name in appveyor.yml?</p>
<p>I´m looking for something like</p>
<pre>
<code>version: 1.0.{build}-{branch.replace("/","-")}</code>
</pre>
<p>Here is my (almost) my full appveyor.yml</p>
<pre>
<code>version: 1.0.{build}-{branch}
image: Visual Studio 2017
before_build:
- ps: nuget restore .\Foo.sln
build:
project: ./Foo.sln
publish_wap_octopus: true
verbosity: minimal
test: off
deploy:
- provider: Octopus
push_packages: true
create_release: false
deploy_release: false
server: https://foo.octopus.app
deploy_wait: false
nuget:
account_feed: true</code>
</pre></div>Bjarte Djuvik Næsstag:help.appveyor.com,2012-11-13:Comment/460458222018-09-10T16:17:04Z2018-09-10T16:17:04ZSting replace in appveyor.yml<div><p>You can update it using <a href="https://www.appveyor.com/docs/build-worker-api/#update-build-details">Update-AppveyorBuild</a> command and <code>APPVEYOR_BUILD_VERSION</code> <a href="https://www.appveyor.com/docs/environment-variables/">environment variable</a> at <code>init</code> stage. It can look like this:</p>
<pre>
<code>init:
- ps: Update-AppveyorBuild -Version $env:APPVEYOR_BUILD_VERSION.Replace("/","-")</code>
</pre>
<p>Downside of this approach is described in <a href="https://github.com/appveyor/ci/issues/1074">this</a> issue, which should be fixed in near time though.</p></div>Ilya Finkelshteyn