Error using MSBuild tokens in PropertyGroup

I am trying to configure some properties that I use several times in my MSBuild script. I have the following properties section:

<PropertyGroup>
    <BuildDependsOn>$(BuildDependsOn); MyAfterBuild </BuildDependsOn>
    <SubstitutionsFilePath>$(ProjectDir)app.config.substitutions.xml </SubstitutionsFilePath>
    <AppConfig>$(TargetPath).config</AppConfig>
    <HostConfig>$(TargetDir)$(TargetName).vshost.exe.config</HostConfig>
</PropertyGroup>

When I run this, I get the following error:

The expression "@(TargetPath).config" cannot be used in this context. Item lists cannot be concatenated with other strings where an item list is expected. Use a semicolon to separate multiple item lists.

I do not understand this error, since using $(BuildDependsOn)and $(ProjectDir)works fine. And I know that the values ​​are $(TargetXXX)generated properly, when I put them directly in the "Tasks" section below, they work fine.

+3
source share
3 answers

, TargetDir , ; , , ?

, $(OutDir) $(TargetDir).

( OutDir Microsoft.Common.Targets( 100-102) OutputPath, .)

+2

/v: diag, , .

Microsoft.Common.targets( % SystemRoot%\Microsoft.NET\Framework\v2.0.50727) PrepareForBuild:

   <!-- 
    These CreateProperty calls are required because TargetDir and TargetPath are defined 
    to contain an item list. We want that item list to be expanded so that it can be used
    as a regular property value and not as an item-list-with-transform.
    -->
    <CreateProperty Value="$(TargetDir)">
        <Output TaskParameter="Value" PropertyName="TargetDir" />
    </CreateProperty>

    <CreateProperty Value="$(TargetPath)">
        <Output TaskParameter="Value" PropertyName="TargetPath" />
    </CreateProperty>
+1

This seems like an error to me, you can report it https://connect.microsoft.com/feedback/Search.aspx?SiteID=210 .

+1
source

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


All Articles