msbuildmsbuild-propertygroup

How to add a custom Property as a child of a PropertyGroup in MSBuild?


I have the following build script, which I run with MSBuild:

<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Compile" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion ="3.5">
<PropertyGroup>
    <BuildDir Condition=" '$(BuildDir)'==' ' ">$(BaseDir)/build</BuildDir>
    <ProdDir >$(BuildDir)/prod</ProdDir>
    <TestDir>$(BuildDir)/test</TestDir>
    <MMC2SourceDir>SteuerungsZugriffTest/mmc2</MMC2SourceDir>
    <UserSourceDir>SteuerungsZugriffTest/user</UserSourceDir>
    <TestXMLDir>$(BuildDir)/test-results</TestXMLDir>
    <SolutionFile Condition=" '$(SolutionFile)'==' ' ">HMI2.0.sln</SolutionFile>"
    <NUnitTest>nunit-console.exe</NUnitTest>
</PropertyGroup>
<Target Name="Prepare">
    <Message Text="Prepare everything" />
    <MakeDir Directories="$(BuildDir)" />
    <MakeDir Directories="$(ProdDir)" />
</Target>
...

When I now start script on the command line:

D:\MyDir>msbuild /property:BaseDir=D:\MyDir MyScript.build

I got the following error on the commandline output:

D:\MyDir>MyScript.build(11,78): error MSB4067: Das <#text>-Element unterhalb des <PropertyGroup>-Elements ist unbekannt.

Which basically means: The element<#text> is an unknown child.

Does anybody have an idea?

Edit: Sorry, I completed now the script


Solution

  • You have an extra " at the end of this line

    <SolutionFile Condition=" '$(SolutionFile)'==' ' ">HMI2.0.sln</SolutionFile>"
    

    It is outside a tag, so it is considered as a text element...