locked
VS2012: LSCodeGeneratorsTask - "The Language parameter must be a System.Management.CodeLanguage" RRS feed

  • Question

  • I get following error when I rebuild a newly created "LightSwitch HTML Application (Visual C#)":

    Error 1 The "LSCodeGeneratorsTask" task failed unexpectedly.
    Microsoft.LightSwitch.CodeGenerator.Implementation.CodeGeneratorException: The Language parameter must be a System.Management.CodeLanguage. ---> System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
       at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
       at Microsoft.LightSwitch.CodeGenerator.Implementation.ParameterizedGeneratorBase.ValidateParameters(IDictionary`2 parameters)
       --- End of inner exception stack trace ---
       at Microsoft.LightSwitch.CodeGenerator.Implementation.ParameterizedGeneratorBase.ValidateParameters(IDictionary`2 parameters)
       at Microsoft.LightSwitch.CodeGenerator.Implementation.CustomResultCodeGenerator.Microsoft.LightSwitch.CodeGenerator.ICodeGenerator.Generate(ProjectIdentifier pid, IDictionary`2 parameters)
       at Microsoft.LightSwitch.CodeEditing.Implementation.CodeGeneratorService.RunGeneratorsImmediately(TbdCodeGeneratorType generatorType, String LightSwitchProjectType, String lightSwitchProjectSubType, String projectDirectory, IDictionary`2 parameters, IList`1 generatedFiles, IList`1& issues)
       at Microsoft.LightSwitch.BuildTasks.CodeGen.LSGeneratorsTask.RunGeneratorsInNonIdeScenario()
       at Microsoft.LightSwitch.BuildTasks.CodeGen.LSGeneratorsTask.Execute()
       at Microsoft.LightSwitch.BuildTasks.CodeGen.LSCodeGeneratorsTask.Execute()
       at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
       at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__20.MoveNext() C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\LightSwitch\v3.0\Microsoft.LightSwitch.Build.Tasks.targets 253 5 LSApp.HTMLClient

    I did not do any editing in the newly created LS application and get this error.

    LightSwitch editors are working but I cannot compile and run the application.

    How do I fix this error?

    System: Win7 x64

    VisualStudio Info:

    Microsoft Visual Studio Professional 2012
    Version 11.0.60610.01 Update 3
    Microsoft .NET Framework
    Version 4.5.50709

    Installed Version: Professional

    LightSwitch for Visual Studio 2012  
    Microsoft LightSwitch for Visual Studio 2012

    Microsoft Office Developer Tools for Visual Studio 2012 ENU  
    Microsoft Office Developer Tools for Visual Studio 2012 ENU 2012

    Microsoft Visual Studio Tools for Applications 2012  
    Microsoft Visual Studio Tools for Applications 2012

    Team Explorer for Visual Studio 2012  
    Microsoft Team Explorer for Visual Studio 2012

    Visual Basic 2012  
    Microsoft Visual Basic 2012

    Visual C# 2012  
    Microsoft Visual C# 2012

    Visual C++ 2012  
    Microsoft Visual C++ 2012

    Visual F# 2012  
    Microsoft Visual F# 2012

    Visual Studio 2012 Code Analysis Spell Checker  
    Microsoft® Visual Studio® 2012 Code Analysis Spell Checker

    Portions of International CorrectSpell™ spelling correction system © 1993 by Lernout & Hauspie Speech Products N.V. All rights reserved.

    The American Heritage® Dictionary of the English Language, Third Edition Copyright © 1992 Houghton Mifflin Company. Electronic version licensed from Lernout & Hauspie Speech Products N.V. All rights reserved.

    AlignAssignments   1.0
    Command for aligning assignments.

    AutoBraceComplete   1.0
    auto brace complete

    CodeMaid   #114
    CodeMaid is an open source Visual Studio extension to cleanup, dig through and simplify our C#, C++, F#, VB, XAML, XML, ASP, HTML, CSS, JavaScript and TypeScript coding.

    Written by Steve Cadwallader, for more information visit http://www.codemaid.net/

    Common Azure Tools   1.0
    Provides common services for use by Azure Mobile Services and Windows Azure Tools.

    CustomDocWell   1.0
    Provides configurable behavior for the document well in Visual Studio 2012.

    Indent Guides   13
    Indent Guides

    Adds visual guides at each indentation level.

    NuGet Package Manager   2.7.40808.167
    NuGet Package Manager in Visual Studio. For more information about NuGet, visit http://docs.nuget.org/.

    OptionsPageImpl   1.0
    Information about my package

    PowerCommands for Visual Studio 2010   1.0
    A set of power commands for Visual Studio 2010

    PreEmptive Analytics Visualizer   1.0
    Microsoft Visual Studio extension to visualize aggregated summaries from the PreEmptive Analytics product.

    Quick Launch Tasks   1.0
    Microsoft Quick LaunchTasks package adds accessibility and settings tasks to the Quick Launch tool.

    SQL Server Data Tools   11.1.30914.0
    Microsoft SQL Server Data Tools

    Visual Studio 11 Editor Extension   1.0
    Information about my package

    Web Developer Tools   1.3.40412.0
    Microsoft Web Developer Tools contains the following components:
    Page Inspector: Tool that offers an efficient way to decompose Web Applications and diagnose front-end issues.
    Web Publishing: Extensions required for Web Publishing for both hosted servers as well as on premises.
    Web Form Templates: Includes the default templates for Web Form Applications.
    Editor Extensions: Includes HTML, CSS, and JS editor extensions that greatly enhance the development experience.

    Windows Azure Tools   2.1
    Windows Azure Tools for Microsoft Visual Studio 2012 - v2.1.10716.1601

    Workflow Manager Tools 1.0   1.0
    This package contains the necessary Visual Studio integration components for Workflow Manager.

    Saturday, September 28, 2013 8:42 AM

Answers

  • Hi

    I did some further testing and found the solution…

    I installed the new VS2013 Pro, created a new LightSwitch 4.0 C# HTML App and tried to build the project.

    Got the same error as with VS2012!!!!!!!! :(

    1>------ Rebuild All started: Project: LS_Test.Server, Configuration: Debug Any CPU ------
    2>------ Rebuild All started: Project: LS_Test.HTMLClient, Configuration: Debug Any CPU ------
    2>C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\LightSwitch\v4.0\Microsoft.LightSwitch.Build.Tasks.targets(263,5): error MSB4018: The "LSCodeGeneratorsTask" task failed unexpectedly.
    2>C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\LightSwitch\v4.0\Microsoft.LightSwitch.Build.Tasks.targets(263,5): error MSB4018: Microsoft.LightSwitch.CodeGenerator.Implementation.CodeGeneratorException: The Language parameter must be a System.Management.CodeLanguage. ---> System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.

    So this has to be something that is totally unrelated to VS or MSBuild installation issues.

    Then I took a look into the LightSwitch MSBuild task definition at: C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\LightSwitch\v4.0\Microsoft.LightSwitch.Build.Tasks.targets

    There is the LSCodeGeneratorsTask definition:

    <LSCodeGeneratorsTask Inputs="@(LightSwitchModel)"
                              ServiceModelFiles="@(ServiceMetadataFiles)"
                              IsRebuild="$(LSCodeGenFromRebuild)"
                              IsBuildingInsideVisualStudio="$(BuildingInsideVisualStudio)"
                              LightSwitchProjectType="$(LightSwitchProjectTypeV3)"
                              LightSwitchProjectSubType ="$(LightSwitchProjectSubType)"
                              ProjectPath="$(MSBuildProjectFullPath)"
                              Parameters="Language=$(Language)"
                              MetadataFiles="@(GeneratedMetadataFiles)"
                              ProjectOutputPath="$(OutDir)"
                              ProjectGuid="$(ProjectGuid)"
                              ExternalDataSources="@(ServerExternalDataSources)">

    The whole problem is caused by the parameter definition in line 270: “Parameters="Language=$(Language)"”

    This definition takes the WINDOWS ENVIROMENT variable “LANGUAGE” and passes it to the MSBuild task!!!!!

    On my system I have the windows environment variable “LANGUAGE” set to “EN”. This is set for an application I use - totally unrelated to VS, MSBuild or .Net.

    If I unset this environment variable the build finishes successful.

    Why have they chosen such a generic variable name to define the programming language to be used to compile the LightSwitch project??? Something like $(LSProgrammingLanguage) would be more appropriate...

    Regards

    • Marked as answer by awag Saturday, October 19, 2013 9:53 AM
    Saturday, October 19, 2013 9:53 AM

All replies

  • Hi awag

    According to your description above, I can hardly troubleshoot,

    Here are a few suggestions that might help:

    • Clean and Rebuild - Cleaning and rebuilding your current Project (Right-click > Clean, Right-click Rebuild respective) and see if that makes any difference at all. 

    I think you can give more explanation about your LightSwitch HTML Application (Visual C#), and we can give precise troubleshooting.

    Regards


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Tuesday, October 1, 2013 7:01 AM
  • Hi!

    Its my first test of a LS HTML app - no real application.

    I did the following steps:

    1) File/New/Project

    2) Select "LightSwitch HTML Application (Visual C#)"

    3) Click OK

    4) Hit F6

    This is the resulting build log:

    1>------ Build started: Project: Application1.HTMLClient, Configuration: Debug Any CPU ------
    1>C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\LightSwitch\v3.0\Microsoft.LightSwitch.Build.Tasks.targets(253,5): error MSB4018: The "LSCodeGeneratorsTask" task failed unexpectedly.
    1>C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\LightSwitch\v3.0\Microsoft.LightSwitch.Build.Tasks.targets(253,5): error MSB4018: Microsoft.LightSwitch.CodeGenerator.Implementation.CodeGeneratorException: The Language parameter must be a System.Management.CodeLanguage. ---> System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
    1>C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\LightSwitch\v3.0\Microsoft.LightSwitch.Build.Tasks.targets(253,5): error MSB4018:    at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
    1>C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\LightSwitch\v3.0\Microsoft.LightSwitch.Build.Tasks.targets(253,5): error MSB4018:    at Microsoft.LightSwitch.CodeGenerator.Implementation.ParameterizedGeneratorBase.ValidateParameters(IDictionary`2 parameters)
    1>C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\LightSwitch\v3.0\Microsoft.LightSwitch.Build.Tasks.targets(253,5): error MSB4018:    --- End of inner exception stack trace ---
    1>C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\LightSwitch\v3.0\Microsoft.LightSwitch.Build.Tasks.targets(253,5): error MSB4018:    at Microsoft.LightSwitch.CodeGenerator.Implementation.ParameterizedGeneratorBase.ValidateParameters(IDictionary`2 parameters)
    1>C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\LightSwitch\v3.0\Microsoft.LightSwitch.Build.Tasks.targets(253,5): error MSB4018:    at Microsoft.LightSwitch.CodeGenerator.Implementation.CustomResultCodeGenerator.Microsoft.LightSwitch.CodeGenerator.ICodeGenerator.Generate(ProjectIdentifier pid, IDictionary`2 parameters)
    1>C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\LightSwitch\v3.0\Microsoft.LightSwitch.Build.Tasks.targets(253,5): error MSB4018:    at Microsoft.LightSwitch.CodeEditing.Implementation.CodeGeneratorService.RunGeneratorsImmediately(TbdCodeGeneratorType generatorType, String LightSwitchProjectType, String lightSwitchProjectSubType, String projectDirectory, IDictionary`2 parameters, IList`1 generatedFiles, IList`1& issues)
    1>C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\LightSwitch\v3.0\Microsoft.LightSwitch.Build.Tasks.targets(253,5): error MSB4018:    at Microsoft.LightSwitch.BuildTasks.CodeGen.LSGeneratorsTask.RunGeneratorsInNonIdeScenario()
    1>C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\LightSwitch\v3.0\Microsoft.LightSwitch.Build.Tasks.targets(253,5): error MSB4018:    at Microsoft.LightSwitch.BuildTasks.CodeGen.LSGeneratorsTask.Execute()
    1>C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\LightSwitch\v3.0\Microsoft.LightSwitch.Build.Tasks.targets(253,5): error MSB4018:    at Microsoft.LightSwitch.BuildTasks.CodeGen.LSCodeGeneratorsTask.Execute()
    1>C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\LightSwitch\v3.0\Microsoft.LightSwitch.Build.Tasks.targets(253,5): error MSB4018:    at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
    1>C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\LightSwitch\v3.0\Microsoft.LightSwitch.Build.Tasks.targets(253,5): error MSB4018:    at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__20.MoveNext()
    2>------ Build started: Project: Application1.Server, Configuration: Debug Any CPU ------
    2>  Application1.Server -> c:\users\aw\documents\visual studio 2012\Projects\Application1\Application1\Application1.Server\bin\Debug\Application.Server.dll
    3>------ Build started: Project: Application1, Configuration: Debug Any CPU ------
    3>C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\LightSwitch\v3.0\Microsoft.LightSwitch.targets(108,5): error MSB3030: Could not copy the file "c:\users\aw\documents\visual studio 2012\Projects\Application1\Application1\Application1.HTMLClient\bin\Debug\Generated\generatedAssets.js" because it was not found.
    3>Done building project "Application1.ls3proj" -- FAILED.
    3>
    3>Build FAILED.
    ========== Build: 1 succeeded, 2 failed, 0 up-to-date, 0 skipped ==========

    Thanks for your hep!

    Regards

    Tuesday, October 1, 2013 7:22 AM
  • Today I tried to uninstall VS2010 an all VS2010 components.

    Then I did a repair installation of VS2012.

    Did not resolve the problem. I still get the same errors.

    Any help? thx.

    Saturday, October 5, 2013 7:08 PM
  • Hi awag

    I'm sorry, the HTML Client was introduced with LS 2012 (V2) for VS 2012. 

    Please take a look at this MSDN document: http://blogs.msdn.com/b/lightswitch/archive/2013/04/04/announcing-the-release-of-the-lightswitch-html-client.aspx

    Regards


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, October 7, 2013 9:58 AM
  • Hi

    I tried some other steps. Still no success... :(
    I did a "change install" of VS2012 and uninstalled the LightSwitch component. Then I searched and deleted some files and folders that may contain LightSwitch files:

    C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\LightSwitch\
    C:\Users\[UserName]\AppData\Local\Microsoft\MSBuild\VSLS\11.3\ManifestCache\LightSwitch.v3.0.MsBuild\
    C:\Users\[UserName]\AppData\Local\Microsoft\VisualStudio\11.3\ManifestCache\LightSwitch.v3.0\
    C:\Users\[UserName]\AppData\Local\Microsoft\VisualStudio\11.3\ManifestCache\LightSwitch.v3.0.Designer\
    C:\Users\[UserName]\AppData\Local\Microsoft\VisualStudio\11.3\ManifestCache\LightSwitch.v3.0.WebHost\

    Then I reinstalled the LightSwitch component again with a "change install" of VS2012

    Created a new LightSwitch project and got the same errors as above.

    Then I donloaded VS2012 Update 3, started VS2012.3.exe and did a repair installation of VS2012 Update 3.

    Again created a new LightSwitch project and got the same errors as above. :(

    If we take the exception "The Language parameter must be a System.Management.CodeLanguage" in the errors serious it would imply, that the MSBuild system is using a wrong(?) .Net runtime where some language is missing in System.Management.CodeLanguage.
    I have a fully patched Win7 system with all Windows and .Net Updates installed.

    I really don't know what to do next... :(

    Monday, October 7, 2013 1:15 PM
  • Hi awg

      I'm have a little confuse about this situation, according to the error message above, your Visual Studio 2012 isn't installed successfully. Generally we can fix this issue by repairing VS:

    To repair Visual Studio

    1. In Control Panel, on the Programs and Features page, choose the product edition that you want to repair, and then choose Uninstall/Change.

    2. In the Setup wizard, choose Repair, choose Next, and then follow the remaining instructions.

    To use HTML client, download the LightSwitch HTML Client, which is included in Visual Studio 2012 Update 3.

    If you still encounter this issue, it's recommended to uninstall VS and reinstall it again,

    To uninstall Visual Studio

    1. In Control Panel, on the Programs and Features page, choose the product edition that you want to uninstall, and then choose Change.

    2. In the Setup wizard, choose Uninstall, choose Yes, and then follow the remaining instructions in the wizard.

    hope it helps,

    Regards


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, October 11, 2013 2:09 AM
  • Hi Angie

    I did some further research...

    I installed VS2012 on an virtual Win8 machine and there my test project compiles fine.
    Then I did command line builds with logging enabled (msbuild.exe /filelogger) on both machines.
    The first difference I found was that on my development machine msbuild is using tools version 2.0!??!!?
    (3rd line in LogFile: Building with tools version "2.0".) I don't know why....
    So I did override the tools version with the /tv:4.0 command line parameter.
    With that parameter the logfiles are identical until line number 277:

    On my Win7 development machine those lines are (build fails):

    275: Using "LSCodeGeneratorsTask" task from assembly "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\LightSwitch\v3.0\Microsoft.LightSwitch.Build.Tasks.dll".
    276: Task "LSCodeGeneratorsTask"
    277:       Parameter: Name=Language, Value=EN
    278:   Generation complete
    279: C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\LightSwitch\v3.0\Microsoft.LightSwitch.Build.Tasks.targets(253,5): error MSB4018: The "LSCodeGeneratorsTask" task failed unexpectedly.\r [C:\Users\aw\Documents\Visual Studio 2012\Projects\LS_Test\LS_Test\LS_Test.HTMLClient\LS_Test.HTMLClient.jsproj]

    On my virtual Win8 machine (build is ok):

    275: Using "LSCodeGeneratorsTask" task from assembly "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\LightSwitch\v3.0\Microsoft.LightSwitch.Build.Tasks.dll".
    276: Task "LSCodeGeneratorsTask"
    277:   Generation complete
    279: Done executing task "LSCodeGeneratorsTask".

    So on the machine where the build fails the LSCodeGeneratorsTask receives a parameter: " Parameter: Name=Language, Value=EN" (line 277)
    This would also explain the exception that says: "The Language parameter must be a System.Management.CodeLanguage" because "EN" is no System.Management.CodeLanguage... ;)

    I really don't know why this parameter gets passed to the LSCodeGeneratorsTask on my Win7 machine. The solution I tried to compile is identical on both machines (I copied the source). I tried to repair the MSBuild (.Net 4.5) installation - still no success...

    I don't think that a simple uninstall/reinstall of VS2012 would fix the problem - and I don't have the time to completely reinstall my development machine... :(

    Regards

    Tuesday, October 15, 2013 3:43 PM
  • Hi

    I did some further testing and found the solution…

    I installed the new VS2013 Pro, created a new LightSwitch 4.0 C# HTML App and tried to build the project.

    Got the same error as with VS2012!!!!!!!! :(

    1>------ Rebuild All started: Project: LS_Test.Server, Configuration: Debug Any CPU ------
    2>------ Rebuild All started: Project: LS_Test.HTMLClient, Configuration: Debug Any CPU ------
    2>C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\LightSwitch\v4.0\Microsoft.LightSwitch.Build.Tasks.targets(263,5): error MSB4018: The "LSCodeGeneratorsTask" task failed unexpectedly.
    2>C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\LightSwitch\v4.0\Microsoft.LightSwitch.Build.Tasks.targets(263,5): error MSB4018: Microsoft.LightSwitch.CodeGenerator.Implementation.CodeGeneratorException: The Language parameter must be a System.Management.CodeLanguage. ---> System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.

    So this has to be something that is totally unrelated to VS or MSBuild installation issues.

    Then I took a look into the LightSwitch MSBuild task definition at: C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\LightSwitch\v4.0\Microsoft.LightSwitch.Build.Tasks.targets

    There is the LSCodeGeneratorsTask definition:

    <LSCodeGeneratorsTask Inputs="@(LightSwitchModel)"
                              ServiceModelFiles="@(ServiceMetadataFiles)"
                              IsRebuild="$(LSCodeGenFromRebuild)"
                              IsBuildingInsideVisualStudio="$(BuildingInsideVisualStudio)"
                              LightSwitchProjectType="$(LightSwitchProjectTypeV3)"
                              LightSwitchProjectSubType ="$(LightSwitchProjectSubType)"
                              ProjectPath="$(MSBuildProjectFullPath)"
                              Parameters="Language=$(Language)"
                              MetadataFiles="@(GeneratedMetadataFiles)"
                              ProjectOutputPath="$(OutDir)"
                              ProjectGuid="$(ProjectGuid)"
                              ExternalDataSources="@(ServerExternalDataSources)">

    The whole problem is caused by the parameter definition in line 270: “Parameters="Language=$(Language)"”

    This definition takes the WINDOWS ENVIROMENT variable “LANGUAGE” and passes it to the MSBuild task!!!!!

    On my system I have the windows environment variable “LANGUAGE” set to “EN”. This is set for an application I use - totally unrelated to VS, MSBuild or .Net.

    If I unset this environment variable the build finishes successful.

    Why have they chosen such a generic variable name to define the programming language to be used to compile the LightSwitch project??? Something like $(LSProgrammingLanguage) would be more appropriate...

    Regards

    • Marked as answer by awag Saturday, October 19, 2013 9:53 AM
    Saturday, October 19, 2013 9:53 AM