neděle 7. března 2021

Odkazy z prohlížeče - 7.3.2021

 CodeProject

Hack-a-Day

HW, robotika

Ostatní


Upgrade website (ASP.Net) from .NET 4 to 4.6

Inspired by the discussion on

https://stackoverflow.com/questions/31548699/how-to-use-c-sharp-6-with-web-site-project-type

But cannot be directly applied to VS2019 and project created with Solution - Add / Existing Website

My solution

(web) Project - Property Pages - Tab "Build"

Change Target Framework to ".NET Framework 4.6"


VS makes changes in Web.config

  <system.web>
    <compilation debug="true" targetFramework="4.6"/>
    <pages controlRenderingCompatibilityVersion="4.0"/>
  </system.web>

But interpolated strings etc. still do not work ...

A new menu item appears - Build - ASP:NET Compilation -> Enable ...features ...


Now select, which project will be upgraded, and VS automatically added:

  • Nuget package
  • New folder Bin/Microsoft.CodeDom.Providers.DotNetCompilerPlatform
  • New lines in Web.config:

<system.codedom>
  <compilers>
    <compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom. ...
    <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" ...
  </compilers>
</system.codedom>

... now it finally works