2013-10-16 73 views
0

如何在使用MSbuild任務的msbuild項目之間傳遞項目組。我有一個MSBuild任務以下在msbuild項目之間傳遞Itemgroup

<Target Name ="test"> 
    <MSBuild Projects="New.proj" Targets="mytarget" 
      Properties="[email protected](Item->'%(FullPath)')"> 
    </MSBuild> 
</Target> 

給出在哪裏「項目」是itemgroup.But IAM收到錯誤如下。

error MSB4012: The expression "[email protected](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. 

感謝

回答

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> 
+0

但我怎樣才能通過這個項目給其他MSBuild項目。不能簡單地傳遞屬性,因爲我必須爲每個item執行一系列任務。只有在完成這些seque後,纔會處理next item任務。 – TVSuser1654136

+0

然後「你不能」......它沒有像那樣連線。但如果有人知道如何,那麼我也會學到一些東西。但我相當肯定你不能那樣做。 – granadaCoder