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

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

问题描述

我有一个项目,该框架面向 .NET Framework 4.6.1,作为 tfs 持续集成过程的一部分,我们创建了一个构建解决方案任务,以确保代码正确编译.
现在 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

在所有其他操作系统版本上: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 包可以解决问题Microsoft.Net.编译器.以下是我突出显示的答案的链接:使用 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.2https://www.microsoft.com/en-us/download/details.aspx?id=53345

That feature is a syntactic sugar for C#6, try to install the latest version of the framework 4.6.2 https://www.microsoft.com/en-us/download/details.aspx?id=53345

然后转到您的项目属性并更改应用程序目标框架上的选项指向最新的.你不需要更改您的代码以替换字符串插值string.Format 方法来修复它.如果您仍然收到此错误,是因为,运行您的构建的编译器不是最新的C# 版本,尝试添加 Microsoft.Net.Compilers,来自 Nuget 和再次编译,应该可以解决问题.如果你想避免安装这个包,尝试打开你的 .csproj 并查看ToolsVersion.that 应该指向版本 12,然后更改它到 14,但请确保您已安装最新版本的MSBuild 来自https://www.microsoft.com/en-us/download/details.aspx?id=48159 或者去到 C:Program Files (x86)MSBuild14.0Bin,你应该有这个包含 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)MSBuild14.0Bin, 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天全站免登陆