错误CS1056:在tfs连续集成过程中运行msbuild的意外字符'$' [英] Error CS1056: Unexpected character '$' running the msbuild on a tfs continuous integration process

查看:382
本文介绍了错误CS1056:在tfs连续集成过程中运行msbuild的意外字符'$'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个项目,该框架的目标是 .NET Framework 4.6.1 ,作为tfs持续集成过程的一部分,我们创建了一个Build Solution任务来确保

现在TFS服务器具有 .Net Famework 4.6.2 的最新版本。在寄存器上,这是框架的Release键的值

I have a project that the framework is targeting .NET Framework 4.6.1, as part of the continuous integration process on the tfs we created a Build Solution task to ensure that the code compiles correctly.
Now the TFS server has the latest version of the .Net Famework 4.6.2. On the register this is the value for the Release key of the framework


在所有其他OS版本上:394806 => .NET Framework 4.6。 2

On all other OS versions: 394806 => .NET Framework 4.6.2

但是在构建运行时会出现以下错误:

But when the build runs it comes with this error:

Error CS1056: Unexpected character '$'

我没有想要用 string.Format 替换字符串插值来解决此问题,请提供另一种解决方法。

I don't want to replace the string interpolation with the string.Format to solve this issue, please provide another workaround to solve it.

我需要在TFS服务器上安装其他东西吗?

Do I need to install something else on the TFS server?

推荐答案

可以通过安装Nuget包$ b来解决问题。 $ b Microsoft.Net.Compilers。以下是我突出显示的答案的链接:项目可以在Visual Studio中正常运行,但在命令行中失败

The problem can be fixed installing a Nuget package Microsoft.Net.Compilers. Below is the link of my highlighted answer: Project builds fine with Visual Studio but fails from the command line


该功能是C#6,尝试安装最新的
版本的框架4.6.2
https://www.microsoft.com/zh-cn/download/details.aspx?id=53345

然后转到您的Project属性,并在Target框架上的Application
选项上进行更改以指向最新的。您无需
更改代码即可将字符串插值替换为
string.Format方法来修复它。如果仍然出现此错误,则
是因为运行您的生成的编译器不是最新的C#
版本,请尝试从Nuget和$ b $添加Microsoft.Net.Compilers。 b再次编译,即应解决该问题。如果要避免
安装此软件包,请尝试打开.csproj并查看
ToolsVersion。应该指向版本12,然后将
更改为14 ,但请确保已从
https://www.microsoft.com/zh-cn/download/details.aspx?id=48159 或将
转到C:\Program Files(x86) \MSBuild\14.0\Bin,那里应该是带有csc.exe编译器的
文件夹。如果即使这样仍不能解决
的问题,请尝试执行以下步骤
https://msdn.microsoft.com/en-us/library/bb383985.aspx

Then go to your Project properties and change on the Application option on Target framework to point to the latest. You don't need to change your code to replace the string interpolation with string.Format method to fix it. If you are still getting this error, is because, the compiler that is running your build is not the latest version of C#, try to add the Microsoft.Net.Compilers, from Nuget and compile again, that should resolve the issue. If you want to avoid to install this package, try to open your .csproj and take a look on the ToolsVersion.that should be pointing to the version 12, then change it to 14, but make sure you have installed the latest version of the MSBuild from https://www.microsoft.com/en-us/download/details.aspx?id=48159 or go to C:\Program Files (x86)\MSBuild\14.0\Bin, there you should have this folder with the csc.exe compiler. If even then that doesn't resolve the issue, then try to follow this steps https://msdn.microsoft.com/en-us/library/bb383985.aspx.

根据我的经验,我通过3种不同的方式解决了这个问题:

In my experience I solved this problem in 3 different ways:

1-仅从Nuget处获取包裹

1- just getting the package from Nuget

2-在tfs服务器上安装Microsoft Build Tools 2015

2- installing Microsoft Build Tools 2015 on the tfs server

3-大锤和最后一个选择,但对我来说是最好的,因为您不需要处理对nuget的依赖关系是在运行该过程的tfs服务器上安装Visual Studio版本。

3- The sledgehammer and last options but for me the best because you don't need to deal with the dependency on nuget, is installing the visual studio version on the tfs server where you run the process.

希望这会有所帮助

这篇关于错误CS1056:在tfs连续集成过程中运行msbuild的意外字符'$'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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