0
votes

I've created a build definition using TF Build. It is the nightly build for our project. It should run the defined Unit Tests and it should package the Azure Cloud Service projects.

This build has been running for some time without the packaging step. This resulted in a successful build that also ran the Unit Tests.

Based on the following guide I have added the packaging of the Cloud Services: https://azure.microsoft.com/en-us/documentation/articles/cloud-services-dotnet-continuous-delivery/. Basically it comes down to setting the target to Publish for msbuild (/target:Publish) in the Build definition.

The problem is that when a solution is build with a Publish target the Unit test projects are not build. MSBuild will return with the following message: Skipping unpublishable project. I have traced this back to the common MSBuild target file. A project will only build when Publishing is the project results in an exe, as can be seen here: http://referencesource.microsoft.com/#MSBuildFiles/C/ProgramFiles(x86)/MSBuild/14.0/bin_/amd64/Microsoft.Common.CurrentVersion.targets,217

What I have tried:

  • Forcing building of Unit Test projects in Publish builds. I have added the following msbuild to the Unit Test csproj-files in order to override the default target on Publish:
    <PropertyGroup>
      <PublishDependsOn>
         Build;
      </PublishDependsOn>
    </PropertyGroup>
    
  • Setting the output type of the Unit Test project to Console Application

In both cased MSBuild will give the The specified project reference metadata for the reference "..\..csproj" is missing or has an invalid value: Project for all projects that are referenced by the unit test project.

I feel like I'm not on the right track. Is there a way I can both build the Unit Test projects and build and publish the Cloud Service projects?

2
TFS on-prem, right? not VSTS?Giulio Vian
Yes, on-premise TFS 2012Remy Blok
I was thinking that by modifying the Build template you can add a second MSBuild call with different parameters that does just the deployment. In VSTS/2015 this is much simpler to do.Giulio Vian
I see that as a last resort, because it is not very easy to do. I was thinking of adding an msbuild-task (msdn.microsoft.com/en-us/library/z7f65y0d.aspx). But I would hope that there is an easier/better solution.Remy Blok
You may try this: add the solution twice with different configurations, call the additional confg Publish and add the /target:Publish on this configuration (could be that this is easier done in the .csproj file).Giulio Vian

2 Answers

2
votes

Okee, it was much simpler then I though.

The /target-arguments of MSBuild can take multiple targets that are built in turn. I change my build definition to have /target:Build;Publish as msbuild params. This fixed the issue.

0
votes

I got an error (no entry point specified for cloud service) doing /t:Build;Publish with my service. So I did 2 separate actions, one with Build and one with Publish and that worked.