简体   繁体   English

如何将特定的App_Data文件发布到Azure VM(IIS)

[英]How to publish specific App_Data files to an Azure VM (IIS)

I use VS2017 and web deploy. 我使用VS2017和Web部署。 I have two solutions : a web app that we deploy on an Azure VM, and a C# solution which is the engine of the web app. 我有两个解决方案:我们在Azure VM上部署的Web应用程序,以及作为Web应用程序引擎的C#解决方案。

The web app has references of the engine, but it needs also to have dlls in App_Data to work (my coworker speaks about runtime problem). 该Web应用程序具有引擎的引用,但它也需要App_Data中的dll才能起作用(我的同事谈到了运行时问题)。 So every time I publish, I need to manualy copy-paste dll to the VM App_Data directory. 因此,每次发布时,我都需要手动将dll复制粘贴到VM App_Data目录。

I want to automatize this process , I tried some approaches of this problem : 我想使这个过程自动化 ,我尝试了一些解决这个问题的方法:

  • Puting batch script in web app properties => build => afterbuild, in order to automatically copy dll from bin/debug to App_Data. 将批处理脚本放入Web应用程序属性=> build => afterbuild,以便将dll从bin / debug自动复制到App_Data。 It creates files, but when I publish, App_data files are ignored 它创建文件,但是当我发布时,App_data文件将被忽略
  • Edit the pubxml file from C:/MyProject/Properties/PublishProfiles/mypp.pubxml, but I didn't found relevant infos or documentation to push farther. 从C:/MyProject/Properties/PublishProfiles/mypp.pubxml编辑pubxml文件,但是我没有找到进一步的相关信息或文档。
  • Using Azure RunBooks, but I didn't find the option to launch it after publishing. 使用Azure RunBooks,但在发布后没有找到启动它的选项。

I look for either some help or documentation about publishing I didn't already found, or maybe some trick for azure runbook. 我在找一些我尚未找到的有关发布的帮助或文档,或者在寻找一些关于Azure Runbook的技巧。

Don't hesitate to point out typos, I'm quite tired at the moment. 请毫不犹豫地指出错别字,此刻我很累。

Per my understanding, you do not need to add Post-build event script. 据我了解,您不需要添加构建后事件脚本。 You could just modify your *.pubxml and add some MSBuild Task before you deploy your application. 您可以在部署应用程序之前修改*.pubxml并添加一些MSBuild任务。 Here is the settings for copying file(s) when deploying your application via ms deploy, you could refer to it: 这是通过ms deploy部署应用程序时用于复制文件的设置,您可以参考该设置:

<?xml version="1.0" encoding="utf-8"?>

<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

  <PropertyGroup>
    <!--****-->
  </PropertyGroup>

  <Target Name="Copy dlls to App_Data" AfterTargets="CopyAllFilesToSingleFolderForMsdeploy">
    <ItemGroup>
      <_FileForCopy Include="$(_PackageTempDir)\bin\ClassLibrary1.dll" />
      <_FileForCopy  Include="$(_PackageTempDir)\bin\Antlr3.Runtime.dll" />
    </ItemGroup>
    <Copy SourceFiles="@(_FileForCopy)" DestinationFolder="$(_PackageTempDir)\App_Data\%(RecursiveDir)" />
  </Target>

</Project>

Additionally, you could follow those tutorials about MSBuild Targets , How To: Recursively Copy Files Using the Task . 此外,您可以按照那些有关MSBuild目标的教程:如何:使用Task递归复制文件

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

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