title: How to build unit test project when performing an Azure Cloud service CI build via Visual Studio Online?
body: <p>I have a Visual Studio solution housing an Azure Cloud Service with the following projects:</p>
  
  <ul>
  <li>CloudService</li>
  <li>CloudServiceRole</li>
  <li>Tests</li>
  </ul>
  
  <p>Where the <code>Tests</code> project is a standard MSTest project that contains unit tests for the business logic in the <code>CloudServiceRole</code> project.</p>
  
  <p>The code is stored in Visual Studio Online and I have hooked up the automated CI build deployment that Azure offers. When I check in code, my staging deployment of the cloud service is automatically updated. However, the Tests project is never even built during the CI builds! This, of course, means that no unit tests run during the build as the "run unit tests" part of the build process finds no assemblies with tests.</p>
  
  <p><strong>My goal</strong> is to change this so the tests project is built and all the unit tests executed.</p>
  
  <p>Looking at the MSBuild arguments that the CI deployment process uses, it appears that only the <code>CloudService:Publish</code> target is executed. The <code>CloudService</code> project has no dependency on the <code>Tests</code> project so MSBuild never even builds the latter.</p>
  
  <p><strong>What I have tried</strong></p>
  
  <p>I cannot manually add a <code>CloudService-&gt;Tests</code> dependency because when I add dependencies on projects that are not Cloud Service Role projects, I get an error during build (<code>The item "C:\a\src\MyProject\Tests\Tests.csproj" in item list "ProjectReferenceWithConfiguration" does not define a value for metadata "Name".</code>) and I cannot add a <code>CloudServiceRole-&gt;Tests</code> dependency because that would make a circular dependency.</p>
  
  <p>Instructing MSBuild to build the full solution by manually adding a <code>/t:Build</code> parameter resulted in yet another error: <code>C:\a\bin\ServiceDefinition.csdef: Need to specify the physical directory for the virtual path 'Web/' of role Web.</code></p>
  
  <p>Adding the <code>Tests</code> project as a separate build target, alongside the solution, results in the tests getting built! However, at the same time, it disables the Continuous Deployment functionality: <code>More than one solution found. Continuous Deployment skipped.</code></p>
  
  <p>Trying to make a fake Cloud Service Role project that references the <code>Tests</code> project but has zero instances configured results in a build error: <code>WAT100: The following roles 'Tests.FakeRole' have an instance count of 0.  Instance count of 0 is not supported in deployments to Microsoft Azure</code>. Attempting to disable this validation <a href="https://connect.microsoft.com/VisualStudio/feedbackdetail/view/961868" rel="nofollow">results in a build error due to a defect in the Azure SDK</a>.</p>