【发布时间】:2017-03-28 09:08:11
【问题描述】:
我需要使用 Jenkins 继续集成,在我的代码中我编写了类似
的代码throw new ArgumentNullException($"The {nameof(Id)} cannot be null");
如果我构建应用程序,它会成功构建,但如果我使用 MsBuild(or) Jenkins 构建相同的应用程序,
我收到类似
的错误Web\WebSharedHelper.cs "C:\WINDOWS\TEMP\.NETFramework,Version=v4.5.2.AssemblyAttributes.cs"
Security\ApiUserToken.cs(46,32): error CS1056: Unexpected character '$' [C:\Program Files (x86)\Jenkins\workspace\OssiaCICD\common\trunk\Cota.Common.Core\Cota.Common.Core.csproj]
Security\ApiUserToken.cs(58,32): error CS1056: Unexpected character '$' [C:\Program Files (x86)\Jenkins\workspace\OssiaCICD\common\trunk\Cota.Common.Core\Cota.Common.Core.csproj]
Security\ApiUserToken.cs(62,26): error CS1056: Unexpected character '$' [C:\Program Files (x86)\Jenkins\workspace\OssiaCICD\common\trunk\Cota.Common.Core\Cota.Common.Core.csproj]
Done Building Project "C:\Program Files (x86)\Jenkins\workspace\OssiaCICD\common\trunk\Cota.Common.Core\Cota.Common.Core.csproj" (default targets) -- FAILED.
我正在为 MSBuild 使用 v4.0.30319 FrameWork。
【问题讨论】:
-
编译成功,编译成功,编译报错?您能否指定这两个版本之间的区别?我猜用于第二次构建的编译器不知道 C#6(字符串插值)?
-
请注意,要使用字符串插值,您必须使用 C#6 及更高版本
-
我正在从它成功构建的视觉工作室构建。但是如果我使用 MSBuild 从命令提示符构建我会收到错误消息。我只知道版本的问题,但为什么以及如何解决该问题。
-
我已经浏览了这个链接,但这是完全不同的问题,因此我要求保持原样。