Alexander Vanwynsberghe

"There is nothing impossible to him who will try"

Packaging SharePoint 2013 Apps with TFS 2012

In a previous post, I was talking about how you can build SharePoint 2013 apps using TFS 2012. In this post, I will guide you through the process of creating App packages using a TFS 2012 build. There are some small things that you need to know.

Required Components on your on-prem TFS build server

To start, you need two extra components on your build server, to be able to create App packages on the one hand, and Web Deploy packages on the other hand (if you’re creating an “Auto Hosted” or a “Provider Hosted App”).

  • The first component you need is Web Deploy V3, which you can download here.

20

  • Next, you need to copy paste the following folder from your local machine to your Build Server. “C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\Web”. Otherwise you will get this nice error:

packagetarget

Hosted TFS Build Server, you can use it, now!

In my previous post, I mentioned that the Hosted TFS Build Server could not yet be used because the “Office 2013 and SharePoint 2013 Developer Tools” were not installed. Well, good news, now they are! You can make use of the Hosted TFS Build Server. This is an overview of the installed component on the hosted Build Server.

Creating App Packages

Previous versions of SharePoint have the notion of SharePoint Solution Packages (wsp). It was also possible to use TFS (2010) for creating these packages. You can find a nice how-to on this link. It all comes down to that one parameter called “/p:IsPackaging=true”. You need to pass this parameter to MSBuild.

Now with the new App model of SharePoint 2013, this behavior is identically. You also need to pass this parameter to MSBuild. To do this, create a new TFS Build Definition (like described in my previous post). On the “Process” part, check the “Build process parameters” and find the “MSBuild Arguments” on section “3.Advanced”. Add the parameter “/p:IsPackaging=true”.

package01

Save the build definition and queue a new build (right-click on the definition, and select “Queue New Build…”. After a while, you will see that you have a nice red build. Yes indeed, build failed!

denied

The problem is in fact a (small) bug on the TFS part of the build process. To create an App package, the AppManifest.xml my not be marked as ‘read-only’. Because we’re using TFS, files are marked as ‘read-only’ once they are downloaded to the Workspace. The reason for that is because the TFS 2012 build server uses ‘Server’ workspaces. Meaning that every file gets this annoying ‘read-only’ file attribute. Local workspaces, on the other hand do not behave like that, but a Build Server always use the server workspace.  (You can find a nice overview about the difference between Local and Server workspaces here). There are also reports that you can have the same behavior when you want to create an App package using Visual Studio. (Right-click on your project, and select ‘Deploy’). You will not have this issue when you’re using a local TFS workspace, as files will not be marked as “read-only” than.

Possible Solution

Unfortunately, there is no easy solution to fix this error, except a small modification to the Build Process Template. (There is an awesome guide available by the ALM Rangers to get you started, get it here). What you could do is make a copy of the ‘DefaultTemplate.11.1.xaml‘ file, and add an extra workflow activity to this template who will remove to ‘read-only‘ attribute from the AppManifest file.

workflow

The Real Solution

Now I see you thinking: nah, I really don’t like editing WF 4.5 XAML files. Well, good news, someone already created a Build Process Template with this modification. There is a nice Codeplex project called “Office / SharePoint 2013 Continuous Integration with TFS 2012“. There you can download a customized Build Process Template that can be used. All you have to do is adding this XAML file to the (for example) “BuildProcessTemplates” folder in Source Control, and change your Build Definition that it will use the new Build Process Template. So it looks like:

templateThat’s it. Just queue a build, and it should be green. (You also don’t really need to add the parameter “/p:IsPackaging=true” anymore, because this great Build Process Template will take care of this. But it’s also that smart that it will detect if you did pass the parameters, so no problem).

completedbuild
So for now, I talked about how you can actually build you SharePoint 2013 App project using TFS. In this post I described how you can produce an .APP package. In my next post, I will talk about how you can deploy your App. I will also make use of this Build Process Template from CodePlex,  because it’s already all in there!

Have fun!

Debugging Apps for SharePoint Online on a non-development site collection

In a previous post, I was talking about how you can use Project Server Online data in a SharePoint 2013 App using CSOM. One thing I was talking about was the fact that you cannot debug an application when you’re not using a development site collection. You will see this nice error:

Eli Sheldon (Program Manager at Microsoft) gave me this explanation (Thanks!):

SharePoint added a site collection level feature near RTM that, once enabled, will allow you to F5 deploy from VisualStudio, no matter what type of site collection you are targeting. Until the new bits roll online and this is documented, your best option here is to F5 debug on-prem and publish an app package and use the corporate catalog to test online.

Well, good news, SharePoint (online) is RTM (since a few weeks). Let’s find out how we can debug our SharePoint app on a non-development site. The reason why I really want to this, is because I have a Project Online App which requires a site collection where PWA (Project Web Access) is activated. Development sites cannot be created with an Active PWA.
I was hoping to see an option in the O365 SharePoint admin center where I could activate this ‘feature’. But unfortunately, there isn’t, or at least I couldn’t find it. So, the next thing I did was opening the solution of my previously created app, and hit F5 debug it. Note: be sure to install the latest version of the Office tools for Visual Studio 2012. As a result F5’ing my solution, I had this error:
So that’s a no-go, because “sideloading of apps is not enabled on this site“. After some research on the MSDN forums, I found a PowerShell script allowing you to enable Sideloading.  Because it’s not available in the interface, the only option you have is to run the PowerShell script to enable this feature. (There is not quite much information about this Sideloading thing yet though).
The first thing you have to do is download the SharePoint Online management Shell (link). The PowerShell script you can use is:
All you need to do is enter you site name, your username and your password. You will get:
That’s it. Now you can F5 your App, and it will be deployed and will also be debuggable on a non-development site, or in my case a PWA site collection. A small app that will load all Projects from my Project Site collection. Nothing fancy, just an example. Have fun!

Solved: Several Windows 8 Apps do not start

Yesterday, I was trying out some of the new apps that became available after the official Windows 8 launch last week. The 2 apps that I was looking for was Lync and Skype. So, off to the Windows 8 store, a small search and a few seconds later I had the apps.

Only there was one small problem. Not one of the apps was able to start correctly. After clicking (no touch on my corp machine) on the Lync and Skype tiles, the application started, but after 1 or 2 seconds, I was returned to my start screen. When I looked at the event log, I found the following traces:

And also (caused because the app was in a ‘lost’ state)

That’s quite annoying, but I found the solution. The main reason that several apps don’t work is the fact that I’m actually running Windows 8 N (Enterprise). Let me quote from the Microsoft website what this ‘N’ is all about:

Windows 8 N editions have been designed to give you most of the features of Windows 8—with the addition of choice. There are three Windows 8 N editions: Windows 8 N, Windows 8 Pro N, and Windows 8 Pro Pack N. The N editions of Windows 8 allow you to choose your own media player and software required to manage and play CDs, DVDs, and other digital media files. If you choose to use Windows Media Player 12, downloading it, along with related software, is free. Windows 8 N editions are available for customers who live in countries that are part of the European Economic Area, Croatia, and Switzerland.

For one reason or another, the 2 apps that I tried do need some media features that are not there with Windows 8 N. So all I had to do was download the required media things. Microsoft actually provides a ‘Media Features Pack For Windows 8 N‘. You can download the installer here. After installing this package (and a reboot!) my apps were just running fine.

Have fun with Windows 8! Thanks for reading.

Note: I don’t have any experience with Windows 8 development, but perhaps, developers, could you please add a check on the App launch to find out if the required components are available on the system? Would be awesome!