Referencing runtime content from .ccproj (Azure SDK 2.9)

妖精的绣舞 提交于 2019-12-11 08:48:25

问题


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


回答1:


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:

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

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

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



来源:https://stackoverflow.com/questions/45702781/referencing-runtime-content-from-ccproj-azure-sdk-2-9

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!