MissingManifestResourceException when using Portable Class Libraries within WinRT
Our team recently ran into a strange issue. Our Windows Phone application targets Silverlight 8.1 but we have several WinRT 8.1 based background tasks. Recen...
In a previous post I introduced the concept of Role Content Folders and how they can be used to deploy additional content (e.g. configuration files, runtime components, etc.) to the virtual machine for a Windows Azure application role. That post was written from the perspective of a developer working within Visual Studio and works great when the content is relatively static and specific to a single project. However, this feature works less well in cases where the content is more dynamic (i.e. where the additional content is not known until package-time) or when the content is used across several roles or applications. Fortunately, the packaging of Role Content Folders within Visual Studio is built upon more general MSBuild infrastructure which we can extend to package additional, arbitrary content.
In v1.7, the targets file for Windows Azure projects contains a new packaging phase (i.e. high-level target) called AddRoleContent. In this phase, various sub-targets identify the Role Content Folders defined by the project file, prepare the files within those folders for packaging, and then inject appropriate elements into the Service Definition (.csdef) file such that those files will be packaged when the process invokes CSPack. The AzureRoleContent MSBuild item group ultimately determines what folders will be packaged and for which roles. An AzureRoleContent item contains the following metadata:
To inject additional content into the package, one must add new AzureRoleContent items prior to the last step of this packaging phase. A convenient place to do this is within an override of the BeforeAddRoleContent target. An alternative is to add a custom target to the beginning of the target list CoreAddRoleContentDependsOn MSBuild property. This latter approach can be useful for cases where you customize many Windows Azure projects in the same way, as it ensures that individual Azure projects do not interfere with the customization if a project were to independently override the BeforeAddRoleContent target.
Let’s suppose we have the following:
The first step is to edit the Windows Azure project file and override the BeforeAddRoleContent target. Next, the target will create a new item group, AzureRoleContent, that includes the AdditionalContent folder. We’ll then add metadata to the item group to specify that it be deployed with the web role, MyWebRole, as well as deployed to the APPROOT\AdditionalContent folder. In the end, we will have a project file that looks something like:
.
.
.
<Import Project="$(CloudExtensionsDir)Microsoft.WindowsAzure.targets" />
<Target Name="BeforeAddRoleContent">
<ItemGroup>
<AzureRoleContent Include="AdditionalContent">
<RoleName>MyWebRole</RoleName>
<Destination>AdditionalContent</Destination>
</AzureRoleContent>
</ItemGroup>
</Target>
.
.
.
When a package is built and/or deployed you will then see the AdditionalContent folder, with its AdditionalContent.xml file, in the package layout and/or on the virtual machine.
Now what would happen if we omitted the Destination metadata from the item group, as in the following example?
.
.
.
<AzureRoleContent Include="AdditionalContent">
<RoleName>MyWebRole</RoleName>
<!--<Destination>AdditionalContent</Destination>-->
</AzureRoleContent>
.
.
.
In this example, the content in the AdditionalContent folder will deployed directly to APPROOT, with no corresponding subfolder. This can be very useful when you need to deploy a configuration file to APPROOT. However, note that this can result in name collisions between files deployed by the role project and files deployed through this Role Content Folder mechanism. You will not get any warnings or errors from CSPack (or the Tools) when this happens, so beware!
Role Content Folders can be a great option when you have additional content to deploy to a role of a Windows Azure application, whether used to deploy static content within Visual Studio or used in conjunction with the underlying infrastructure to deploy more dynamic content.
This post was migrated from my MSDN blog, Visual Studio Tools and Anything Else I Can Think Of, and written as a Microsoft employee.
Our team recently ran into a strange issue. Our Windows Phone application targets Silverlight 8.1 but we have several WinRT 8.1 based background tasks. Recen...
In a previous post I introduced the concept of Role Content Folders and how they can be used to deploy additional content (e.g. configuration files, runtime ...
The latest versions of the Windows Azure Tools for Visual Studio have the ability to maintain multiple versions of the Service Configuration (.cscfg) file.&n...
When a package fails to deploy to Windows Azure (or deploys but its roles fail to start properly) it can be difficult to determine what went wrong. In many c...
Windows Azure applications often need to package and deploy additional content. This could be advanced configuration files such as the diagnostics.wadcfg for...
The LINQ-to-DASL provider of the Office Interop API Extensions provides a very limited set of mappings between its query types and their associated DASL prop...
When your LINQ-to-DASL queries do not return the results you expect, how do you determine where the problem is? The issue could be that the query simpl...
I received an email over the weekend asking why the following LINQ to DASL query threw an exception: Outlook.Folder folder = (Outlook.Folder)Application.Se...
Now that the Office Interop API Extensions have been released, I thought I would post a complete walkthrough of a simple LINQ to DASL application. Let's star...
One of the disadvantages of C# compared with VB is its lack of support for parameterized properties. Instead, parameterized properties in C# are exposed as ...
As announced in Andrew Whitechapel’s post, version 1.0 of the VSTO Power Tools have been released! One of those tools is the Office Interop API Extensions, a...
In an earlier post I discussed LINQ to DASL, part of the Office Interop API Extensions, which is one of the forthcoming VSTO Power Tools. LINQ to DASL ...
In my last post I talked about LINQ to DASL, a LINQ provider that converts query expressions into their DASL equivalent in order to efficiently filter item c...
Quick, tell me what the following code does:
I like VSTO. I like C#. What I don’t like is having to write VSTO code in C# like:
Yesterday I gave a presentation on VSTO at the third annual Portland Code Camp. I demonstrated an Outlook 2007 add-in that used Outlook Form Regions, WCF, an...