Hi,
Would it be possible to access the version number from the .csproj (.NET) project during a pipeline step?
The structure of a .csproj file is similar to this:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<Version>1.1.0</Version>
<Description>Test</Description>
</PropertyGroup>
</Project>
I would like to extract the version to later ship it on a package step and publish it automatically to nuget.
Thanks in advance.
So if I understand you correctly you just want to pull the version number out of an xml file and pass it on to the next step? If you know that the version attribute will always be on a separate line as shown above and if there will be no other lines that look like that then you could use some basic pattern matching. Something like this:
pipelines:
default:
- step:
script:
- grep '<Version>' < .csproj | sed 's/.*<Version>\(.*\)<\/Version>/\1/' > version.txt
artifacts:
- version.txt
- step:
script:
- cat version.txt
Thank you for your answer and help Steven.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Save my day !!! Thank you
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.