Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Access .NET .csproj version while running pipeline

João Antão September 10, 2018

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. 

1 answer

1 accepted

4 votes
Answer accepted
Steven Vaccarella
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 13, 2018

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
João Antão September 22, 2018

Thank you for your answer and help Steven. 

Nickolas Shpotenko February 26, 2019

Save my day !!! Thank you

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events