0

MSbuildタスクを使用してmsbuildプロジェクト間でアイテムグループを渡すにはどうすればよいですか? 以下に示すように、Msbuildタスクがあります

<Target Name ="test">
    <MSBuild Projects="New.proj" Targets="mytarget"
            Properties="Itemproperty=@(Item->'%(FullPath)')">
    </MSBuild>
</Target>

「アイテム」はアイテムグループですが、以下のようなエラーが発生します。

 error MSB4012: The expression "Itemproperty=@(Item->'%(FullPath)')" cannot be used in   this context. Item lists cannot beconcatenated with other strings where an item list is     expected. Use a semicolonto separate multiple item lists.

ありがとう

4

1 に答える 1

0

それを大きな長い(単一の)文字列に「平らにする」ことはできますか?

例:

   <PropertyGroup>
        <MySuperLongString>@(MyIncludeFiles->'&quot;%(fullpath)&quot;')</MySuperLongString>
    </PropertyGroup>

ここにいくつかの「オプション」があります

<Message Text="The below items are good when you need to feed command line tools, like the console NUnit exe.  Quotes around the filenames help with paths that have spaces in them. "/>
<Message Text="I found this method initially from : http://pscross.com/Blog/post/2009/02/22/MSBuild-reminders.aspx       Thanks Pscross! "/>
<Message Text="   "/>
<Message Text="   "/>



<Message Text="Flat list, each file surrounded by quotes, with semi colon delimiter: "/>
<Message Text="          @(MyIncludeFiles->'&quot;%(fullpath)&quot;')"/>
<Message Text="   "/>
<Message Text="   "/>



<Message Text="Flat list, each file surrounded by quotes, no comma (space delimiter): "/>
<Message Text="          @(MyIncludeFiles->'&quot;%(fullpath)&quot;' , ' ')"/>
<Message Text="   "/>
<Message Text="   "/>


<Message Text="Flat list, each file surrounded by quotes, with comma delimiter: "/>
<Message Text="          @(MyIncludeFiles->'&quot;%(fullpath)&quot;' , ',')"/>
<Message Text="   "/>
<Message Text="   "/>





<Message Text="List of files using special characters (carriage return)"/>
<Message Text="@(MyIncludeFiles->'&quot;%(fullpath)&quot;' , '%0D%0A')"/>
<Message Text="   "/>
<Message Text="   "/>

以下の完全な例:

<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="AllTargetsWrapper" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

    <Target Name="AllTargetsWrapper">
        <CallTarget Targets="FunWithFilesTask" />
    </Target>


    <PropertyGroup>
        <WorkingCheckout>.</WorkingCheckout>
    </PropertyGroup>


                <!--    =====================================================                      -->

                <!--

              See:
              http://msdn.microsoft.com/en-us/library/ms164313.aspx

            *Identity    Value for the item specified in the Include attribute.
            *Filename   Filename for this item, not including the extension.
            *Extension  File extension for this item.
            *FullPath   Full path of this item including the filename.
            *RelativeDir    Path to this item relative to the current working directory.
            *RootDir    Root directory to which this item belongs.
            RecursiveDir    Used for items that were created using wildcards. This would be the directory that replaces the wildcard(s) statements that determine the directory.
            *Directory  The directory of this item.
            AccessedTime    Last time this item was accessed.
            CreatedTime     Time the item was created.
            ModifiedTime    Time this item was modified.   
              -->


    <Target Name="FunWithFilesTask">


        <ItemGroup>
            <MyExcludeFiles Include="$(WorkingCheckout)\**\*.doesnotexist" />
        </ItemGroup>

        <ItemGroup>
            <MyIncludeFiles Include="$(WorkingCheckout)\**\*.*" Exclude="@(MyExcludeFiles)" />
        </ItemGroup>  



        <PropertyGroup>
            <MySuperLongString>@(MyIncludeFiles->'&quot;%(fullpath)&quot;')</MySuperLongString>
    </PropertyGroup>  

    <Message Text="MySuperLongString=$(MySuperLongString)"/>
    <Message Text="   "/>
    <Message Text="   "/>


    <Message Text="The below items are good when you need to feed command line tools, like the console NUnit exe.  Quotes around the filenames help with paths that have spaces in them. "/>
    <Message Text="I found this method initially from : http://pscross.com/Blog/post/2009/02/22/MSBuild-reminders.aspx       Thanks Pscross! "/>
    <Message Text="   "/>
    <Message Text="   "/>



    <Message Text="Flat list, each file surrounded by quotes, with semi colon delimiter: "/>
    <Message Text="          @(MyIncludeFiles->'&quot;%(fullpath)&quot;')"/>
    <Message Text="   "/>
    <Message Text="   "/>



    <Message Text="Flat list, each file surrounded by quotes, no comma (space delimiter): "/>
    <Message Text="          @(MyIncludeFiles->'&quot;%(fullpath)&quot;' , ' ')"/>
    <Message Text="   "/>
    <Message Text="   "/>


    <Message Text="Flat list, each file surrounded by quotes, with comma delimiter: "/>
    <Message Text="          @(MyIncludeFiles->'&quot;%(fullpath)&quot;' , ',')"/>
    <Message Text="   "/>
    <Message Text="   "/>


    <Message Text="List of files using special characters (carriage return)"/>
    <Message Text="@(MyIncludeFiles->'&quot;%(fullpath)&quot;' , '%0D%0A')"/>
    <Message Text="   "/>
    <Message Text="   "/>



</Target>


</Project>
于 2013-10-16T20:50:00.867 に答える