简体   繁体   English

旧的ASP.NET 4应用程序的生成服务器无法生成新的C#7,但是在开发中可以正常工作

[英]Build server of an old ASP.NET 4 application fails building new C# 7, but it works in development

I recently start to work on a legacy ASP.NET codebase based on .NET framework 4.0 . 我最近开始研究基于.NET Framework 4.0的旧式ASP.NET代码库。 We managed to pass everything from Visual Studio 2012 to VS 2017 , updated the build server with a new version of Jenkins and installing .NET framework 4.7.x. 我们设法将所有内容从Visual Studio 2012传递到VS 2017 ,并使用新版本的Jenkins更新了构建服务器,并安装了.NET Framework4.7.x。

Locally we can write C# code of the newest version (7.3) and the build works (VS doesn't use MSBuild if I remember right), but when we deploy on the build server the build fails because there MSBuild cannot recognize constructs newer than C# 4.0 . 在本地,我们可以编写最新版本(7.3)的C#代码,并且构建可以正常工作(如果我没记错的话,VS不使用MSBuild),但是当我们在构建服务器上进行部署时,构建会失败,因为MSBuild无法识别比C#更新的构造4.0 To avoid mistakes I fixed the lang version to 4.0 (advanced build properties on projects), so if I write too new C# VS blocks me in dev, but we would like to start using new C#. 为了避免错误,我将lang版本固定为4.0(项目的高级构建属性),因此,如果我编写的C#太新了,VS就会在dev中阻止我,但我们想开始使用新的C#。

We also tried to fix C# 7.3 directly in the project ( <LangVersion>7.3</LangVersion> in PropertyGroup inside csproj) and the but ToolsVersion property of Project element (csproj) to 14.0, but then building we MSBuild fails with the error: 我们还尝试直接在项目中( <LangVersion>7.3</LangVersion>内PropertyGroup中的<LangVersion>7.3</LangVersion>中直接修复C#7.3,并将Project元素(csproj)的but ToolsVersion属性修复为14.0,但随后构建MSBuild失败,并显示以下错误:

CS1617: Invalid option '6' for /langversion; CS1617:/ langversion的选项“ 6”无效; must be ISO-1, ISO-2, 3, 4, 5 or Default 必须为ISO-1,ISO-2、3、4、5或默认值

Here it's explained that what I want to do it is possible: https://www.dotnetcurry.com/dotnet/1427/build-apps-different-dotnet-framework-versions 在这里说明了我想做的事情是可能的: https : //www.dotnetcurry.com/dotnet/1427/build-apps-different-dotnet-framework-versions

No matter which .NET framework version we target in the project, the C# language version in use will not change. 无论我们在项目中定位的是哪个.NET Framework版本,使用的C#语言版本都不会更改。 That's fine because the vast majority of language features that were introduced in later versions of the language don't depend on the CLR or specific APIs. 很好,因为在更高版本的语言中引入的绝大多数语言功能均不依赖CLR或特定的API。 They are only syntactic sugar and the bytecode generated by the compiler will still work in .NET framework 2.0. 它们只是语法糖,并且编译器生成的字节码仍将在.NET Framework 2.0中运行。

Anyone have an idea of what mistake are we doing? 任何人都知道我们在犯什么错误?

The problem was that on the build server MSBuild wasn't properly installed and build scripts got an old one. 问题是在构建服务器上未正确安装MSBuild,并且构建脚本使用了旧的脚本。 Installing Visual Studio 2017 Build tools and fixing the path on the script we solved. 安装Visual Studio 2017构建工具并修复我们解决的脚本上的路径。

After we had the problem "The “GetReferenceNearestTargetFrameworkTask” task was not found" we solved like explained here: The "GetReferenceNearestTargetFrameworkTask" task was not found (the right answer depends on what strategy have you used to install VS Buld tools). 在遇到“找不到“ GetReferenceNearestTargetFrameworkTask”任务”问题后,我们按以下说明进行了解决: 找不到“ GetReferenceNearestTargetFrameworkTask”任务 (正确的答案取决于您使用哪种策略安装VS Buld工具)。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 asp.net C#Web窗体应用程序中的密码恢复在localhost上有效,但在Godaddy服务器上不起作用 - Password recovery in asp.net c# web forms application works on localhost but not on Godaddy server 用于IIS的C#ASP.net应用程序的Team Foundation Server构建过程 - Team foundation server build process for a C# ASP.net application to IIS Visual Studio 2010-应用程序无法通过asp.NET开发服务器启动,但可以在生产服务器上运行 - Visual Studio 2010 - Application not starting up through asp.NET Development Server but works on the Production Server 在电子邮件中发送忘记的用户密码在本地机器上成功运行,但在使用 c# asp.net 的服务器上失败 - Sending forgot password of user in an email works successfully in local machine but fails on server using c# asp.net 它是否支持asp.net(C#)中多个服务器中的应用程序缓存? - Is it support Application cache in multiple server in asp.net(C#)? 如何使用C#以编程方式运行ASP.Net开发服务器? - How can I programmatically run the ASP.Net Development Server using C#? 来自Asp.net应用程序的SSL握手失败-在浏览器中有效 - SSL Handshake fails from asp.net application - works in browser 链接到asp.net c#应用程序时C ++ dll无法写入文件 - C++ dll fails to write to file when linked to asp.net c# application 使用c#使用Microsoft.Build.Engine构建和发布(ASP.NET Web应用程序) - Build and Publish (ASP.NET Web Application) using Microsoft.Build.Engine using c# ASP.net C#新行 - ASP.net C# New line
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM