简体   繁体   中英

Publish Azure Application with MS-Build on vs2015

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?


please note that this is not a duplicate of Publish Azure Application with MSBuild since it is 2 years later, and on vs 2015 and Azure sdk is 2.9 not 2.2.

And if you don't agree, or anything please comment.

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>
  1. Create MVC project vis visual studio

  2. Unload the project from the solution via right click the project name.

在此处输入图片说明

  1. Edit the project file

在此处输入图片说明

  1. Add the script in the project file and reload the project.

在此处输入图片说明 Source Files: 在此处输入图片说明

  1. Publish the project to azure and check the files from the kudu tools.

在此处输入图片说明

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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM