Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I call static class methods from msbuild?

Tags:

msbuild

How does one call a class static method from msbuild and store its results in a list?

EDIT: Okay, let me explain a bit further. I am using sandcastle help file builder to generate documentation for my application. One of the requirements is that you must specify the documentation sources as follows:

<DocumentationSources>
    <DocumentationSource sourceFile="$(MSBuildProjectDirectory)\..\src\myApp\bin\Debug\myApp.exe" xmlns="" />
    <DocumentationSource sourceFile="$(MSBuildProjectDirectory)\..\src\myApp\bin\Debug\myApp.xml" xmlns="" />
</DocumentationSources>

Sandcastle Help File Builder comes with a utils assembly that has a way of retrieving all dll and xml files from a specified directory. I want to call the method from this assembly and store its result as a list of <DocumentationSource>. This is a static method which returns Collection<string>

like image 398
Draco Avatar asked Oct 26 '25 18:10

Draco


1 Answers

Custom Tasks are great but potential overkill if you want to do something simple. I believe Draco is asking about the Property Functions feature in MSBuild 4.

An example of setting a property by using a static function (ripped directly from above page):

<Today>$([System.DateTime]::Now)</Today>

And to call a static function on parameters:

$([Class]:: Property.Method(Parameters))

Or, perhaps you want something crazier like inline tasks. (edit: maybe try this link if the previous doesn't work

like image 71
fostandy Avatar answered Oct 29 '25 03:10

fostandy