title: Azure Project build package working from VS, failing from command line with error MSB4096
body: <p>I have a solution with a Windows Azure Cloud Services project, that compiles fine from VS and command line.</p>
  
  <p>If I try to make a package, it works fine from VS, but fails from command line.</p>
  
  <p>Here is my command line from Powershell:</p>
  
  <pre><code>C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe .\project.sln --% 
  /p:Configuration="QA" /p:TargetProfile="CloudQA" /p:Platform="Any CPU" /target:Publish
  /nr:false
  </code></pre>
  
  <p>I have this error:</p>
  
  <pre><code>"C:\CI\project\project.sln" (Publish target) (1) -&gt;
  "C:\CI\project\WindowsAzure\WindowsAzure.ccproj.metaproj" (Publish target) (11) -&gt;
  "C:\CI\project\WindowsAzure\WindowsAzure.ccproj" (Publish target) (12) -&gt;
  (PrepareRoleItems target) -&gt;
    C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\Windows Azure Tools\2.0\Microsoft.WindowsAzure.targets(13
  02,5): error MSB4096: The item "C:\CI\project\project.WebAPI\project.WebAPI.csproj" in item list "Projec
  tReferenceWithConfiguration" does not define a value for metadata "Name".  In order to use this metadata, either qualif
  y it by specifying %(ProjectReferenceWithConfiguration.Name), or ensure that all items in this list define a value for
  this metadata. [C:\CI\project\WindowsAzure\WindowsAzure.ccproj]
  </code></pre>
  
  <p><strong>EDIT</strong>
  Few interesting things:
  Here is my csdef file</p>
  
  <pre><code>&lt;WorkerRole name="ProjectWorker" vmsize="ExtraSmall"&gt;
    &lt;Imports&gt;
      &lt;Import moduleName="Diagnostics" /&gt;
    &lt;/Imports&gt;
    &lt;Endpoints&gt;
      &lt;InternalEndpoint name="InternalEndpoint1" protocol="http" /&gt;
    &lt;/Endpoints&gt;
    &lt;ConfigurationSettings&gt;
    &lt;/ConfigurationSettings&gt;
  &lt;/WorkerRole&gt;
  &lt;WebRole name="Project.Web" vmsize="ExtraSmall"&gt;
    &lt;Sites&gt;
      &lt;Site name="Web"&gt;
        &lt;Bindings&gt;
          &lt;Binding name="http" endpointName="http" /&gt;
        &lt;/Bindings&gt;
      &lt;/Site&gt;
      &lt;Site name="Api" physicalDirectory="..\..\..\Project.WebAPI"&gt;
        &lt;Bindings&gt;
          &lt;Binding name="http" endpointName="http81" /&gt;
        &lt;/Bindings&gt;
      &lt;/Site&gt;
    &lt;/Sites&gt;
    &lt;Endpoints&gt;
      &lt;InputEndpoint name="http" protocol="http" port="80" /&gt;
      &lt;InputEndpoint name="http81" protocol="http" port="81" /&gt;
    &lt;/Endpoints&gt;
    &lt;Imports&gt;
      &lt;Import moduleName="Diagnostics" /&gt;
    &lt;/Imports&gt;
  &lt;/WebRole&gt;
  </code></pre>
  
  <p>As you can see, I have two websites on one WebRole.</p>
  
  <p>Now, let's have a look at the ccproj file:</p>
  
  <pre><code>&lt;ItemGroup&gt;
    &lt;ProjectReference Include="..\Project.Web\Project.Web.csproj"&gt;
      &lt;Name&gt;Project.Web&lt;/Name&gt;
      &lt;Project&gt;{5d000123-0000-4b6e-b5fa-72525afca7f5}&lt;/Project&gt;
      &lt;Private&gt;True&lt;/Private&gt;
      &lt;RoleType&gt;Web&lt;/RoleType&gt;
      &lt;RoleName&gt;Project.Web&lt;/RoleName&gt;
      &lt;UpdateDiagnosticsConnectionStringOnPublish&gt;True&lt;/UpdateDiagnosticsConnectionStringOnPublish&gt;
    &lt;/ProjectReference&gt;
    &lt;ProjectReference Include="..\ProjectWorker\ProjectWorker.csproj"&gt;
      &lt;Name&gt;ProjectWorker&lt;/Name&gt;
      &lt;Project&gt;{22e99999-1000-4559-8507-a948b7e3d1b0}&lt;/Project&gt;
      &lt;Private&gt;True&lt;/Private&gt;
      &lt;RoleType&gt;Worker&lt;/RoleType&gt;
      &lt;RoleName&gt;ProjectWorker&lt;/RoleName&gt;
      &lt;UpdateDiagnosticsConnectionStringOnPublish&gt;True&lt;/UpdateDiagnosticsConnectionStringOnPublish&gt;
    &lt;/ProjectReference&gt;
  &lt;/ItemGroup&gt;
  </code></pre>
  
  <p>Only two projects are referenced in the ccproj instead of 3.</p>
  
  <p>The cloud project has 3 dependencies in the sln.</p>
  
  <p>If I had a reference by hand in the ccproj like this:</p>
  
  <pre><code>&lt;ProjectReference Include="..\Project.WebAPI\Project.WebAPI.csproj"&gt;
    &lt;Name&gt;Project.Web&lt;/Name&gt;
    &lt;Project&gt;{A0F88888-3333-4823-A34F-5F01F0A3FFFF}&lt;/Project&gt;
    &lt;Private&gt;True&lt;/Private&gt;
    &lt;RoleType&gt;Web&lt;/RoleType&gt;
    &lt;RoleName&gt;Project.WebAPI&lt;/RoleName&gt;
    &lt;UpdateDiagnosticsConnectionStringOnPublish&gt;True&lt;/UpdateDiagnosticsConnectionStringOnPublish&gt;
  &lt;/ProjectReference&gt;
  </code></pre>
  
  <p>I have this error:</p>
  
  <pre><code>C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\Windows Azure Tools\2.0
  \Microsoft.WindowsAzure.targets(987,5): error : CloudServices25 : Multiple directories are 
  specified for role Project.Web. [C:\CI\project\WindowsAzure\WindowsAzure.ccproj]
  </code></pre>
  
  <p>Now if I update the reference like this:</p>
  
  <pre><code>&lt;ProjectReference Include="..\Project.WebAPI\Project.WebAPI.csproj"&gt;
    &lt;Name&gt;Project.WebAPI&lt;/Name&gt;
    &lt;Project&gt;{A0F88888-3333-4823-A34F-5F01F0A3FFFF}&lt;/Project&gt;
    &lt;Private&gt;True&lt;/Private&gt;
    &lt;RoleType&gt;Web&lt;/RoleType&gt;
    &lt;RoleName&gt;Project.Web&lt;/RoleName&gt;
    &lt;UpdateDiagnosticsConnectionStringOnPublish&gt;True&lt;/UpdateDiagnosticsConnectionStringOnPublish&gt;
  &lt;/ProjectReference&gt;
  </code></pre>
  
  <p>I have this error:</p>
  
  <pre><code>C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\Windows Azure Tools\2.0
  \Microsoft.WindowsAzure.targets(987,5): error : CloudServices26 : Cannot find role 
  named 'Project.WebAPI' in service description file 
  C:\CI\project\WindowsAzure\bin\UAT\ServiceDefinition.csdef.     
  [C:\CI\project\WindowsAzure\WindowsAzure.ccproj]
  </code></pre>