modelsbuilder/ModelsBuilder.Original

Failing to build models with VS Ext 8.0.4

Closed this issue · 22 comments

Hi,

I have just tried to re-build my models ( first time in at least a week on this project ) and for some reason it is failing to create the models.

I currently have:

Umbraco Version: 7.14
The Visual Studio extension Version: 8.0.4
Umbraco.ModelsBuilder Version: 3.0.10
Umbraco.ModelsBuilder.API Version: 3.0.10

I wasn't sure if I should update the Umbraco.ModelsBuilder to the latest 8.0.x versions, I also tried this, but the error remained so I reverted them back.

I have updated my solution to .NET 4.7.2

The solution is set to use the latest version of C#

But after making both of the above changes, the error message remains the same, which is the following:

UmbracoModelsBuilder: Starting v8.0.4 3/20/2019 5:59:14 PM.
UmbracoModelsBuilder: UmbracoModelsBuilder failed to generate code: Exception: Response status code does not indicate success (InternalServerError)
{"Message":"An error has occurred.","ExceptionMessage":"Feature 'expression-bodied property' is not available in C# 5.  Please use language version 6 or greater.","ExceptionType":"Umbraco.ModelsBuilder.Building.CompilerException","StackTrace":"   at Umbraco.ModelsBuilder.Building.Compiler.ThrowExceptionFromDiagnostic(String path, String code, Diagnostic diagnostic) in D:\\d\\Zbu ModelsBuilder-7\\Umbraco.ModelsBuilder\\Building\\Compiler.cs:line 161\r\n   at Umbraco.ModelsBuilder.Building.Compiler.<>c__DisplayClass12_0.<GetCompilation>b__0(KeyValuePair`2 x) in D:\\d\\Zbu ModelsBuilder-7\\Umbraco.ModelsBuilder\\Building\\Compiler.cs:line 50\r\n   at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()\r\n   at System.Linq.Buffer`1..ctor(IEnumerable`1 source)\r\n   at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)\r\n   at Umbraco.ModelsBuilder.Building.Compiler.GetCompilation(String assemblyName, IDictionary`2 files, SyntaxTree[]& trees) in D:\\d\\Zbu ModelsBuilder-7\\Umbraco.ModelsBuilder\\Building\\Compiler.cs:line 46\r\n   at Umbraco.ModelsBuilder.Building.CodeParser.Parse(IDictionary`2 files, IEnumerable`1 references) in D:\\d\\Zbu ModelsBuilder-7\\Umbraco.ModelsBuilder\\Building\\CodeParser.cs:line 38\r\n   at Umbraco.ModelsBuilder.Api.ApiHelper.GetModels(String modelsNamespace, IDictionary`2 files) in D:\\d\\Zbu ModelsBuilder-7\\Umbraco.ModelsBuilder\\Api\\ApiHelper.cs:line 16\r\n   at Umbraco.ModelsBuilder.Api.ModelsBuilderApiController.GetModels(GetModelsData data) in D:\\d\\Zbu ModelsBuilder-7\\Umbraco.ModelsBuilder.Api\\ModelsBuilderApiController.cs:line 65\r\n   at lambda_method(Closure , Object , Object[] )\r\n   at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass10.<GetExecutor>b__9(Object instance, Object[] methodParameters)\r\n   at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.Execute(Object instance, Object[] arguments)\r\n   at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(HttpControllerContext controllerContext, IDictionary`2 arguments, CancellationToken cancellationToken)\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Controllers.ApiControllerActionInvoker.<InvokeActionAsyncCore>d__0.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__5.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__5.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Filters.ActionFilterAttribute.<ExecuteActionFilterAsyncCore>d__0.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Controllers.ActionFilterResult.<ExecuteAsync>d__2.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Filters.AuthorizationFilterAttribute.<ExecuteAuthorizationFilterAsyncCore>d__2.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__1.MoveNext()"}
UmbracoModelsBuilder:    at Umbraco.ModelsBuilder.Api.ApiClient.EnsureSuccess(HttpResponseMessage result)
   at Umbraco.ModelsBuilder.Api.ApiClient.GetModels(Dictionary`2 ourFiles, String modelsNamespace)
   at Umbraco.ModelsBuilder.CustomTool.CustomTool.UmbracoModelsBuilder.GenerateRaw(String wszInputFilePath, String wszDefaultNamespace, IntPtr[] rgbOutputFileContents, UInt32& pcbOutput, String& errMsg)

Currently I am unable to update my client's site which is somewhat critical, any help you can give me would be much appreciated. :)

Looking at the error, it's a c# version error by the looks of it. Have you tried the suggestion here:

https://our.umbraco.com/forum/templates-partial-views-and-macros/83962-modelsbuilder-not-working-with-c6-code#comment-266274

This tells Models Builder which version of c# to use :-)

Hi @NikRimington

I have tried that but it didn't make any difference unfortunately. In the docs you linked to, it does say this is for the [Live]dll. However I am using the API and the Visual Studio plugin to generate the models, so maybe it doesn't effect the code that is generated by the Visual Studio extension?

Umbraco.ModelsBuilder.LanguageVersion (string, default is CSharp5) indicates the C# language version which is used when compiling the models in [Live]Dll. Can be set to CSharp6 or Experimental to try the new C# features.

My gut feeling is this is not related to the issue I am having... but I could be wrong :)

Hmm, I'm sure it used to take that into account as I had to do that on a project a little while back.

Well, I just tried again and it has worked :)

I am not sure what is different compared to when I tried it earlier today as I've tried so many different things, but this time, it's worked!

Thanks @NikRimington

I think it would still be a good idea for the documentation to be more detailed as to the required setup / configuration of these sort of bits :)

Just another thought on this @zpqrtbnk originally I was just trying to generate the models as I have done for the last 12 months, I had not intended to update to the latest version of C# and only did so because of this error message. I.e. it looks like there may be an issue with generating the code without the C# 6 setting?

Just out of interest, did you install a new property editor? Also what version of Umbraco did you upgrade from (I'm assuming you upgraded recently)?

Hi @NikRimington

The last time I generated the models was on the 4th March, on the 15th March I used Umbraco Cloud to auto-upgrade from 7.13.2 to 7.14.0

Before trying to use the Model's builder Extension this afternoon I had added a new Dropdown data type with 5 items to an existing Document Type.

When this failed I tried upgrading my C# version support in the solution, moved the entire solution to .NET 4.7.2 and also tried removing the new Data type in case that had been the issue.

What I find strange is that it's now working with the C#6 setting. I don't understand why it should make a difference when generating the files. I can understand if it generated C#6 code while I was using C#5 that at the point of my building the solution things would fail, however I don't understand why it fails to build the models for a C#5 solution, I am sure not everyone is going to want / or know how to upgrade their solution.

Quick update (will reply w/ more details later)

  • On the server/site: v7 requires ModelsBuilder 3.x and does not support MB 8.x, v8 requires MB 8.x
  • On Visual Studio: the extension 3.x supports only v7 sites, whereas 8.x supports both v7 and v8

Meaning that, in your case, you should not change anything at site level, and you can update the Visual Studio extension to 8.x (in order to support both v7 and v8 sites) and it all should work.

Well, obviously - something went wrong in your case, going to look into it in more details.

Hi @zpqrtbnk

I've just updated Visual Studio to the latest patch release 15.9.11 which might be related ( but I don't think so )

Anyhow, I am unfortunately again getting an error trying to generate the models and I'm not sure the best way to debug what is wrong with Model's builder.

I am now getting the following error:

UmbracoModelsBuilder: Starting v8.0.4 4/8/2019 6:29:31 PM.
UmbracoModelsBuilder: UmbracoModelsBuilder failed to generate code: Exception: Response status code does not indicate success (InternalServerError)
{"Message":"An error has occurred.","ExceptionMessage":"{ or ; expected","ExceptionType":"Umbraco.ModelsBuilder.Building.CompilerException","StackTrace":"   at Umbraco.ModelsBuilder.Building.Compiler.ThrowExceptionFromDiagnostic(String path, String code, Diagnostic diagnostic) in D:\\d\\Zbu ModelsBuilder-7\\Umbraco.ModelsBuilder\\Building\\Compiler.cs:line 161\r\n   at Umbraco.ModelsBuilder.Building.Compiler.<>c__DisplayClass12_0.<GetCompilation>b__0(KeyValuePair`2 x) in D:\\d\\Zbu ModelsBuilder-7\\Umbraco.ModelsBuilder\\Building\\Compiler.cs:line 50\r\n   at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()\r\n   at System.Linq.Buffer`1..ctor(IEnumerable`1 source)\r\n   at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)\r\n   at Umbraco.ModelsBuilder.Building.Compiler.GetCompilation(String assemblyName, IDictionary`2 files, SyntaxTree[]& trees) in D:\\d\\Zbu ModelsBuilder-7\\Umbraco.ModelsBuilder\\Building\\Compiler.cs:line 46\r\n   at Umbraco.ModelsBuilder.Building.CodeParser.Parse(IDictionary`2 files, IEnumerable`1 references) in D:\\d\\Zbu ModelsBuilder-7\\Umbraco.ModelsBuilder\\Building\\CodeParser.cs:line 38\r\n   at Umbraco.ModelsBuilder.Api.ApiHelper.GetModels(String modelsNamespace, IDictionary`2 files) in D:\\d\\Zbu ModelsBuilder-7\\Umbraco.ModelsBuilder\\Api\\ApiHelper.cs:line 16\r\n   at Umbraco.ModelsBuilder.Api.ModelsBuilderApiController.GetModels(GetModelsData data) in D:\\d\\Zbu ModelsBuilder-7\\Umbraco.ModelsBuilder.Api\\ModelsBuilderApiController.cs:line 65\r\n   at lambda_method(Closure , Object , Object[] )\r\n   at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass10.<GetExecutor>b__9(Object instance, Object[] methodParameters)\r\n   at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.Execute(Object instance, Object[] arguments)\r\n   at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(HttpControllerContext controllerContext, IDictionary`2 arguments, CancellationToken cancellationToken)\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Controllers.ApiControllerActionInvoker.<InvokeActionAsyncCore>d__0.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__5.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__5.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Filters.ActionFilterAttribute.<ExecuteActionFilterAsyncCore>d__0.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Controllers.ActionFilterResult.<ExecuteAsync>d__2.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Filters.AuthorizationFilterAttribute.<ExecuteAuthorizationFilterAsyncCore>d__2.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__1.MoveNext()"}
UmbracoModelsBuilder:    at Umbraco.ModelsBuilder.Api.ApiClient.EnsureSuccess(HttpResponseMessage result)
   at Umbraco.ModelsBuilder.Api.ApiClient.GetModels(Dictionary`2 ourFiles, String modelsNamespace)
   at Umbraco.ModelsBuilder.CustomTool.CustomTool.UmbracoModelsBuilder.GenerateRaw(String wszInputFilePath, String wszDefaultNamespace, IntPtr[] rgbOutputFileContents, UInt32& pcbOutput, String& errMsg)

I couldn't find any further details in the log so I'm a bit unsure how to proceed?

Happy to try and help diagnose if this is a MB issue or if you think I've done something that might be breaking it, please do let me know.

Unfortunately haven't been able to dig into this - raising priority

@zpqrtbnk I could really do with a hand trying to debug this issue as currently I cannot continue with the development of my client's solution as I cannot create the new models ;(

If there is any chance we could maybe have a Skype call early next week to try and debug this remotely I'd be happy to help as it would probably be a win-win if we can fix an issue.

Can you share (email if you prefer) the content of your models directory before you trigger the generation, and get the error you reported above (with VS 15.9.11), along with the complete set of ModelsBuilder appSettings on the server?

No need to share files, the error you are seeing is because one of your file probably contains a line similar to:

  public string Something { get => _something; set => _something = value; }

Which is C#7 which you cannot support in 3.0.10 even with settings, because 3.0.10 relies on Roslyn 1.0 which did not support C#7 at all.

So... I have produced a 3.1.0 version which relies on Roslyn 2.10 which supports C# up to 7.3. All tests are OK, but I would need to test it on a real site. Also had to up the target framework from 4.5 to 4.6.2 because Roslyn 2.10 would not support 4.5.

Attached v3.1.0.zip Zip archive contains the two corresponding NuGet packages. Any chance you can try them and report? If all works, then I'll upload them to the official NuGet servers.

Hi Stephan,

I have tried your new version, but its now showing a different error, I have guessed your email is likely to be firstname at your company dot com... but if I am wrong and it's now a lost email, please let me know your email address :)

If you did receive my email you will see the full details, but in a nut shell it now complains with the following error:

Could not load file or assembly 'System.Collections.Immutable, Version=1.2.3.0

( I have version 1.5.0 installed which is the latest version )

Chris

P.s. the email just bounced back... so please do let me know your email address, you could send it to me via our contact us form: https://www.vizioz.com/contact-us/ if you don't want to post it on GitHub :)

Going to be stephane umbraco com.

Was afraid of this: it's not a big deal, but the new Roslyn has tons of updated dependencies which require binding redirects in web.config. Maybe if you're willing to share the current state of your binding redirects, I can tell you what to update?

Hi @zpqrtbnk

The current bindings are;

  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <!-- Old asp.net ajax assembly bindings -->
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Extensions" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="4.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Extensions.Design" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="4.0.0.0" />
      </dependentAssembly>
      <!-- Ensure correct version of MVC -->
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="0.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="0.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
      </dependentAssembly>
      <!-- Ensure correct version of HtmlAgilityPack -->
      <dependentAssembly>
        <assemblyIdentity name="HtmlAgilityPack" publicKeyToken="bd319b19eaf3b43a" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-1.4.9.5" newVersion="1.4.9.5" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="AutoMapper" publicKeyToken="be96cd2c38ef1005" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-3.3.1.0" newVersion="3.3.1.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.1.1.2" newVersion="4.1.1.2" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-10.0.0.0" newVersion="10.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-5.2.3.0" newVersion="5.2.3.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.WebPages.Razor" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="0.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Http" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-5.2.3.0" newVersion="5.2.3.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Owin" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-3.1.0.0" newVersion="3.1.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Owin.Security.OAuth" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-3.1.0.0" newVersion="3.1.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Owin.Security" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-3.1.0.0" newVersion="3.1.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Owin.Security.Cookies" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-3.1.0.0" newVersion="3.1.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Net.Http.Formatting" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-5.2.3.0" newVersion="5.2.3.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="log4net" publicKeyToken="669e0ddf0bb1aa2a" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-2.0.8.0" newVersion="2.0.8.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Data.SqlServerCe" publicKeyToken="89845DCD8080CC91" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.0.0.1" newVersion="4.0.0.1" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.ValueTuple" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>

I tried adding a binding for System.Collections.Immutable but it then said I needed a reference for NetStandard 2.0 so I have reverted this in case I did it wrong :)

I look forward to hearing from you,

Cheers, Chris

@zpqrtbnk

A quick update, I have added the following to the web.config file:

      <dependentAssembly>
        <assemblyIdentity name="System.Collections.Immutable" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="1.2.3.0" newVersion="1.5.0" />
      </dependentAssembly>

And had to add:

<add assembly="netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51"/>

The web site runs fine, both frontend and back office, however model's builder continues to fail, if I remove the C#7 syntax and then try and run model's builder it works fine.

E.g. changing this:

set => name = value;

to:

set
{
    name = value;
}

The error I am now getting from model's builder is definitely related to C#7, see below:


UmbracoModelsBuilder: Starting v8.0.4 4/15/2019 10:38:35 AM.
UmbracoModelsBuilder: UmbracoModelsBuilder failed to generate code: Exception: Response status code does not indicate success (InternalServerError)
{"Message":"An error has occurred.","ExceptionMessage":"Feature 'expression body property accessor' is not available in C# 6. Please use language version 7.0 or greater. (at C:\\Development\\Client Projects\\Segal Group\\SWCTF\\SegalGroup.Swctf.Core\\Models\\CourseScheduleEntityNode.cs:line 50).","ExceptionType":"Umbraco.ModelsBuilder.Building.CompilerException","StackTrace":"   at Umbraco.ModelsBuilder.Building.Compiler.ThrowExceptionFromDiagnostic(String path, String code, Diagnostic diagnostic) in D:\\d\\Zbu ModelsBuilder-7\\Umbraco.ModelsBuilder\\Building\\Compiler.cs:line 161\r\n   at Umbraco.ModelsBuilder.Building.Compiler.<>c__DisplayClass12_0.<GetCompilation>b__0(KeyValuePair`2 x) in D:\\d\\Zbu ModelsBuilder-7\\Umbraco.ModelsBuilder\\Building\\Compiler.cs:line 50\r\n   at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()\r\n   at System.Linq.Buffer`1..ctor(IEnumerable`1 source)\r\n   at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)\r\n   at Umbraco.ModelsBuilder.Building.Compiler.GetCompilation(String assemblyName, IDictionary`2 files, SyntaxTree[]& trees) in D:\\d\\Zbu ModelsBuilder-7\\Umbraco.ModelsBuilder\\Building\\Compiler.cs:line 46\r\n   at Umbraco.ModelsBuilder.Building.CodeParser.Parse(IDictionary`2 files, IEnumerable`1 references) in D:\\d\\Zbu ModelsBuilder-7\\Umbraco.ModelsBuilder\\Building\\CodeParser.cs:line 38\r\n   at Umbraco.ModelsBuilder.Api.ApiHelper.GetModels(String modelsNamespace, IDictionary`2 files) in D:\\d\\Zbu ModelsBuilder-7\\Umbraco.ModelsBuilder\\Api\\ApiHelper.cs:line 16\r\n   at Umbraco.ModelsBuilder.Api.ModelsBuilderApiController.GetModels(GetModelsData data) in D:\\d\\Zbu ModelsBuilder-7\\Umbraco.ModelsBuilder.Api\\ModelsBuilderApiController.cs:line 65\r\n   at lambda_method(Closure , Object , Object[] )\r\n   at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass10.<GetExecutor>b__9(Object instance, Object[] methodParameters)\r\n   at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.Execute(Object instance, Object[] arguments)\r\n   at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(HttpControllerContext controllerContext, IDictionary`2 arguments, CancellationToken cancellationToken)\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Controllers.ApiControllerActionInvoker.<InvokeActionAsyncCore>d__0.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__5.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__5.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Filters.ActionFilterAttribute.<ExecuteActionFilterAsyncCore>d__0.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Controllers.ActionFilterResult.<ExecuteAsync>d__2.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Filters.AuthorizationFilterAttribute.<ExecuteAuthorizationFilterAsyncCore>d__2.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__1.MoveNext()"}
UmbracoModelsBuilder:    at Umbraco.ModelsBuilder.Api.ApiClient.EnsureSuccess(HttpResponseMessage result)
   at Umbraco.ModelsBuilder.Api.ApiClient.GetModels(Dictionary`2 ourFiles, String modelsNamespace)
   at Umbraco.ModelsBuilder.CustomTool.CustomTool.UmbracoModelsBuilder.GenerateRaw(String wszInputFilePath, String wszDefaultNamespace, IntPtr[] rgbOutputFileContents, UInt32& pcbOutput, String& errMsg)

Ahh... just spotted:

<add key="Umbraco.ModelsBuilder.LanguageVersion" value="CSharp6" />

Which I have updated to:

<add key="Umbraco.ModelsBuilder.LanguageVersion" value="CSharp7" />

And now everything seems happy :)

Albeit there seem to be a LOT of exceptions showing in the debug output window, quite a few of which I have not see before. The site still seems to be running fine, but it can't be good to have all these exceptions, I'll try and take a deeper look into them once I've finished the current feature release for my client.

Thanks again for your help @zpqrtbnk

If you need me to test any other versions of Models Builder, just let me know.

Cheers, Chris

Note: you probably can remove the LanguageVersion appSetting entirely, as MB 3.1 is C# 7.3 by default.

So, what we have so far: version 3.1 of MB (with latest Roslyn 2.10) supports C# 7.3 and works, provided that some binding redirects are updated. I am going to experiment to find out the list of exact redirects that are needed.

Still, some exceptions in the Debug window: can you give me more details about these?

@zpqrtbnk these exceptions are not showing when I run Model's builder, so I think they are probably more related to the core than to MB, I will drop you an email with the details.

Have released version 3.1.0 here on GitHub, and will not release it on NuGet - don't want people to automatically upgrade. Bit too dangerous. So, closing this issue (as for the other problems, we can discuss via email).