Deploying resources with WinRT components

If you have developed WinRT components referencing resources (such as Generic.xaml resource dictionaries within Themes folders, or other content files that you internally load using msappx protocol) and you need to deploy the output assembly (WinMD file), you’ll need to make sure that the output folder structure is similar to this:

  • YourComponent.winmd (assembly file)
  • YourComponent (subfolder)
    • Themes (subfolder)
      • Generic.xaml (resource file)

Otherwise, although the component could compile and working correctly from a project referencing application within same Visual Studio solution, you may receive compile errors indicating that the resource files are not found when you try to reference the assembly directly from a different one.

Visual Studio 2012 for Windows 8 doesn’t seem to deploy the correct folder structure automatically to the output folder. It will place Themes subfolder directly in the same root folder where YourComponent.winmd file is placed.

To resolve the issue, you can configure this post-build script to be run when you build your WinRT component project (you need one line for each resource subfolder, such as Theme, adapted to your naming):

xcopy /s /y “$(TargetDir)\Themes\*.*”
            “$(TargetDir)\$(TargetName)\Themes\*.*”

About Sorin Dolha

My passion is software development, but I also like physics.
This entry was posted in Computers and Internet and tagged , , , , . Bookmark the permalink.

Add a reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s