简体   繁体   English

在vs2015上发布带有MS-Build的Azure应用

[英]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. 我正在尝试使用Azure App Services上的Visual Studio发布我的应用程序(mvc和webapi2)。 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). 然后,我尝试添加一个不属于我的解决方案的文件夹(由前端渲染器生成并更改某些内容),因此我已将所需的文件夹添加到msbuild中,并且在发布到普通配置文件(本地文件夹)时一切正常)。

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. 下一步,我尝试在Azure上发布项目,在那里我看到它不会发布我添加到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. 我用Google搜索它,发现了这一点: 使用MSBuild发布Azure应用程序,答案是使用Power Shell发布。

But the link is 2 years old and I Azure matured a lot in this 2 years. 但是链接已有2年历史了,而我Azure在这2年中已经成熟了很多。 Is there any way to do it using visual studio? 使用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. 请注意 ,这不是使用MSBuild发布Azure应用程序的副本,因为它是2年后的版本,而与2015和Azure sdk相比则是2.9而不是2.2。

And if you don't agree, or anything please comment. 如果您不同意,请发表评论。

Yes, we can do it using Visual Studio. 是的,我们可以使用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 通过Visual Studio创建MVC项目

  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. 将项目发布为天蓝色,然后从kudu工具中检查文件。

在此处输入图片说明

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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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