Dela via


Azure SDK has trouble with worker roles whose names are different from the role’s project name – and how to fix it

I had seen this before, but today I became determined to figure out how to fix my targets file.
The problem is caused by this code in the msbuild targets which assumes that project name and role name are the same.
AFAICS Azure 2.2 SDK, 2.3 SDK and 2.4 SDK have this exact same problem.

<ItemGroup>
      < WorkerRoleReferences Include="$(_WorkerRoleProject)">
        < RoleType>Worker</RoleType>
        <RoleName>$(_WorkerRoleProjectName)</RoleName>
        <ProjectName>$(_WorkerRoleProjectName)</ProjectName>

To fix it, you change it to

<ItemGroup>
  < WorkerRoleReferences Include="$(_WorkerRoleProject)">
    < RoleType>Worker</RoleType>
    <RoleName>$(_WorkerRoleProjectRoleName)</RoleName>
    < ProjectName>$(_WorkerRoleProjectName)</ProjectName>

and define WorkerRoleProjectRoleName and above:

<PropertyGroup>
     <_WorkerRoleProject>%(WorkerRoleProjects.Identity)</_WorkerRoleProject>
     <_WorkerRoleProjectName>%(WorkerRoleProjects.Name)</_WorkerRoleProjectName>
+     <_WorkerRoleProjectRoleName>%(WorkerRoleProjects.RoleName)</_WorkerRoleProjectRoleName>
     <_WorkerRoleConfiguration>%(WorkerRoleProjects.Configuration)</_WorkerRoleConfiguration>
     <_WorkerRolePlatform>%(WorkerRoleProjects.Platform)</_WorkerRolePlatform>
    </PropertyGroup>

<Message Text="WorkerRoleProject=$(_WorkerRoleProject)" />
< Message Text="WorkerRoleProjectName=$(_WorkerRoleProjectName)" />
+<Message Text="WorkerRoleProjectRoleName=$(_WorkerRoleProjectRoleName)" />
< Message Text="WorkerRoleConfiguration=$(_WorkerRoleConfiguration)" />
< Message Text="WorkerRolePlatform=$(_WorkerRolePlatform)" />

Web Roles probably have the same issue too. I haven’t checked.