[英]c# error CS1056: Unexpected character '$' with Jenkins or MSbuild
I have a requirement to work with Jenkins for Continues integration, in my code I have written code like 我需要与Jenkins进行持续集成,在我的代码中我编写了如下代码
throw new ArgumentNullException($"The {nameof(Id)} cannot be null");
If I build the application it is building successfully but if I build this same application using MsBuild(or) Jenkins, 如果我构建该应用程序,则该应用程序将成功构建,但是如果我使用MsBuild(或)Jenkins构建该应用程序,
I am getting error like 我收到类似的错误
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.
I am using v4.0.30319 FrameWork for MSBuild. 我将MSBuild使用v4.0.30319 FrameWork。
我通过在jenkins上使用C:\\Program Files (x86)\\MSBuild\\14.0\\Bin\\MSBuild.exe
而不是C:\\Windows\\Microsoft.NET\\Framework64\\v4.0.30319\\MSBuild.exe
解决了该问题。
The $
string interpolation symbol is only available in C# 6+. $
字符串插值符号仅在C#6+中可用。 Make sure that you are compiling with C#6. 确保使用C#6进行编译。 C#6 is supported in MSBuild 14.0+. MSBuild 14.0+支持C#6。
If your Visual Studio version is older than 2015 then by default the IDE does not provide C#6 which you need to compile it. 如果您的Visual Studio版本早于2015,则默认情况下,IDE不提供您需要对其进行编译的C#6。
Use Visual Studio 2015 or newer. 使用Visual Studio 2015或更高版本。 It should resolve problem. 它应该解决问题。
This problem can be resolved in a couple of ways. 此问题可以通过两种方法解决。 Please check my answer here for the first option: 请在这里查看我的答案以获取第一种选择:
1st https://stackoverflow.com/a/42931980/819153 第一个https://stackoverflow.com/a/42931980/819153
2nd option - Try to install the visual studio on the tfs where you run the continuous integration, that will save you a lot of headaches 第二个选择-尝试在运行持续集成的tfs上安装Visual Studio,这样可以省去很多麻烦
As suggested by a gentleman here, I used C:\\Program Files (x86)\\MSBuild\\14.0\\Bin\\MSBuild.exe instead of C:\\Windows\\Microsoft.NET\\Framework64\\v4.0.30319\\MSBuild.exe over the build agent. 如一位先生的建议,我在构建过程中使用了C:\\ Program Files(x86)\\ MSBuild \\ 14.0 \\ Bin \\ MSBuild.exe而不是C:\\ Windows \\ Microsoft.NET \\ Framework64 \\ v4.0.30319 \\ MSBuild.exe代理商。 And it helped me. 它帮助了我。
I have MSBuild Version 14.0.25420.1 in the build agent. 我在生成代理中拥有MSBuild版本14.0.25420.1。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.