开发者

How to exclude certain folders while copying using MSBUILD

开发者 https://www.devze.com 2023-02-03 10:07 出处:网络
Seems like it should be fairly simple but I\'m having trouble excluding folders when using the MSBUILD copy task. Here\'s what I\'m doing:

Seems like it should be fairly simple but I'm having trouble excluding folders when using the MSBUILD copy task. Here's what I'm doing:

   <ItemGroup>
        <Compile Include="$(_SolutionPath)$(_SolutionName)" />
        <ProjectFiles Include="..\$(_WebDirectory)\*.csproj" Exclude="*.master.csproj"/>
        <ExcludeFromBuild Include="..\$(_WebDirectory)\**\*.cs; ..\$(_WebDirectory)\**\*.sln; ..\$(_WebDirectory)\**\*.csproj; ..\$(_WebDirectory)\Web References; ..\$(_WebDirectory)\obj;"/>
        <AppFolder Include="..\$(_WebDirectory)\**\*.*" Exclude="$(ExcludeFromBuild)"/>
    </ItemGroup>

<Copy SourceFiles="@(AppFolder)" DestinationFiles="c:\test\%(RecursiveDir)%(FileName)%(Extension)"/>

In the item group section I have an ExcludeFromBuild item which lists开发者_如何学C out the file types i want to exclude. On top of that I want to exclude the "obj" and "Web References" folder.

How can I accomplish this? Please let me know if more information is needed. Thank you.

shahzad


You need to create a new ItemGroup for that. I've added AppFolderWithExclusions below:

<ItemGroup>
     <Compile Include="$(_SolutionPath)$(_SolutionName)" />
     <ProjectFiles Include="..\$(_WebDirectory)\*.csproj" Exclude="*.master.csproj"/>
     <ExcludeFromBuild Include="..\$(_WebDirectory)\**\*.cs; ..\$(_WebDirectory)\**\*.sln; ..\$(_WebDirectory)\**\*.csproj; ..\$(_WebDirectory)\Web References; ..\$(_WebDirectory)\obj;"/>
     <AppFolder Include="..\$(_WebDirectory)\**\*.*" Exclude="$(ExcludeFromBuild)"/>

     <AppFolderWithExclusions Include="@(AppFolder)" Exclude="obj\**\*.*;Web References\**\*.*" />
 </ItemGroup>

(untested; may include syntax typos)

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号