gpt4 book ai didi

c# - 错误 CS1056 : Unexpected character '$' running the msbuild on a tfs continuous integration process

转载 作者:IT王子 更新时间:2023-10-29 04:16:18 37 4
gpt4 key购买 nike

我有一个框架针对 .NET Framework 4.6.1 的项目,作为 tfs 持续集成过程的一部分,我们创建了一个构建解决方案任务以确保代码正确编译。
现在 TFS 服务器有最新版本的 .Net Famework 4.6.2。在寄存器中,这是框架的 Release 键的值

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

但是当构建运行时出现了这个错误:

Error CS1056: Unexpected character '$'

我不想用 string.Format 替换字符串插值来解决这个问题,请提供另一种解决方法来解决它。

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

最佳答案

这个问题可以通过安装 Nuget 包来解决Microsoft.Net.Compilers。以下是我突出显示的答案的链接:Project builds fine with Visual Studio but fails from the command line

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

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 种不同的方式解决了这个问题:

1- 刚刚从 Nuget 获取包

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

3- 大锤和最后一个选项但对我来说最好的,因为你不需要处理对 nuget 的依赖,正在运行进程的 tfs 服务器上安装 visual studio 版本。

希望对你有帮助

关于c# - 错误 CS1056 : Unexpected character '$' running the msbuild on a tfs continuous integration process,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42932577/

37 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com