question

lavanyadeepak avatar image
0 Votes"
lavanyadeepak asked TianyuSun-MSFT edited

FilesForPackagingFromProject is Project File does not work

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>

vs-generalvs-msbuild
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

TianyuSun-MSFT avatar image
0 Votes"
TianyuSun-MSFT answered

Hello @lavanyadeepak ,

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.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.