FECPAKG2 is a complete remote-location parasite assessment tool. The FECPAKG2 system combines a field testing kit with software to manage and submit tests for analysis. The current FECPAKG2 software was written for WPF and published as a ClickOnce application for ease of deployment and updating. With the proliferation of Windows 10, especially on devices suitable for operation in the field, Techion Group wanted to be able to take advantage of the distribution and updating capabilities of the Windows Store – but without rewriting their application. With the new desktop bridge capabilities, it was (nearly) as simple as adding a new project type in Visual Studio and then building the project.

![FECPAKG2 Testing Kit](/images/2017-06-15-FECPAKG2/fecpakg2-kit.png)

Core Team

  • Duncan McGregor (@redwolvx) – IT Manager & Senior Developer, Techion Group Ltd
  • Regan Murphy (@nzregs) – Senior Technical Evangelist, DX, Microsoft NZ

Customer profile

FECPAK International Limited was established in Dunedin, New Zealand in 1993 by Greg Mirams, primarily the company supplied the FECPAK unit, an on-farm tool allowing farmers to undertake their own internal parasite assessments on their stock, with the later addition of the SPORPAK unit allowing on-farm monitoring of Facial Eczema.

In 2006 FECPAK International became a business unit of PGG Wrightson supplying its products and services to the corporate group, developing a high throughput laboratory with the ability to process samples for the monitoring and control of Internal parasites and Facial Eczema. In July 2010 FECPAK was purchased back from PGG Wrightson and Greg Mirams formed a new company, Techion Group Limited; incorporating the FECPAK International products and services into the new business. Techion meaning Technology in Action, has been established to work with a wide range of industries to ensure technological products and services are delivering on-farm and in-lab advancements.

Techion Group Limited is committed to continual development and improvement of the FECPAK and SPORPAK systems allowing its utilisation in even the remotest locations on many different species of animals as well as humans. Techion’s new revolutionary technology, FECPAKG2 and SPORPAKG2 can be utilised for many other laboratory tasks, providing onsite and offsite microscope replacement, full sample tracking and reporting, global data access and acquisition, multi-professional reporting, all in a fully auditable system.

Problem statement

Windows 10 brings about a new opportunity for managing the deployment and updating of applications for both business, and consumer apps. FECPAKG2 has traditionally been published using the ClickOnce technology which allows for simplified install over the network or internet, self-updating, and application isolation which prevents the installation clashing with other installed apps. While this has worked well for distribution and updating of the FECPAKG2 application, there are advantages of doing this via the Windows Store instead.

ClickOnce features such as self-updating, simple one-click deployment, and app isolation come standard with Windows Store Apps. One of the new capabilities that comes with the Windows Store distribution channel, however, is the ability to integrate with management and deployment tools like Microsoft Intune or other MDM (Mobile Device Management) based solutions. These solutions make it easier for an organization to manage devices that are not typically connected to the corporate LAN. By having apps available in the Windows Store means they can also be made available for the Windows Store for Business which adds even more features targeted at simplifying ease of deployment, updating, and management, of Apps on Windows based devices.

To fully take advantage of the Windows Store, applications typically must be re-written as UWP (Universal Windows Platform) applications. That can be quite time consuming. With the Desktop Bridge technology, however, it becomes easy to bring an existing application to the Windows Store – often without writing a single line of code.

Solution, steps, and delivery

With the Desktop Bridge, Techion Group could bring FECPAKG2 to the Windows Store rapidly. Because the application had already been brought to the latest version of Visual Studio, adding the Desktop Bridge was (nearly) as simple as: 1) Adding an appxmanifest.xml file to the existing solution 2) Run the command line tool to generate an Appx package

A walkthrough of these steps can be found in the Package a desktop app manually article which is part of the Desktop Bridge documentation. An alternative option, just as simple, would be to use the Package a .NET App using Visual Studio method.

FECPAKG2 in action

The image mark-up review screen is shown below. This is where the technician identifies parasites and marks up the image, using the mouse and the controls on the right pane. The mark-up data is submitted to the database and provides the foundation for sample reporting, and location reporting.

![FECPAKG2 Image Mark-up Review Screen](/images/2017-06-15-FECPAKG2/fecpakg2-imagemarkup.png)

The application is available in the Windows Store, but you’ll need to be an FECPAKG2 customer to use it.

Get it on Windows 10

Issues encountered, and solutions found

Cannot install an unsigned Appx bundle

While the FECPAKG2 application packaged successfully and an Appx bundle was generated, that bundle was unable to be deployed on test machines as the packages were not signed. We had to sign the packages manually. Note that apps are automatically signed when deployed to the Windows Store, so manually signing the appx packages need only apply to app testing or sideloading scenarios.

![FECPAKG2 Installation Failed - Not Signed](/images/2017-06-15-FECPAKG2/fecpakg2-installfailed.png)

Fixing this was quite simple. Using the Visual Studio Developer Command Prompt, it is as simple as running a single command to sign the resulting appx package using the signtool app that is deployed as part of Visual Studio:

Code Snippet 1 – Using the signtool to sign appx package

signtool sign /t http://timestamp.certprovider.com /n "Company" /r "CertProvider" /v /fd sha256 "C:\local\Desktop-Bridge\Application-1.0.2.0.appx"

A key thing to remember here is that your Identity->Publisher property needs to match that on your code signing certificate. If you need to generate a code signing certificate for testing, then follow these instructions.

To save time you can integrate the packaging and signing of the appx by adding a new configuration to your solution, and adding an AfterBuild event into your .csproj file like below:

Code Snippet 2 – Configuring for automatic build and signing of appx

  <Target Name="AfterBuild" Condition=" '$(Configuration)' == 'WindowsStore'">
    <GetAssemblyIdentity AssemblyFiles="$(TargetPath)">
      <Output TaskParameter="Assemblies" ItemName="myAssemblyInfo" />
    </GetAssemblyIdentity>
    <Exec Command="&quot;C:\Program Files (x86)\Windows Kits\10\bin\10.0.15063.0\x86\makeappx.exe&quot; pack /d $(OutDir) /p &quot;C:\local\Desktop-Bridge\Application-%(myAssemblyInfo.Version).appx&quot;" />
    <Exec Command="&quot;C:\Program Files (x86)\Windows Kits\10\bin\10.0.15063.0\x86\signtool.exe&quot; sign /t http://timestamp.certprovider.com /n &quot;Compnay&quot; /r &quot;CertProvider&quot; /v /fd sha256 &quot;C:\local\Desktop-Bridge\Application-%(myAssemblyInfo.Version).appx&quot;" />

Writing files to an unsupported location

The other problem that was encountered, and resolved, was writing files out to the filesystem. This was occurring for images that were temporarily stored while being manipulated, and for log files. In the Win32 application, these files were typically being written to a directory inside of the execution directory. In the Desktop Bridge version of the application these file writes were causing an exception:

System.UnauthorizedAccessException occurred
  HResult=0x80070005
  Message=Access to the path 'C:\Program Files\WindowsApps\Techion.FECPAKG2.Lab_1.0.0.0_x86__q6kzdpasp4an2\imgs' is denied.
  Source=mscorlib 

This was fixed by changing the code from:

string basePath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location);
string imgsPth = System.IO.Path.Combine(basePath, "imgs");

to:

string basePath = string.Format(@"{0}\ApplicationSpecificFolder", Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData));
string imgsPth = System.IO.Path.Combine(basePath, "imgs");

which instead wrote the files to a subdirectory contained within the special ApplicationData folder.

Next Steps

Packaging the application for deployment via the Windows Store was just the first step. Using the Desktop Bridge makes it possible to bring additional features to the Windows Store version of the application by incorporating additional functionality like Live Tiles or Push Notifications. There are several UWP APIs that are available to a Desktop Bridge packaged app that can be found in the documentation and code samples.

Conclusion

The FECPAKG2 desktop application was easily packaged for the Windows Store, with only a very minor code change. Adding a simple change to the project file meant that Techion Group could automate this package creation during the build process which could then be integrated into a continuous delivery pipeline. Based on the success of converting FECPAKG2, additional applications in the FECPAKG2 suite will now also be queued for conversion. For customers that are using Windows 10, this will make deploying and maintaining the application much simpler – especially as these devices are typically out in the field – mobile – and not part of a typical Windows Domain deployment.