0
votes

I use VS2017 and web deploy. 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.

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). So every time I publish, I need to manualy copy-paste dll to the VM App_Data directory.

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. It creates files, but when I publish, App_data files are ignored
  • Edit the pubxml file from C:/MyProject/Properties/PublishProfiles/mypp.pubxml, but I didn't found relevant infos or documentation to push farther.
  • Using Azure RunBooks, but I didn't find the option to launch it after publishing.

I look for either some help or documentation about publishing I didn't already found, or maybe some trick for azure runbook.

Don't hesitate to point out typos, I'm quite tired at the moment.

1

1 Answers

0
votes

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. Here is the settings for copying file(s) when deploying your application via ms deploy, you could refer to it:

<?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.