I am trying to publish my application (mvc and webapi2) using visual studio on Azure App Services. Everything working fine when I publish the normal structure.
Then I tried to add a folder that is not a part of my solution (generates and changes by front-enders some how) so I've added the required folder to msbuild and everything works fine when I publish to a normal profile (local folder).
On the next step, I try to publish the project on the azure, where I saw that it won't publish files that I've added to ms-build. How to fix it?
I've googled it and I've found this: Publish Azure Application with MSBuild and the answer is to publish using Power shell.
But the link is 2 years old and I Azure matured a lot in this 2 years. Is there any way to do it using visual studio?
Yes, we can do it using Visual Studio. Please have a try to add following code in the project file .I create a demo for it, the following is my detail steps.
<ItemGroup> <Content Include="C:\test\**"> <Link>test\%(RecursiveDir)%(Filename)%(Extension)</Link> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> </Content> </ItemGroup>
Create MVC project vis visual studio
Unload the project from the solution via right click the project name.
Update: Use target to do that
<Target Name="CopyFiles" BeforeTargets="PrepareForBuild"> <Copy SourceFiles="@(MySourceFiles)" DestinationFiles="@(MySourceFiles->'C:\Tom\MSBuild\MSBuild\test\%(RecursiveDir)%(Filename)%(Extension)')" /> </Target> <Target Name="BeforeBuild"> <ItemGroup> <Content Include="test\**\*.*" /> </ItemGroup>