Untergeordnete Seiten
  • Build Process

  Wiki Navigation

    Loading...


 Recently Updated


 Latest Releases

 MediaPortal 1.32
            Releasenews | Download
 MediaPortal 2.5
            Releasenews | Download


Table of Contents

Overview

MediaPortal 2 is an application which is composed of few core components and many dynamic plugins which are loaded at runtime. In Visual Studio, each core component and each plugin are realized as a separate VS project. To compile the default system all together, all projects are part of a big VS solution.

Target structure

When the application is built, the target directory structure should contain the main windows executable file, some dlls and other files in the application's root directory, and some sub directories containing different other stuff, for example default setttings, plugins, etc.

This target structure is created by the Visual Studio build command of the MP2 solution. It is written to the directory

Bin\MP2-Client\bin\x86\Release\

or

Bin\MP2-Client\bin\x86\Debug\

respectively). (Note: This is the current state. In the future, we might switch from 32 bit to 64 bit, and we might adapt the target directory slightly)

In the following sections, we will call this directory the _target output directory_ or _target directory_, which refers to the directory according to the current build configuration (Release or Debug/x86 or x64).

Configuration of the main project and its referenced projects

The main project (MediaPortal.Client) is the only project which directly compiles into the target output directory. This is not optimal, because with this setting, VS also copies additional files to the target directory like the debug symbols file, etc. But with that setup, we are able to make the VS integrated debugger run the project in the target directory.

The main project has project references to some core projects like MediaPortal.Common, MediaPortal.UI, ..., MediaAccessor ...

Because those projects are referenced by the main project, their dll files are automatically copied by VS to the target directory.

Configuration of each VS plugin project

Plugin projects are not explicitly referenced by the main Visual Studio project file. They will be automatically compiled into the correct directory and loaded at runtime by the PluginManager component. To make that happen, the set of plugins to be compiled is configured in the solution's *configuration manager*.

To make the system run, all plugins must be available in the plugins subdirectory of the target directory at the end of the build process. To achieve this, each plugin project does a two-step build process:

First, it compiles its sources to its local (default) output directory (typically

bin\x86\Release

, or

bin\x86\Debug

, respectively, in its root project directory).

Then the AfterBuild target copies all files of this plugin to the main project's target output directory. So plugin P will copy its resources to 

$(SolutionDir)..\Bin\$(SolutionName)\$(OutDir)Plugins\$(ProjectName)

, which is 

[...]\Bin\MP2-Client\bin\x86\Release\Plugins\P

, for example. This is done using MSBuild like described in the next chapter.

PostBuild / AfterBuild Commands using MSBuild

The instructions for copying these files are defined in a separated MSBuild targets file which needs also being included into the project file. Using MSBuild instead of the projects PostBuildEvents has various advantages like having much more control over each single step of the build process, a separation post build commands from the actual project files and the ability to make use of many MSBuild tasks. For more information about MSBuild please read it's documentation and/or search for specific tasks you would like to achieve.

The Pre- and PostBuildEvents which can be configured within the project's settings dialog should not be used anymore to ensure consistency across all plugins and projects.

The most important targets are

BeforeBuild

and

AfterBuild

. Both targets are defined in the same MSBuild file

build.targets

which is located within the project's root directory (

$(ProjectDir)

). To ensure the defined targets are also executed during the build process the targets-file needs to be import into the *.csproject-file (line 9). Line 6 is responsible for displaying the files within the VisualStudios' file browser to easily open and modify it.

<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
  <PropertyGroup>
  ...
  <ItemGroup>
    <None Include="build.targets" />
  </ItemGroup>
  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
  <Import Project="build.targets" />
</Project>

The

build.targets

-file of the SkinEngine looks like this, for example:

<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">

  <PropertyGroup>
    <PluginDestination>$(SolutionDir)..\Bin\$(SolutionName)\$(OutDir)Plugins\$(ProjectName)\</PluginDestination>
  </PropertyGroup>

  <ItemGroup>
    <PluginFiles Include="$(TargetDir)$(ProjectName).dll" />
    <PluginFiles Include="$(ProjectDir)plugin.xml" />
  </ItemGroup>

  <ItemGroup>
    <LanguageFiles Include="$(ProjectDir)Language\*.*" />
  </ItemGroup>

  <ItemGroup>
    <SkinFiles Include="$(ProjectDir)Skin\**\*.*" />
  </ItemGroup>

  <ItemGroup>
    <References Include="$(ProjectDir)References\freetype6.dll" />
    <References Include="$(ProjectDir)References\SlimDX.dll" />
    <References Include="$(ProjectDir)References\zlib1.dll" />
  </ItemGroup>

  <Target Name="AfterBuild">
    <Copy SourceFiles="@(PluginFiles)" DestinationFolder="$(PluginDestination)" />
    <Copy SourceFiles="@(LanguageFiles)" DestinationFolder="$(PluginDestination)Language\" />
    <Copy SourceFiles="@(SkinFiles)"
          DestinationFiles="@(SkinFiles->'$(PluginDestination)Skin\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(References)" DestinationFolder="$(PluginDestination)" />
  </Target>

</Project>

   

 

This page has no comments.