• Uncategorized

About linux : reading-the-version-prefix-from-an-external-file-instead-of-the-csproj-file

Question Detail

At this time, my .csproj files contain the XPath /Project/PropertyGroup/VersionPrefix and that determines the version for the nuget packages.
However, I would prefer to read this version prefix from a shared file, as it will be common for 3 or 4 projects, each of whom have their own .csproj files.

In other words, instead of having


we would prefer to have something like

@@include ../../version.xml

and this version.xml contains the line above which will be substituted.

I am sure there would be multiple ways to achieve this but cannot fathom exactly how. Help would be appreciated.

Question Answer

You can create a file named Directory.Build.props in the folder hierarchy above all your projects (e.g. next to the solution file) and put shared properties in there:


MSBuild will automatically find and import this file. (you may need to re-open your editor / visual studio). See MSBuild’s Customize your build documentation for more information.

You may also like...

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.