When I was writing unit tests for an ODataController I needed the references to the
Microsoft.Lightswitch.dll and to the
Microsoft.LightSwitch.Server.dll in the unit test project. I tried to add them with the
Reference Manager in Microsoft Visual Studio (Solution Explorer: Right click on references -> Add reference…) but couldn’t find the references. The Reference Manager allows you to browse for a dll so I checked the paths of the references I searched for in the main project and added them by browsing. When doing it this way the path to the references will be absolute and it’s better having relative paths in a project. I had a look into the
csproj-file of the main project to check out how this problem is solved in the main project and I found the following lines of configuration:
<LightSwitchVersion>v4.5</LightSwitchVersion> <MicrosoftSdkDir Condition=" '$(MicrosoftSdkDir)' == '' ">$([System.IO.Path]::Combine($(MSBuildProgramFiles32), 'Microsoft SDKs'))</MicrosoftSdkDir> <LightSwitchSDKPath Condition=" '$(LightSwitchSDKPath)' == '' ">$([System.IO.Path]::Combine($(MicrosoftSdkDir), 'LightSwitch', $(LightSwitchVersion)))</LightSwitchSDKPath> <LightSwitchSDKPath Condition=" '$(LightSwitchSDKPath)' != '' and !HasTrailingSlash('$(LightSwitchSDKPath)')">$(LightSwitchSDKPath)</LightSwitchSDKPath>
The properties are defined in the first PropertyGroup tag
<Reference Include="Microsoft.LightSwitch"> <HintPath>$(LightSwitchSDKPath)ClientMicrosoft.LightSwitch.dll</HintPath> <Private>True</Private> <ProjectCritical>True</ProjectCritical> </Reference> <Reference Include="Microsoft.LightSwitch.Server"> <HintPath>$(LightSwitchSDKPath)ServerMicrosoft.LightSwitch.Server.dll</HintPath> <Private>True</Private> <ProjectCritical>True</ProjectCritical> </Reference>
The references are defined in the first ItemGroup tag
To solve the problem of having absolute paths in the test project I took the above configuration snippets and manually added them to the corresponding sections in the
csproj file of the unit test project.
IMPORTANT: If the references were already added with the Reference Manager (with absolute paths) they have to be deleted from the csproj file after adding the references with relativ paths.