How to extract version and path from working copy of SVN to nant variable?

I am creating a new build process for a DotNet project to be held in Subversion.

For each dll / exe that I compile (via Nant), I would like to include 2 additional attibutes in the built dlls.

I already understand the work of "asminfo" nant task. But I need help getting information that I hope to embed in my binaries.

Build will always be performed from a full working copy (checked by the build process itself) and therefore will always have a .svn directory.

The attributes I want to add are RepositoryVersion and RepositoryPath. (I understand that these are not the names that this information is passed to svn)

To do this, I will need to extract the RepositoryVersion and RepositoryPath, represented by the working folder in which the BuildFile is located.

How to extract this information from any .svn folder in 2 variables?

+3
source share
4 answers

First, you can use "svn info --xml> out.xml" to get svn information into a text file. Then you can use Nant xml-peek to get the value from the file into a variable.

<xmlpeek file="out.xml" xpath="/info/entry/url" property="svn.url" />
+3
source

Here is how I do it for the version number:

<exec
    program="svn"
    commandline='log "${solution.dir}" --xml --limit 1'
    output="${solution.dir}\_revision.xml"
    failonerror="false"/>
<xmlpeek
    file="${solution.dir}\_revision.xml"
    xpath="/log/logentry/@revision"
    property="version.revision"
    failonerror="false"/>
<delete file="${solution.dir}\_revision.xml" failonerror="false"/>
+2
source

svn keywords . :
<property name="RepositoryPath" value="$HeadURL$" />
<property name="RepositoryVersion" value="$Revision$" />

0

Entries in the .svn directory are not really intended for direct access. I don't know much about what you are doing, but I suggest you use the mechanism that you use to validate the project to find the version and path of HEAD. (I would suggest that since you are checking out a project that already knows the way, but perhaps it is not).

Sorry, I can’t give more information than this.

-1
source

Source: https://habr.com/ru/post/1698144/


All Articles