简体   繁体   中英

How do I configure CruiseControl's C# version for XSLT code snippets?

I am trying to set up a CruiseControl.NET instance that displays some of its build results with custom XSLT that includes C# snippets.

This used to work on another instance (whose configuration is not available to me anymore - I just have the original XSLT files), but the current instance complains about certain "more recent" C# keywords such as var .

This makes me think that the XSLT processor used by CC.NET is currently using an old C# compiler. Unfortunately, I cannot find any hints or documentation on how to modify that behaviour.

Is there any option in CC.NET to determine which C# language version/compiler is used by the XSLT processor?

I don't know anything about CruiseControl but in pure .NET I think you need to add the NuGet package https://www.nuget.org/packages/Microsoft.CodeDom.Providers.DotNetCompilerPlatform/3.6.0 and then in your App.config you need to declare the CodeDom section to use the particular C# language version

<system.codedom>
    <compilers>
  <compiler extension=".cs" language="c#;cs;csharp" warningLevel="4" compilerOptions="/langversion:7.3 /nowarn:1659;1699;1701;612;618" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=3.6.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />

to get XslCompiledTransform use the newer C# compiler/CodeDom.

There was one catch getting that to work described in https://stackoverflow.com/a/63293441/252228 , namely to "move the \\roslyn subdirectory to \\bin\\roslyn" as the compiler is looked for in bin\\roslyn while it is installed in roslyn.

In the end, it turned out to be a matter of:

  • targetting CC.NET to a recent .NET version
  • configuring the AppPool in IIS to use .NET 4 and
  • making the target version explicit in the Web.config file of the CC.NET web dashboard by writing something like <compilation defaultLanguage="c#" targetFramework="4.7.2"/>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM