Fail to host a LightSwitch HTML Client application on AppHarbor

LightSwitch HTML Client inspires me a lot since its first release. I never think that the database development can be so fast and easy. It takes me just an hour to finish an application with Authentication, Authorization, CRUD (Create, Read, Update, Delete), HTML5 support and Mobile capability. LightSwitch is such a great tool with its wonderful features, however hosting a LightSwitch application on a build server seems to be not so easy. I don’t own either a Windows Azure server or a Windows VPS Server so that I can install LightSwitch prerequisites on it. So I manage to host my LightSwitch application on shared host like AppHarbor. It takes me days to fix the compiled errors on the server and I still fail. There is an error of building tasks and I can’t solve it.

I would like to emphasize again that I still can’t host a LightSwitch application on AppHarbor but I would like to share what I did so far. Maybe one of you follow the steps and at the end find out how to fix the error which I encounter. In the next section, you’ll find the summary of the steps which I made to create a sample project, push it to AppHarbor and how I fix the errors.

1. Prepare a test project

– Start Visual Studio and create a LightSwitch HTML Application.
– Right click on the project and choose Add Client…

LightSwitch Add Client

– On the new window, choose DesktopClient and click OK

LightSwitch Add Desktop Client

– Right click on new DesktopClient (Startup), choose Properties –> Client Type –> Web

DesktopClient Web

– Press F5 to run application to check if everything works. You won’t see anything but a blank screen on browser. No error is good.

2. Host project to AppHarbor

– Go to Bitbucket, create a new repository using mercurial. Check in your sample project into new repository. Remember to check everything into repository, don’t filter anything. Packages from NuGet has to be checked in too. AppHarbor can’t load some NuGet Packages of LightSwitch. If you set restoring NuGet packages during building, you’ll get errors later.
– Go to AppHarbor, create a new application and link that application to your BitBucket repository.

Link appharbor to bitbucket

– Now you have already linked your LightSwitch application to build server of AppHarbor. You can read more about integrating AppHarbor with BitBucket at following link

3. Fix errors

– Our application was already linked to AppHarbor, after each push to BitBucket, AppHarbor will download the source code and compile on his server.

AppHarbor Pull History

– If you click on each history item, you will see more details such as branch, commit message, overview of log… The log details is under Show Log URL

AppHarbor Show Log

– Now back to our sample project, after pushing our source code to BitBucket, AppHarbor will pull the source code and compile it. Of course our test project can’t be compiled because LightSwitch prerequisites are not installed on server. We have to make bin-deploy that we copy all required .dlls to source code folder and force project to load those .dlls instead of searching in GAC or in Program Files (x86) folder.

– When I try to host application myself, of course, I have to fix step by step, error after error but it’s not necessary to write all steps according to that sequence here. You’ll loose an overview of what is going on and why I solve like that. You’ll only see a big mess of errors. :). So I will categorize the errors as following categories and tell you how I fix them.

3.1 Imported project

– When a Visual Studio is built,many build actions will be executed. They are defined as default in .targets or .props files which are usually located under “C:\Program Files (x86)\…”. As we already know, the server isn’t equipped with LightSwitch prerequisites. Therefore some of imported projects won’t be found. Let’s take a look of some typical errors of this kind

D:\temp\xdpnaxy5.cjp\input\lightswitch-sample-application.ls3proj(169,3): error MSB4019: The imported project "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\LightSwitch\v3.0\Microsoft.LightSwitch.targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.

D:\temp\qsb342dp.m0d\input\lightswitch-sample-application.DesktopClient\lightswitch-sample-application.DesktopClient.csproj(254,3): error MSB4019: The imported project "C:\Program Files (x86)\MSBuild\Microsoft\Silverlight\v5.0\Microsoft.Silverlight.CSharp.targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.

D:\temp\iiovsxxe.ub0\input\lightswitch_sample_application.HTMLClient\lightswitch_sample_application.HTMLClient.jsproj(21,3): error MSB4019: The imported project "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\LightSwitch\v3.0\MobileClient\Microsoft.LightSwitch.MobileClient.Default.props" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.

D:\temp\ir4bcveg.etf\input\lightswitch_sample_application.Server\lightswitch_sample_application.Server.csproj(230,3): error MSB4019: The imported project "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\LightSwitch\v3.0\Microsoft.LightSwitch.Build.Tasks.targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.

– As you can see, the errors occur in 4 different projects: .ls3proj, DesktopClient.csprojec,HTMLClient.jsproj and Server.csproj. All of them indicate that these projects are trying to load default build project of LightSwitch prerequisites but they can’t find it. So we need to tell msbuild where he can find these imported projects. To fix these errors we have to make 2 steps: patch the project file and copy prerequisites to local repository.

3.1.1 Patch project files

– In next step, I tell the project files to load the dependencies from $(SolutionDir) instead of using default paths
File: lightswitch-sample-application.ls3proj

<Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\LightSwitch\$(LightSwitchVersion)\Microsoft.LightSwitch.targets" />


<Import Project="$(SolutionDir)MSBuild\Microsoft\VisualStudio\LightSwitch\$(LightSwitchVersion)\Microsoft.LightSwitch.targets" />
<Import Condition="false" Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\LightSwitch\$(LightSwitchVersion)\Microsoft.LightSwitch.targets" />

File: lightswitch_sample_application.HTMLClient.jsproj

<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\LightSwitch\v3.0\MobileClient\Microsoft.LightSwitch.MobileClient.Default.props" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\LightSwitch\v3.0\MobileClient\Microsoft.LightSwitch.MobileClient.props" />


<Import Project="$(SolutionDir)\MSBuild\Microsoft\VisualStudio\LightSwitch\v3.0\MobileClient\Microsoft.LightSwitch.MobileClient.Default.props" />
<Import Condition="false" Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\LightSwitch\v3.0\MobileClient\Microsoft.LightSwitch.MobileClient.Default.props" />
<Import Project="$(SolutionDir)\MSBuild\Microsoft\VisualStudio\LightSwitch\v3.0\MobileClient\Microsoft.LightSwitch.MobileClient.props" />
<Import Condition="false" Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\LightSwitch\v3.0\MobileClient\Microsoft.LightSwitch.MobileClient.props" />


<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\LightSwitch\v3.0\MobileClient\Microsoft.LightSwitch.MobileClient.targets"/>
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\LightSwitch\v3.0\Microsoft.LightSwitch.Build.Tasks.targets" />


<Import Project="$(SolutionDir)MSBuild\Microsoft\VisualStudio\LightSwitch\v3.0\MobileClient\Microsoft.LightSwitch.MobileClient.targets"/>
<Import Condition="false" Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\LightSwitch\v3.0\MobileClient\Microsoft.LightSwitch.MobileClient.targets"/>
<Import Project="$(SolutionDir)MSBuild\Microsoft\VisualStudio\LightSwitch\v3.0\Microsoft.LightSwitch.Build.Tasks.targets" />
<Import Condition="false" Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\LightSwitch\v3.0\Microsoft.LightSwitch.Build.Tasks.targets" />

File: lightswitch_sample_application.Server.csproj

<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\LightSwitch\$(LightSwitchVersion)\Microsoft.LightSwitch.Build.Tasks.targets" />


<Import Project="$(SolutionDir)MSBuild\Microsoft\VisualStudio\LightSwitch\$(LightSwitchVersion)\Microsoft.LightSwitch.Build.Tasks.targets" />
<Import Condition="false" Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\LightSwitch\$(LightSwitchVersion)\Microsoft.LightSwitch.Build.Tasks.targets" />

File: lightswitch-sample-application.DesktopClient.csproj

<Import Condition="false" Project="$(MSBuildExtensionsPath32)\Microsoft\Silverlight\$(SilverlightVersion)\Microsoft.Silverlight.CSharp.targets" />
<Import Condition="false" Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\LightSwitch\$(LightSwitchVersion)\Microsoft.LightSwitch.Build.Tasks.targets" />


<Import Condition="Exists('$(SolutionDir)MSBuild\Microsoft\Silverlight\$(SilverlightVersion)\Microsoft.Silverlight.CSharp.targets')" Project="$(SolutionDir)MSBuild\Microsoft\Silverlight\$(SilverlightVersion)\Microsoft.Silverlight.CSharp.targets" />
<Import Condition="!Exists('$(SolutionDir)MSBuild\Microsoft\Silverlight\$(SilverlightVersion)\Microsoft.Silverlight.CSharp.targets') and Exists('..\MSBuild\Microsoft\Silverlight\$(SilverlightVersion)\Microsoft.Silverlight.CSharp.targets')" Project="..\MSBuild\Microsoft\Silverlight\$(SilverlightVersion)\Microsoft.Silverlight.CSharp.targets" />
<Import Condition="false" Project="$(MSBuildExtensionsPath32)\Microsoft\Silverlight\$(SilverlightVersion)\Microsoft.Silverlight.CSharp.targets" />
<Import Condition="Exists('$(SolutionDir)MSBuild\Microsoft\VisualStudio\LightSwitch\$(LightSwitchVersion)\Microsoft.LightSwitch.Build.Tasks.targets')" Project="$(SolutionDir)MSBuild\Microsoft\VisualStudio\LightSwitch\$(LightSwitchVersion)\Microsoft.LightSwitch.Build.Tasks.targets" />
<Import Condition="!Exists('$(SolutionDir)MSBuild\Microsoft\VisualStudio\LightSwitch\$(LightSwitchVersion)\Microsoft.LightSwitch.Build.Tasks.targets') and Exists('..MSBuild\Microsoft\VisualStudio\LightSwitch\$(LightSwitchVersion)\Microsoft.LightSwitch.Build.Tasks.targets')" Project="..\MSBuild\Microsoft\VisualStudio\LightSwitch\$(LightSwitchVersion)\Microsoft.LightSwitch.Build.Tasks.targets" />
<Import Condition="false" Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\LightSwitch\$(LightSwitchVersion)\Microsoft.LightSwitch.Build.Tasks.targets" />

3.1.2 Copy required files into solution directory

– We have done in the step before is fixing the path of the dependencies by setting from “Program Files …” to our solution directory. Now we have to copy those files to solution directory. Let’s copy all files (keeping structure) of following folders directly to your solution directory

C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\LightSwitch\v3.0\
C:\Program Files (x86)\MSBuild\Microsoft\Silverlight\v5.0\
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\LightSwitch\v3.0\MobileClient\

– After copying, your solution directory will have new folder MSBuild like this

MSBuild in Solution Directory

– That’s is all about the error with imported project. Anytime when you see this kind of error, following my hint above, edit the project, copy required files, you’ll pass.

3.2 Could not resolve this reference

– Another kind of error during building your LightSwitch application on AppHarbor is “Warning”. You’ll get about 30 warning messages because the required .dlls are not available at project folder. The typical message of this kind of error is

C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1578,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly "Microsoft.LightSwitch". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors. [D:\temp\5xghtdxi.wdu\input\lightswitch_sample_application.Server\lightswitch_sample_application.Server.csproj]
                 For SearchPath "{HintPathFromItem}".
                 Considered "C:\Program Files (x86)\Microsoft SDKs\LightSwitch\v3.0\\Client\Microsoft.LightSwitch.dll", but it didn't exist.
                 For SearchPath "{TargetFrameworkDirectory}".
                 Considered "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\Microsoft.LightSwitch.winmd", but it didn't exist.
                 Considered "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\Microsoft.LightSwitch.dll", but it didn't exist.
                 Considered "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\Microsoft.LightSwitch.exe", but it didn't exist.
                 For SearchPath "{Registry:Software\Microsoft\.NETFramework,v4.0,AssemblyFoldersEx}".
                 Considered AssemblyFoldersEx locations.
                 For SearchPath "{AssemblyFolders}".
                 Considered "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\v3.5\Microsoft.LightSwitch.winmd", but it didn't exist.
                 Considered "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\v3.5\Microsoft.LightSwitch.dll", but it didn't exist.
                 Considered "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\v3.5\Microsoft.LightSwitch.exe", but it didn't exist.
                 Considered "C:\Program Files (x86)\Microsoft\Contracts\PublicAssemblies\v3.5\Microsoft.LightSwitch.winmd", but it didn't exist.
                 Considered "C:\Program Files (x86)\Microsoft\Contracts\PublicAssemblies\v3.5\Microsoft.LightSwitch.dll", but it didn't exist.
                 Considered "C:\Program Files (x86)\Microsoft\Contracts\PublicAssemblies\v3.5\Microsoft.LightSwitch.exe", but it didn't exist.
                 Considered "C:\Program Files (x86)\Microsoft SQL Server\100\SDK\Assemblies\Microsoft.LightSwitch.winmd", but it didn't exist.
                 Considered "C:\Program Files (x86)\Microsoft SQL Server\100\SDK\Assemblies\Microsoft.LightSwitch.dll", but it didn't exist.
                 Considered "C:\Program Files (x86)\Microsoft SQL Server\100\SDK\Assemblies\Microsoft.LightSwitch.exe", but it didn't exist.
                 Considered "C:\Program Files (x86)\Microsoft.NET\ADOMD.NET\100\Microsoft.LightSwitch.winmd", but it didn't exist.
                 Considered "C:\Program Files (x86)\Microsoft.NET\ADOMD.NET\100\Microsoft.LightSwitch.dll", but it didn't exist.
                 Considered "C:\Program Files (x86)\Microsoft.NET\ADOMD.NET\100\Microsoft.LightSwitch.exe", but it didn't exist.
                 Considered "C:\Program Files (x86)\FSharp-\bin\Microsoft.LightSwitch.winmd", but it didn't exist.
                 Considered "C:\Program Files (x86)\FSharp-\bin\Microsoft.LightSwitch.dll", but it didn't exist.
                 Considered "C:\Program Files (x86)\FSharp-\bin\Microsoft.LightSwitch.exe", but it didn't exist.
                 Considered "C:\Program Files (x86)\Microsoft SQL Server\110\SDK\Assemblies\Microsoft.LightSwitch.winmd", but it didn't exist.
                 Considered "C:\Program Files (x86)\Microsoft SQL Server\110\SDK\Assemblies\Microsoft.LightSwitch.dll", but it didn't exist.
                 Considered "C:\Program Files (x86)\Microsoft SQL Server\110\SDK\Assemblies\Microsoft.LightSwitch.exe", but it didn't exist.
                 Considered "C:\Program Files\IIS\Microsoft Web Deploy V3\Microsoft.LightSwitch.winmd", but it didn't exist.
                 Considered "C:\Program Files\IIS\Microsoft Web Deploy V3\Microsoft.LightSwitch.dll", but it didn't exist.
                 Considered "C:\Program Files\IIS\Microsoft Web Deploy V3\Microsoft.LightSwitch.exe", but it didn't exist.
                 Considered "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\v3.0\Microsoft.LightSwitch.winmd", but it didn't exist.
                 Considered "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\v3.0\Microsoft.LightSwitch.dll", but it didn't exist.
                 Considered "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\v3.0\Microsoft.LightSwitch.exe", but it didn't exist.
                 For SearchPath "{GAC}".
                 Considered "Microsoft.LightSwitch", which was not found in the GAC.
                 For SearchPath "{RawFileName}".
                 Considered treating "Microsoft.LightSwitch" as a file name, but it didn't exist.
                 For SearchPath "D:\temp\5xghtdxi.wdu\output\".
                 Considered "D:\temp\5xghtdxi.wdu\output\Microsoft.LightSwitch.winmd", but it didn't exist.
                 Considered "D:\temp\5xghtdxi.wdu\output\Microsoft.LightSwitch.dll", but it didn't exist.
                 Considered "D:\temp\5xghtdxi.wdu\output\Microsoft.LightSwitch.exe", but it didn't exist.

– The main reason of these warnings is also not-found-references. You have seen that msbuild needs a file for his compile process and he starts to search in many possible folders until he finds it. Our mission is pretty easy, give him what he wants. Just choose one of searched folder and put the files in there, msbuild will be satified. Or you can use my solution: To solve these warnings, in Visual Studio, I click on project and choose File View

LightSwitch FileView

– Under Server and DesktopClient project, create a folder called DeployedDll


– Copy all .dll files in Debug or Release folder of Server/DeskopClient into DeployedDll and then set “Copy to Output Directory” property of all files to “Copy always”.

Server Deployed Dll

DesktopClient Deployed Dll

– Push your changes to server and all warnings will be gone with the wind.

3.3 The Silverlight 4 SDK is not installed

– If you have only HTML Client in project, you won’t see this error. But we have added a DesktopClient in our application and this DesktopClient is a silverlight application therefore he asks for SDK so that he can run. The typical error looks like following

D:\temp\prancaxg.w4x\input\MSBuild\Microsoft\Silverlight\v5.0\Microsoft.Silverlight.Common.targets(104,9): error : The Silverlight 4 SDK is not installed. [D:\temp\prancaxg.w4x\input\lightswitch-sample-application.DesktopClient\lightswitch-sample-application.DesktopClient.csproj]

(GetFrameworkPaths target) ->
         D:\temp\prancaxg.w4x\input\MSBuild\Microsoft\Silverlight\v5.0\Microsoft.Silverlight.Common.targets(104,9): error : The Silverlight 4 SDK is not installed. [D:\temp\prancaxg.w4x\input\lightswitch-sample-application.DesktopClient\lightswitch-sample-application.DesktopClient.csproj]

– Let’s analyze the error together. The error happens when Microsoft.Silverlight.Common.targets is built, some tasks in this file should be executed and one of them “the GetFrameworkPaths” failed for unknown reasons and throwed “The Silverlight 4 SDK is not installed”. OK, open Microsoft.Silverlight.Common.targets file, search for GetFrameworkPaths and analyze what this task really wants to do. According to his definition, the taks tries to load Silverlight SDK by evaluating 3 variables below

	<Output TaskParameter="SilverlightPath" PropertyName="TargetFrameworkDirectory" Condition="'$(TargetFrameworkDirectory)' == ''"/>
	<Output TaskParameter="SilverlightSDKPaths" ItemName="_TargetFrameworkSDKDirectoryItem" Condition="'$(TargetFrameworkSDKDirectory)' == ''"/>
	<Output TaskParameter="SilverlightRuntimeVersion" PropertyName="SilverlightRuntimeVersion" Condition="'$(SilverlightRuntimeVersion)' == ''"/>

– If msbuild finds required Silverlight .dlls in the path of theses variables, he’ll take them as Silverlight SDK. But where do these paths point to? Where should we get the files? It’s pretty easy, print out the content of these variables at our development machine and then copy the files to our local repository. To get content of the variables, open file lightswitch-sample-application.DesktopClient.csproj with a text editor and edit its section ‘Target Name=”AfterBuild”‘ as below

<Target Name="AfterBuild">
	<Message Importance="high" Text="TargetFrameworkDirectory: $(TargetFrameworkDirectory)" />
	<Message Importance="high" Text="TargetFrameworkSDKDirectory: $(TargetFrameworkSDKDirectory)" />
	<Message Importance="high" Text="SilverlightRuntimeVersion: $(SilverlightRuntimeVersion)" />

– What we inserted to action AfterBuild is just that after DesktopClient.csproj was built, please print out the value of 3 variables. Save your changes, open Visual Studio and compile the project, values of the variables will be printed at the Output tab

TargetFrameworkDirectory TargetFrameworkSDKDirectory SilverlightRuntimVersion

– Write down these values and copy files to your local repository as we did before. After copying, we also need to tell msbuild to load files from our local repository. Edit lightswitch-sample-application.DesktopClient.csproj again, right before we import Microsoft.Silverlight.Common.targets (or actually Microsoft.Silverlight.CSharp.targets, this will call Microsoft.Silverlight.Common.targets inside him), let’s define the values of 3 variable pointing to local

<PropertyGroup Condition="$(SilverlightVersion) == 'v5.0' and !Exists('$(MSBuildExtensionsPath32)\Microsoft\Silverlight\$(SilverlightVersion)\Microsoft.Silverlight.CSharp.targets')">
    <TargetFrameworkDirectory>$(SolutionDir)Reference Assemblies\Microsoft\Framework\Silverlight\v5.0\</TargetFrameworkDirectory>
    <TargetFrameworkSDKDirectory>$(SolutionDir)Microsoft SDKs\Expression\Blend\Silverlight\v5.0\Libraries\;$(SolutionDir)Microsoft SDKs\Expression\Extensions\FXG\Libraries\Silverlight\v5.0\;$(SolutionDir)Microsoft SDKs\Expression\Blend\Silverlight\v5.0\Prototyping\Libraries\;$(SolutionDir)Microsoft SDKs\RIA Services\v1.0\Libraries\Silverlight\;$(SolutionDir)Common Files\Microsoft Shared\Web Server Extensions\15\Template\Layouts\ClientBin;$(SolutionDir)Microsoft SDKs\Silverlight\v5.0\Libraries\Client\</TargetFrameworkSDKDirectory>

Add PropertyGroup for Silverlight SDK

– After fixing, msbuild will find Silverlight SDK at your local repository.

3.4 Task could not be loaded from the assembly Microsoft.LightSwitch.Build.Tasks.dll

– In this section, we still solve the not-found-references. Indeed all we have to do is fixing references so that msbuild works. Now the error is relevant to Microsoft.LightSwitch.Build.Tasks.dll is not found. It’s just as same as error above because msbuild tries to resolve files at “Program Files” folder and he can’t find. The typical error message should be

D:\temp\g0bj1lyb.br1\input\MSBuild\Microsoft\VisualStudio\LightSwitch\v3.0\Microsoft.LightSwitch.Build.Tasks.targets(208,5): error MSB4062: The "LSResourceGeneratorsTask" task could not be loaded from the assembly C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\LightSwitch\v3.0\Microsoft.LightSwitch.Build.Tasks.dll. Could not load file or assembly 'file:///C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\LightSwitch\v3.0\Microsoft.LightSwitch.Build.Tasks.dll' or one of its dependencies. The system cannot find the file specified. Confirm that the <UsingTask> declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask. [D:\temp\g0bj1lyb.br1\input\lightswitch_sample_application.HTMLClient\lightswitch_sample_application.HTMLClient.jsproj]

– I hope until now you can fix this error yourself. Again some tasks in Microsoft.LightSwitch.Build.Tasks.targets tries to load file and not found. As we did before, to solve this error, you need to edit Microsoft.LightSwitch.Common.targets and point LightSwitchTaskDir to our local folder, so that Microsoft.LightSwitch.Build.Tasks.dll must be loaded from our local repository.



– After resolving the error with Microsoft.LightSwitch.Build.Tasks.dll, you’ll encounter other errors saying the dependencies of Microsoft.LightSwitch.Build.Tasks.dll are not found. Analyze the errors and copy the necessary files with correct version from GAC to same folder of Microsoft.LightSwitch.Build.Tasks.dll. When you finish with copy all required files, the errors will go away.

D:\temp\01rqohcc.jgp\input\MSBuild\Microsoft\VisualStudio\LightSwitch\v3.0\Microsoft.LightSwitch.Build.Tasks.targets(208,5): error MSB4062: The "LSResourceGeneratorsTask" task could not be loaded from the assembly D:\temp\01rqohcc.jgp\input\MSBuild\Microsoft\VisualStudio\LightSwitch\v3.0\Microsoft.LightSwitch.Build.Tasks.dll. Could not load file or assembly 'Microsoft.LightSwitch.Design.CodeGen, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified. Confirm that the <UsingTask> declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask. [D:\temp\01rqohcc.jgp\input\lightswitch_sample_application.HTMLClient\lightswitch_sample_application.HTMLClient.jsproj]


– Be careful when copying files from GAC, you must select the correct version.

4. The last stand

– So we fixed a lot of errors, didn’t we? And it still doesn’t work. The last error just blocks my way to a successful compiling.

D:\temp\3qbdwhtz.s5q\input\MSBuild\Microsoft\VisualStudio\LightSwitch\v3.0\Microsoft.LightSwitch.Build.Tasks.targets(209,5): error MSB4018: The "LSResourceGeneratorsTask" task failed unexpectedly. [D:\temp\3qbdwhtz.s5q\input\lightswitch_sample_application.HTMLClient\lightswitch_sample_application.HTMLClient.jsproj]
D:\temp\3qbdwhtz.s5q\input\MSBuild\Microsoft\VisualStudio\LightSwitch\v3.0\Microsoft.LightSwitch.Build.Tasks.targets(209,5): error MSB4018: System.NullReferenceException: Object reference not set to an instance of an object. [D:\temp\3qbdwhtz.s5q\input\lightswitch_sample_application.HTMLClient\lightswitch_sample_application.HTMLClient.jsproj]
D:\temp\3qbdwhtz.s5q\input\MSBuild\Microsoft\VisualStudio\LightSwitch\v3.0\Microsoft.LightSwitch.Build.Tasks.targets(209,5): error MSB4018:    at Microsoft.LightSwitch.BuildTasks.CodeGen.LSGeneratorsTask.RunGeneratorsInNonIdeScenario() [D:\temp\3qbdwhtz.s5q\input\lightswitch_sample_application.HTMLClient\lightswitch_sample_application.HTMLClient.jsproj]
D:\temp\3qbdwhtz.s5q\input\MSBuild\Microsoft\VisualStudio\LightSwitch\v3.0\Microsoft.LightSwitch.Build.Tasks.targets(209,5): error MSB4018:    at Microsoft.LightSwitch.BuildTasks.CodeGen.LSGeneratorsTask.Execute() [D:\temp\3qbdwhtz.s5q\input\lightswitch_sample_application.HTMLClient\lightswitch_sample_application.HTMLClient.jsproj]
D:\temp\3qbdwhtz.s5q\input\MSBuild\Microsoft\VisualStudio\LightSwitch\v3.0\Microsoft.LightSwitch.Build.Tasks.targets(209,5): error MSB4018:    at Microsoft.LightSwitch.BuildTasks.CodeGen.LSResourceGeneratorsTask.Execute() [D:\temp\3qbdwhtz.s5q\input\lightswitch_sample_application.HTMLClient\lightswitch_sample_application.HTMLClient.jsproj]
D:\temp\3qbdwhtz.s5q\input\MSBuild\Microsoft\VisualStudio\LightSwitch\v3.0\Microsoft.LightSwitch.Build.Tasks.targets(209,5): error MSB4018:    at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute() [D:\temp\3qbdwhtz.s5q\input\lightswitch_sample_application.HTMLClient\lightswitch_sample_application.HTMLClient.jsproj]
D:\temp\3qbdwhtz.s5q\input\MSBuild\Microsoft\VisualStudio\LightSwitch\v3.0\Microsoft.LightSwitch.Build.Tasks.targets(209,5): error MSB4018:    at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__20.MoveNext() [D:\temp\3qbdwhtz.s5q\input\lightswitch_sample_application.HTMLClient\lightswitch_sample_application.HTMLClient.jsproj]

– I really have no idea what’s wrong with this error. Well, NullReferenceException is already clear but why and where? For your convenience, I made a sample project of bin-deploy with all steps I did above. If you want to try yourself, you can check if out here

Check it out, and push to your own repository and link to AppHarbor, you can see the last error immediately. If you’re successful, then please share your solution to me. ;). Just one more thing, LightSwitch HTML needs Visual Studio 2012.


  1. Just wondering if you were able to get this deployment working ?
    Nice post .. but would love to see step 5 😉

Leave a comment

Your email address will not be published. Required fields are marked *