1

I have a worker role that contains a reference to a few nuget packages that drop a few needed runtime files as a post-build step to the project bin folder.

The problem I'm facing is that these files are not being copied over to the published worker role as they are not tracked by the worker role .csproj

Worker role .csproj:

...
<Import Project="[path-to-nupkg]\build\package.targets" Condition="Exists('[path-to-nupkg]\build\package.targets')" />

package.targets copy post-build resources, so after build the worker role bin folder includes:

MyWorkerRole.dll
resource.txt
Resources\another_resource.txt

However, when packaging the worker role for deployment the WorkerRole.cspkg contains only MyWorkerRole.dll.

I tried to follow Dynamically Add Content to Windows Azure Application Roles by adding the following to my .ccproj:

  <Target Name="BeforeAddRoleContent">
    <ItemGroup>
      <AzureRoleContent Include="Resources\*">
        <RoleName>MyWorkerRole</RoleName>
      </AzureRoleContent>
    </ItemGroup>
  </Target>

But the folder is not dropped and I don't get any error during packaging.

Edit: It was suggested I'll try using Role Content Folders, but the problem in my case is that the resources are coming from a Nuget package. So not available until at least build time (actually being dropped as a post-build task).

Assaf Israel
  • 478
  • 3
  • 11
  • Have you tried to use [Role Content Folders](https://blogs.msdn.microsoft.com/philliphoff/2012/06/08/add-files-to-your-windows-azure-package-using-role-content-folders/) for deploying additional content? – Bruce Chen Aug 16 '17 at 09:47
  • @BruceChen The problem in my case is that the resources are coming from a Nuget package and are copied as a post-build step, so no easy way of referencing them in the .ccproj or in the UI. – Assaf Israel Aug 16 '17 at 19:08
  • AFAIK, we could install nuget package and the library(e.g. *.dll) would be copied to the bin folder. I can not understand why you copy files via a post-build task and what are those files used for? Could you share your build task and the nuget package you are using? – Bruce Chen Aug 17 '17 at 09:13
  • @BruceChen The nuget package contains an ML model and the resources are runtime features (mostly text dictionaries and word embeddings). I tried to simplify the description as much as possible in the question description, but I do believe this is a common enough scenario. – Assaf Israel Aug 17 '17 at 21:47

1 Answers1

0

I checked Dynamically Add Content to Windows Azure Application Roles and found the additional folder for storing files should be located within your Azure Cloud Service project as follows:

enter image description here

Then edit your cloud service .ccproj and override the BeforeAddRoleContent target as follows:

enter image description here

After package your cloud service project, you could check the packaged content as follows:

enter image description here

Based on your requirement, you could use build events and copy files into your AdditionalContent folder within the azure cloud service project.

Bruce Chen
  • 18,207
  • 2
  • 21
  • 35