带有发布目标和运行单元测试的TF构建定义 [英] TF Build definition with Publish target and running unit tests

查看:101
本文介绍了带有发布目标和运行单元测试的TF构建定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用TF Build创建了一个构建定义.这是我们项目的每晚构建.它应运行已定义的单元测试,并应打包Azure Cloud Service项目.

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.

基于以下指南,我添加了Cloud Services的包装:

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.

问题在于,当使用发布目标构建解决方案时,不会构建单元测试项目. MSBuild将返回以下消息:Skipping unpublishable project.我将其追溯到常见的MSBuild目标文件.仅当发布是项目导致执行exe时,才会构建项目,如此处所示:

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

我尝试过的事情:

  • 在发布版本中强制构建单元测试项目. 我已将以下msbuild添加到单元测试csproj文件中,以覆盖发布时的默认目标:
  • 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>

  • 将单元测试项目的输出类型设置为控制台应用程序
  • 在两种情况下,MSBuild都会为单元测试项目引用的所有项目提供The specified project reference metadata for the reference "..\..csproj" is missing or has an invalid value: Project.

    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.

    我觉得自己走的路不正确.有没有办法既可以构建单元测试项目,又可以构建和发布Cloud Service项目?

    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?

    推荐答案

    好的,那比我要简单得多.

    Okee, it was much simpler then I though.

    MSBuild的/target参数可以采用依次构建的多个目标.我将构建定义更改为将/target:Build;Publish作为msbuild参数.这样就解决了这个问题.

    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.

    这篇关于带有发布目标和运行单元测试的TF构建定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆