Share via

FilesForPackagingFromProject is Project File does not work

Deepak Vasudevan 96 Reputation points
2021-04-30T05:52:58.293+00:00

I have a custom addition to my .csproj file as below. The expectation is that all folders within Areas/ should be copied to published location/Areas and also LavanyaDeepak.Web.API.dll which is present in folder of Web and ought to have been copied but missed is also addressed.

However neither of the copy is getting accomplished.

<PropertyGroup>
<CopyAreaFiles>
CollectAndCopyAreaFiles;
$(CopyAreaFiles);
</CopyAreaFiles>
</PropertyGroup>
<Target Name="CollectAndCopyAreaFiles">
<ItemGroup>
<AreaFiles Include="Areas*" />
<FilesForPackagingFromProject Include="%(AreaFiles.Identity)">
<DestinationRelativePath>Areas\%(RecursiveDir)</DestinationRelativePath>
</FilesForPackagingFromProject>
</ItemGroup>
<ItemGroup>
<WebAPI Include="bin\LavanyaDeepak.WEB.Api.dll" />
<FilesForPackagingFromProject Include="%(WebAPI.Identity)">
<DestinationRelativePath>bin\LavanyaDeepak.WEB.Api.dll</DestinationRelativePath>
</FilesForPackagingFromProject>
</ItemGroup>
</Target>

Developer technologies | Visual Studio | Other
Developer technologies | Visual Studio | Other

A family of Microsoft suites of integrated development tools for building applications for Windows, the web, mobile devices and many other platforms. Miscellaneous topics that do not fit into specific categories.

Community Center | Not monitored
0 comments No comments

1 answer

Sort by: Most helpful
  1. Tianyu Sun-MSFT 34,836 Reputation points Microsoft External Staff
    2021-04-30T11:59:12.29+00:00

    Hello @Deepak Vasudevan ,

    Welcome to Microsoft Q&A forum.

    Per this document: MSBuild well-known item metadata--%(RecursiveDir), the %(RecursiveDir) specifies the part of the path that replaces the wildcard, so if you try to change this path <AreaFiles Include=”Areas*” /> to use wildcard for example < AreaFiles Include=”**\Areas*” /> will it work?(Not sure where these Areas* files/folders are located on your side, if they are located in your solution folder, you can try **\Areas*, if they are located in your project folder, you can try **\[your project name]\Areas* )

    Besides, the <DestinationRelativePath>Areas\%(RecursiveDir)</DestinationRelativePath> code line should also be modified. As %(RecursiveDir) specifies the part of the path that replaces the wildcard, %(RecursiveDir) would be Drive:\XXXX\... for example C:\MySolution so if you add Areas\ before it, it will not be identified as a correct path.

    You may also need to check these documents: Update the publish profile file and MSBuild well-known item metadata.

    Best Regards,
    Tianyu

    • If the answer is helpful, please click "Accept Answer" and upvote it.
      Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    Was this answer helpful?

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.