在Visual Studio中生成的代码不会在TFS中生成 [英] Code that Builds in Visual Studio Won't Build in TFS

查看:101
本文介绍了在Visual Studio中生成的代码不会在TFS中生成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在C#类中定义了两种扩展方法.当我在Visual Studio 2015中编译使用这些扩展方法的代码时,它们将正确编译.当我在内部Team Foundation Build Server上运行相同的代码时,将MSBuild 2015与/p:VisualStudioVersion=14.0一起使用,该代码将无法编译.我需要采取什么其他步骤来配置构建服务器,以使代码得以编译?

I have two extension methods defined in a C# class. When I compile code that uses these extension methods in Visual Studio 2015, they compile correctly. When I run the same code on an on-premises Team Foundation Build Server, using MSBuild 2015 with /p:VisualStudioVersion=14.0, the code will not compile. What additional steps to do I need to take to configure the build server so that the code will compile?

这些是相关的方法签名

    public static IEnumerable<TResult> LeftOuterJoin<TOuter, TInner, TKey, TResult>(this IEnumerable<TOuter> outer, IEnumerable<TInner> inner, Func<TOuter, TKey> outerKeySelector, Func<TInner, TKey> innerKeySelector, Func<TOuter, TInner, TResult> resultSelector) where TInner : class;
    public static IEnumerable<TResult> LeftOuterJoin<TOuter, TInner, TKey, TResult>(this IEnumerable<TOuter> outer, IEnumerable<TInner> inner, Func<TOuter, TKey> outerKeySelector, Func<TInner, TKey> innerKeySelector, Func<TOuter, TInner, TResult> resultSelector) where TInner : class

这是构建服务器上的编译错误:

This is the compile error on the build server:

我在C#类中定义了两种扩展方法.当我在Visual Studio 2015中编译使用这些扩展方法的代码时,它们将正确编译.当我在内部Team Foundation Build Server上运行相同的代码时,将MSBuild 2015与/p:VisualStudioVersion=14.0一起使用,该代码将无法编译.我需要采取什么其他步骤来配置构建服务器,以使代码得以编译?

I have two extension methods defined in a C# class. When I compile code that uses these extension methods in Visual Studio 2015, they compile correctly. When I run the same code on an on-premises Team Foundation Build Server, using MSBuild 2015 with /p:VisualStudioVersion=14.0, the code will not compile. What additional steps to do I need to take to configure the build server so that the code will compile?

这些是相关的方法签名

public static IEnumerable<TResult> LeftOuterJoin<TOuter, TInner, TKey, TResult>(this IEnumerable<TOuter> outer, IEnumerable<TInner> inner, Func<TOuter, TKey> outerKeySelector, Func<TInner, TKey> innerKeySelector, Func<TOuter, TInner, TResult> resultSelector)
    where TInner : class;
public static IEnumerable<TResult> LeftOuterJoin<TOuter, TInner, TKey, TResult>(this IEnumerable<TOuter> outer, IEnumerable<TInner> inner, Func<TOuter, TKey> outerKeySelector, Func<TInner, TKey> innerKeySelector, Func<TOuter, TInner?, TResult> resultSelector)
    where TInner : struct;

基于构建服务器中的编译器错误,即使TInner是引用类型,构建过程似乎也接受该方法的"where TInner:struct"版本作为适当的重载,而Visual Studio在我的开发中机器不认为这些方法模棱两可.这是构建服务器上的编译错误:

Based on the compiler error in the build server, it appears that the build process is accepting the "where TInner : struct" version of the method as a suitable overload even though TInner is a reference type, whereas Visual Studio on my development machine does not consider these methods ambiguous. This is the compile error on the build server:

The call is ambiguous between the following methods or properties:
'Extensions.LeftOuterJoin<AnonymousType#1,ReferenceType,AnonymousType#2,AnonymousType#3>(System.Collections.Generic.IEnumerable<AnonymousType#1>, System.Collections.Generic.IEnumerable<ReferenceType>, System.Func<AnonymousType#1,AnonymousType#2>, System.Func<ReferenceType,AnonymousType#2>, System.Func<AnonymousType#1,ReferenceType,AnonymousType#3>)'
and
'Extensions.LeftOuterJoin<AnonymousType#1,ReferenceType,AnonymousType#2,AnonymousType#4>(System.Collections.Generic.IEnumerable<AnonymousType#1>, System.Collections.Generic.IEnumerable<ReferenceType>, System.Func<AnonymousType#1,AnonymousType#2>, System.Func<ReferenceType,AnonymousType#2>, System.Func<AnonymousType#1,ReferenceType?,AnonymousType#4>)'

推荐答案

如果使用的是TFS2015,则必须确保构建计算机上的构建环境与本地开发计算机相同.您应该在构建计算机上安装VS2015.

If you are using TFS2015, you must make sure the build environment on your build machine be the same as your local develop machine. You should install VS2015 on your build machine.

如果使用的是TFS2013或TFS2012,则此/p:VisualStudioVersion=14.0参数无效.您需要自定义tfs构建过程模板,以将Run MSBuild for Project的ToolPath设置为以MSBuild14为目标.并将ToolVersion设置为"14.0".选中此 BuildActivity会忽略ToolsVersion 的详细信息.

If you are using TFS2013 or TFS2012 , this /p:VisualStudioVersion=14.0 argument doesn't work. You need to customize the tfs build process template to set ToolPath of the Run MSBuild for Project to target to MSBuild14; and set ToolVersion to "14.0". Check this BuildActivity ignores ToolsVersion for deatils.

这篇关于在Visual Studio中生成的代码不会在TFS中生成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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