2012-10-23 23 views
1

我有一個FilesToExclude2.txt文件文件,它包含所有類似的不包括:的MSBuild複製任務和條件名稱從通配符

*.settings 
*#* 
*.vbproj* 
*.csproj* 
*\Errors\* 
*\Errors 
*\_vti_*\* 
*\_vti_* 
*\CVS\* 

在我的任務文件中,有一份工作

<Target Name="CustomModuleCopy"> 
    <ItemGroup> 
     <ModuleFiles Include="$(SolutionModuleName)\$(ProjectModuleName)\**\*.*" /> 
     <FileToExclude Include="$(BasePath)\$(SolutionModuleName)\FilesToExclude2.txt" /> 
    </ItemGroup> 
    <ReadLinesFromFile File="@(FileToExclude)"> 
     <Output TaskParameter="Lines" ItemName="FileContents" /> 
    </ReadLinesFromFile> 

    <Copy SourceFiles="@(ModuleFiles)" DestinationFiles="@(ModuleFiles->'$(DestFolder)\$(ProjectModuleName)\%(RecursiveDir)%(Filename)%(Extension)')" Condition="'%(ModuleFiles.Identity)' != @(FileContents)" ContinueOnError="false" /> 

    <!--CallTarget Targets="RemoveCustomModuleConfigFiles" /--> 
    </Target> 

沒有複製任務的「條件」屬性,一切工作正常,但我不知道如何實現條件與通配符,如果有可能

任何形式的幫助將是非常感謝:)這讓我嚇了幾個小時......

回答

4

只是使用exclude屬性而不是更容易? 如 項目的xmlns = 「http://schemas.microsoft.com/developer/msbuild/2003」>

<ItemGroup> 
    <ModuleFiles Include="c:\code\**\*.*" 
       Exclude="@(FileContents)" /> 
</ItemGroup> 


<!--<Copy SourceFiles="@(ModuleFiles)" DestinationFolder="Some|Destination" Condition="'%(ModuleFiles.Identity)' != @(FileContents)" ContinueOnError="false" /> 

CallTarget Targets="RemoveCustomModuleConfigFiles" /--> 

+0

我想你的解決方案,但它似乎是「排除」物業不走通配符的字符特價... – Pouki

+0

看到我的另一篇文章的:)謝謝精度詹姆斯 – Pouki

+0

我在我的答案真實的位,但它從來沒有做出CTRL + V ...現在所有的固定? –

0

以下代碼

<Target Name="CustomModuleCopy"> 
    <ItemGroup> 
     <FileToExclude Include="$(BasePath)\$(SolutionModuleName)\FilesToExclude.txt" /> 
    </ItemGroup> 
    <ReadLinesFromFile File="@(FileToExclude)"> 
    <Output TaskParameter="Lines" ItemName="FileContents" /> 
    </ReadLinesFromFile> 
    <ItemGroup> 
    <ModuleFiles Include="$(SolutionModuleName)\$(ProjectModuleName)\**\*.*" Exclude="@(FileContents)" /> 
    </ItemGroup> 
    <Copy SourceFiles="@(ModuleFiles)" DestinationFiles="@(ModuleFiles->'$(DestFolder)\$(ProjectModuleName)\%(RecursiveDir)%(Filename)%(Extension)')" ContinueOnError="false" /> 
    <Message Text="Exclude = @(FileContents)" /> 
    <!--CallTarget Targets="RemoveCustomModuleConfigFiles" /--> 
</Target> 

產生硫S IN控制檯輸出:

copy /y "CPBMessaging\CPBMessagingWeb_NotificationMessage\Web.Debug.config" "C:\__CPB\CPBSite\CPBMessagingWeb_NotificationMessage\Web.Debug.config" 
Copying file from "CPBMessaging\CPBMessagingWeb_NotificationMessage\Web.Release.config" to "C:\__CPB\CPBSite\CPBMessagingWeb_NotificationMessage\Web.Release.config" 
copy /y "CPBMessaging\CPBMessagingWeb_NotificationMessage\Web.Release.config" "C:\__CPB\CPBSite\CPBMessagingWeb_NotificationMessage\Web.Release.config" 
Exclude = *.cab;*.config;*.vb;*.cs;*.resx;*.xsx;*.bak;*.myapp;*.settings;*#*; 
*.vbproj*;*.csproj*;*\Errors\*;*\Errors;*\_vti_*\*;*\_vti_*;*\CVS\*;*\CVS;