Reputation: 5989
I have a solution with a Windows Azure Cloud Services project, that compiles fine from VS and command line.
If I try to make a package, it works fine from VS, but fails from command line.
Here is my command line from Powershell:
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
I have this error:
"C:\CI\project\project.sln" (Publish target) (1) ->
"C:\CI\project\WindowsAzure\WindowsAzure.ccproj.metaproj" (Publish target) (11) ->
"C:\CI\project\WindowsAzure\WindowsAzure.ccproj" (Publish target) (12) ->
(PrepareRoleItems target) ->
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]
EDIT Few interesting things: Here is my csdef file
<WorkerRole name="ProjectWorker" vmsize="ExtraSmall">
<Imports>
<Import moduleName="Diagnostics" />
</Imports>
<Endpoints>
<InternalEndpoint name="InternalEndpoint1" protocol="http" />
</Endpoints>
<ConfigurationSettings>
</ConfigurationSettings>
</WorkerRole>
<WebRole name="Project.Web" vmsize="ExtraSmall">
<Sites>
<Site name="Web">
<Bindings>
<Binding name="http" endpointName="http" />
</Bindings>
</Site>
<Site name="Api" physicalDirectory="..\..\..\Project.WebAPI">
<Bindings>
<Binding name="http" endpointName="http81" />
</Bindings>
</Site>
</Sites>
<Endpoints>
<InputEndpoint name="http" protocol="http" port="80" />
<InputEndpoint name="http81" protocol="http" port="81" />
</Endpoints>
<Imports>
<Import moduleName="Diagnostics" />
</Imports>
</WebRole>
As you can see, I have two websites on one WebRole.
Now, let's have a look at the ccproj file:
<ItemGroup>
<ProjectReference Include="..\Project.Web\Project.Web.csproj">
<Name>Project.Web</Name>
<Project>{5d000123-0000-4b6e-b5fa-72525afca7f5}</Project>
<Private>True</Private>
<RoleType>Web</RoleType>
<RoleName>Project.Web</RoleName>
<UpdateDiagnosticsConnectionStringOnPublish>True</UpdateDiagnosticsConnectionStringOnPublish>
</ProjectReference>
<ProjectReference Include="..\ProjectWorker\ProjectWorker.csproj">
<Name>ProjectWorker</Name>
<Project>{22e99999-1000-4559-8507-a948b7e3d1b0}</Project>
<Private>True</Private>
<RoleType>Worker</RoleType>
<RoleName>ProjectWorker</RoleName>
<UpdateDiagnosticsConnectionStringOnPublish>True</UpdateDiagnosticsConnectionStringOnPublish>
</ProjectReference>
</ItemGroup>
Only two projects are referenced in the ccproj instead of 3.
The cloud project has 3 dependencies in the sln.
If I had a reference by hand in the ccproj like this:
<ProjectReference Include="..\Project.WebAPI\Project.WebAPI.csproj">
<Name>Project.Web</Name>
<Project>{A0F88888-3333-4823-A34F-5F01F0A3FFFF}</Project>
<Private>True</Private>
<RoleType>Web</RoleType>
<RoleName>Project.WebAPI</RoleName>
<UpdateDiagnosticsConnectionStringOnPublish>True</UpdateDiagnosticsConnectionStringOnPublish>
</ProjectReference>
I have this error:
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]
Now if I update the reference like this:
<ProjectReference Include="..\Project.WebAPI\Project.WebAPI.csproj">
<Name>Project.WebAPI</Name>
<Project>{A0F88888-3333-4823-A34F-5F01F0A3FFFF}</Project>
<Private>True</Private>
<RoleType>Web</RoleType>
<RoleName>Project.Web</RoleName>
<UpdateDiagnosticsConnectionStringOnPublish>True</UpdateDiagnosticsConnectionStringOnPublish>
</ProjectReference>
I have this error:
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]
Upvotes: 11
Views: 5256
Reputation: 524
I found this link: Visual Studio 2010 Beta 2 myTODO Error message it works for me. The valuable information from that link:
It seems like maybe Azure does not like it if you specify anything besides an Azure Role project as a dependency on the service project. I made it so MyWebRole.csproj was dependent on xxx.csproj, instead of MyService.ccproj being dependent on xxx.csproj, and it worked.
Upvotes: 6
Reputation: 1808
I stumbled upon a similar problem when building my cloud project from the command line, in particular I get this exception if the web project referenced by the VirtualDirectory
tag is marked as a build dependency for the cloud project.
To avoid this and ensure that the web project is compiled and included in the cspack
, I come up with a procedure simpler that the one cited in Swell's answer -- in particular it does not require to alter the project files but only to call two targets in a precise order:
Configuration Manager
that the web project will be rebuilt in the desired solution configuration (for example ensure that it is built under Release
configuration);do a rebuild of the solution, for example
MsBuild solution.sln /t:Rebuild ...
This way the web project will be recompiled.
perform a publish of the cloud project, for example
MsBuild solution.sln /t:cloudproject.ccproj:publish ...
The web project will be copied correctly to the cspack
file.
Upvotes: 1
Reputation: 5989
This post solved my problem: http://michaelcollier.wordpress.com/2013/01/14/multiple-sites-in-a-web-role/
A must read if you have several websites on one webrole!
Upvotes: 3