小编Dáv*_*zky的帖子

MSBuild v14在极少数情况下编译语义错误的程序集

在构建环境更新后,我们的一个Smoke Tests在TeamCity中爆发.调查结果显示,来自相同的源代码,

  • C:\ Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe生成正确的二进制文件
  • C:\ Program Files(x86)\ MSBuild\14.0\bin\MSBuild.exe生成错误的二进制文件

什么时候发生

  • "params object []"被使用
  • 只传递一个值,而不是显式地包装在数组中
  • 使用命名参数
  • 与方法签名中的顺序不同

用于重现它的示例代码

static void Main(string[] args)
{
    var customerId = Guid.NewGuid();

    // Produces buggy code when compiled with MSBuild v14
    TestMethodWithParams(args: customerId, whatever: "foo");

    //All the calls below result correct behavior, regardless of the version of MSBuild, order and naming of parameters
    TestMethodWithParams("foo", customerId);
    TestMethodWithParams(whatever: "foo", args: customerId);

    TestMethodWithParams(args: new object[] { customerId }, whatever: "foo");
    TestMethodWithParams("foo", new object[] { customerId });
    TestMethodWithParams(whatever: "foo", args: new …
Run Code Online (Sandbox Code Playgroud)

c# msbuild binary compilation roslyn

10
推荐指数
1
解决办法
127
查看次数

标签 统计

binary ×1

c# ×1

compilation ×1

msbuild ×1

roslyn ×1