npocmaka npocmaka - 1 month ago 7
C# Question

Assign parameter value taken from a property in MSBuild

I'm trying to combine batch script and C# code using MSBuild and inline tasks.Looks like the only one way to pass a command line argument is to use a properties (

command line switch in msbuild) and the only one way to access something external from the inline task is to use properties.

How can I combine the properties and parameters in MSBuild in way to make them accessible in the inline task?

Here's an example script (should be saves as
) :

<!-- :
@echo off
for /r "%SystemRoot%\Microsoft.NET\Framework\" %%# in ("*msbuild.exe") do set "msb=%%#"

if not defined msb (
echo no .net framework installed
exit /b 10

rem :::::::::: calling msbuid :::::::::
call %msb% /nologo /noconsolelogger "%~dpsfnx0" /property:H=Hello
rem ::::::::::::::::::::::::::::::::::::
exit /b %errorlevel%

<Project ToolsVersion="4.0" xmlns="">
<Target Name="A">
AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll" >

<ParameterGroup >
<Z ParameterType="System.String">$(H)</Z>

<Code Type="Fragment" Language="js">

is passed to the , the intention is this script to print
but it only prints


If in the command line you use


you can simply use


without the need for the <ParameterGroup /> block