简体   繁体   English

C#错误CS1056:Jenkins或MSbuild出现意外字符'$'

[英]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.

相关问题 C# CodeDomCompiler。 错误 CS1056:意外字符“$” - C# CodeDomCompiler. error CS1056: Unexpected character '$' 错误 CS1056:在 tfs 持续集成过程中运行 msbuild 时出现意外字符“$” - Error CS1056: Unexpected character '$' running the msbuild on a tfs continuous integration process C#类错误CS1061 CS1056 - C# class error CS1061 CS1056 错误CS1056:意外字符'$'Xamarin Studio - Error CS1056: Unexpected character '$' Xamarin Studio 为什么我在此代码上得到一个 CS1056 - Unexpected character '' - Why do I get an CS1056 - Unexpected character '' on this code 为什么我会收到“错误 CS1056:意外字符 '$'”并在此处放置 $ 标记? 我的编译器有问题吗? - Why am I getting "error CS1056: Unexpected character '$'" putting a $ mark here? A problem with my compiler? 为什么我在此代码中得到 CS1056 意外字符 '' - Why do I get an CS1056 Unexpected character '' on this code 如何调试错误“意外的字符CS1056”? - How to debug the error “unexpected char CS1056”? 使用Jenkins和Sonarqube分析c#项目-调用MSBuild.SonarQube.Runner.exe结束时出错 - Analysis c# Project with Jenkins and Sonarqube - Error calling MSBuild.SonarQube.Runner.exe end 如何修复 C# 错误 CS1525:意外符号“if”“sol”和“else”? [等候接听] - How to fix C# error CS1525: Unexpected Symbol 'if' 'sol' and 'else'? [on hold]
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM