2012-06-20 89 views
2

排除特定的文件,我在我的csproj文件的MSBuild這個目標:我如何從我的MSBuild AfterBuild目標

<Target Name="AfterBuild" Condition=" '$(Configuration)' == 'Release' "> 
    <CreateItem Condition="'%(Extension)'=='.dll'" Include="@(ReferenceCopyLocalPaths)"> 
     <Output TaskParameter="Include" ItemName="IlmergeAssemblies" /> 
    </CreateItem> 
    <Exec Command="&quot;$(ProjectDir)..\..\..\tools\IlMerge\Ilmerge.exe&quot; /targetplatform:&quot;v4,C:\Windows\Microsoft.NET\Framework64\v4.0.30319&quot; /ndebug /out:@(MainAssembly) &quot;@(IntermediateAssembly)&quot; @(IlmergeAssemblies->'&quot;%(FullPath)&quot;', ' ')" /> 
    <Delete Files="@(ReferenceCopyLocalPaths->'$(OutDir)%(DestinationSubDirectory)%(Filename)%(Extension)')" /> 
</Target> 

這就像一個魅力。但我希望它排除一個特定的文件,並試圖調整它:

<Target Name="AfterBuild" Condition=" '$(Configuration)' == 'Release' "> 
    <CreateItem Condition="'%(Extension)'=='.dll' AND '%(Filename)' != 'Foo.dll'" Include="@(ReferenceCopyLocalPaths)"> 
     <Output TaskParameter="Include" ItemName="IlmergeAssemblies" /> 
    </CreateItem> 
    <Exec Command="&quot;$(ProjectDir)..\..\..\tools\IlMerge\Ilmerge.exe&quot; /targetplatform:&quot;v4,C:\Windows\Microsoft.NET\Framework64\v4.0.30319&quot; /ndebug /out:@(MainAssembly) &quot;@(IntermediateAssembly)&quot; @(IlmergeAssemblies->'&quot;%(FullPath)&quot;', ' ')" /> 
    <Delete Files="@(ReferenceCopyLocalPaths->'$(OutDir)%(DestinationSubDirectory)%(Filename)%(Extension)')" /> 
</Target> 

但是,這是行不通的。有誰知道我做錯了什麼?

+0

我認爲(通過存儲器)%(文件名)將是 '富' –

+0

是,你是對的。只是想出了相同的。你想放棄一個答案,以便我可以接受它嗎? – Christoph

+0

它發生在我身上的一次,但我不確定,現在無法測試..這就是我把它作爲評論的原因。我現在已經創建了一個答案。快樂你解決了問題:) –

回答

4

%(文件名)只包含文件的名稱。

所以,你可以測試%(文件名)富」!= ''

<Target Name="AfterBuild" Condition=" '$(Configuration)' == 'Release' "> 
<CreateItem Condition="'%(Extension)'=='.dll' AND '%(Filename)' != 'Foo'" Include="@(ReferenceCopyLocalPaths)"> 
    <Output TaskParameter="Include" ItemName="IlmergeAssemblies" /> 
</CreateItem> 
<Exec Command="&quot;$(ProjectDir)..\..\..\tools\IlMerge\Ilmerge.exe&quot; /targetplatform:&quot;v4,C:\Windows\Microsoft.NET\Framework64\v4.0.30319&quot; /ndebug /out:@(MainAssembly) &quot;@(IntermediateAssembly)&quot; @(IlmergeAssemblies->'&quot;%(FullPath)&quot;', ' ')" /> 
<Delete Files="@(ReferenceCopyLocalPaths->'$(OutDir)%(DestinationSubDirectory)%(Filename)%(Extension)')" /> 

相關問題