BracketShow


Custom nuget feeds with Visual Studio Online Build

So I was working on DayTickler, and we suddenly decided to start using Xamarin controls from Telerik(Progress) and Syncfusion. Traditionally, that usually meant downloading the installer and then referencing the proper assemblies from the local drive. Another workflow was to copy the assemblies to the project directory in some sort of “lib” folder so that those assemblies could be used in a CI environment.

Fast forward to 2016  and we have something called Nuget, so i tried using these to achieve the same objective. The first was to add the two nuget feeds to Visual Studio’s Nuget configuration screen. Easy enough and from there, i was able to provide my Telerik credentials (their feed is private) and install the packages. Yay !

But when you commit to Visual Studio Online, there is no way to build because it would now fail on package restore.

The solution is to:

1 – Create a nuget.config file in the solution so that the build server knows where to download nuget feeds from:

2 – Open your build definition, and in the “Feeds and authentication” section, go point to your nuget.config file:

3 – Press “+” near “Credentials for feeds outside the account/collection”, and add the appropriate details.

 

That’s it ! worked like a charm and there is a “Verify connection” button to ensure all is good.


For enterprises, creating a web site that can link to files stored locally to work with “desktop apps”

One of my clients wanted a way to interact with local files (open folders, launch the associated application) from a web page. In this way, they could construct home page for the user and link to “local files” the same way as if they were on the internet.

This worked using IE (not Chrome nor Edge) through the file protocol. You could effectively do this :

<a href="file://t:\data">Data directory</a>
<a href="file://t:\data\file.txt">text file</a>

And the web page (on IE) would render two links, which would either open the folder in explorer or the file in notepad.

How would you fix this problem with Chrome and Edge ?

What we have prototyped is the creation of a UWP app that registers two URL protocols. Then you simply use these protocols in your web page and the UWP app will handle the request and do something, effectively bridging the gap between web and desktop…

Here is the updated HTML:

<a href=”myAppOpenFolder://t:\data”>Data directory</a>
<a href=”myAppOpenFile://t:\data\file.txt”>text file</a>

Once that is done, you need to create a new UWP app and register your new protocol declarations in the manifest, it should look like this:

<Extensions>
 <uap:Extension Category="windows.protocol">
 <uap:Protocol Name="myAppOpenFolder">
 <uap:DisplayName>myAppOpenFolder</uap:DisplayName>
 </uap:Protocol>
 </uap:Extension>
<uap:Extension Category="windows.protocol">
 <uap:Protocol Name="myAppOpenFile">
 <uap:DisplayName>myAppOpenFile</uap:DisplayName>
 </uap:Protocol>
 </uap:Extension>
 </Extensions>
 </Application>
 </Applications>

Once the manifest is done, you simply handle the situation in you app.cs:

protected override void OnActivated(IActivatedEventArgs e)
{
if (e.Kind == ActivationKind.Protocol)
{
var protocolArgs = e as ProtocolActivatedEventArgs;

if (protocolArgs.Uri.Scheme == “myAppOpenFolder”)
{
Windows.System.Launcher…. (protocolArgs.Uri);
}
else if (protocolArgs.Uri.Scheme == “myAppOpenFile”)

{
Windows.System.Launcher…. (protocolArgs.Uri);
}

base.OnActivated(e);
}
}

 


Understanding NetStandard

I was working on DayTickler and authentication when the latest Azure Mobile Client was released. Being fearless, i decided to upgrade.

Turns out the new version of the nuget doesn`t support pcl, but netstandard. No problem, let`s upgrade everything to netstandard, i need it for things like the latest AutoMapper anyways.

NetStandard is the new name for portable libraries. They are not built X time for each platform but offer binary compatibility for each platform. For example, uap10 implements netstandard 1.4, meaning that any UWP project can target libraries of type netstandard 1.4 because it provides and implementation of all the 1.4 level api…

It`s really complicated, but i always go back to this post, mainly for this table :

.NET Standard 1.0 1.1 1.2 1.3 1.4 1.5 1.6 2.0
.NET Core 1.0 1.0 1.0 1.0 1.0 1.0 1.0 2.0
.NET Framework (with tooling 1.0) 4.5 4.5 4.5.1 4.6 4.6.1 4.6.2
.NET Framework (with tooling 2.0 preview) 4.5 4.5 4.5.1 4.6 4.6.1 4.6.1 4.6.1 4.6.1
Mono 4.6 4.6 4.6 4.6 4.6 4.6 4.6 vNext
Xamarin.iOS 10.0 10.0 10.0 10.0 10.0 10.0 10.0 vNext
Xamarin.Android 7.0 7.0 7.0 7.0 7.0 7.0 7.0 vNext
Universal Windows Platform 10.0 10.0 10.0 10.0 10.0 vNext vNext vNext
Windows 8.0 8.0 8.1
Windows Phone 8.1 8.1 8.1
Windows Phone Silverlight 8.0

 

Also, if, along the way, you wish to include non netstandard libraries in your netstandard library,  you can modify your project.json like this :

“frameworks”: {
“netstandard1.4”: {
“imports”: [ “portable-net45+win8+wpa81” ]
}
}

It helps !


Microsoft Build 2017 WishList

Microsoft Build 2017 is right around the corner, with keynotes streaming live in about 24 hours !

This is my reading of the Windows ecosystem, and what i would like to see announced… My new thinking is that an operating system is just a management thing, the APIs are all similar now… there is no reason i should be choosing my OS based on the apps available but rather how i want to manage it. Oh, and the web with PWA apps is going to kill it all…

The big messages are :

  • Make Windows shine as a managed platform.
  • Every Windows device should be an Android device ++. We need the apps.
  • Every desktop-laptop Windows device should be a Linux device ++, this will bring in the entire academic and scientific public to Windows.
  • Make Windows cloud first, mobile first. Make it sync my life. Make it replace my phone. force a eSIM in every device and provide the service. Help us get ride of our telcos with take our money and offer zero innovation.

Here is the detailed list…

  1. Win32 Apps can now be on the store, and run everywhere windows can (desktop, laptop, tablets with ARM and Intel), you require a traditional Windows license to run Win32 outside of the store.
  2. UWP for redstone3  is the new API to build professional apps. The API surface will be augmented so that it is years ahead of any other API we have to build apps. It is 3d ready, mobile ready, cloud ready, sync ready… Works everywhere like RPI, desktop, laptop, tablets, phones, xbox, smart tvs.
  3. Xamarin is the way to build cross platform stuff using Microsoft technologies. These apps will shine on Windows and Xamarin will provide some sort of universal platform service API to compete against the Google PLAY specific APIs.
  4. Android apps can be downloaded from the Windows Store on any platform and things just work. Developers only need to submit their APK to the Windows Store. If you can’t beat them, join them. Microsoft has to differentiate itself by offering a better management platform and THE API to develop professional apps. An Android page exists in the settings app to manage the interoperability.
  5. A single shell that adapts to every device seamlessly (CSHELL), extend Continuum.
  6. An interface that doesn’t make me jealous of iphones (NEO).
  7. The development pace for EDGE will augment and will now be distributed in the store so that PWA is fully supported by redstone3. Also web sites will be deeply integrated into the OS and will not feel any different than UWP apps.
  8. EDGE will be enhanced to become the premier note taking and research tool. Complete integration with OneNote.
  9. Skype for UWP actually made usable and will integrate functionality for Skype for business.
  10. Skype will offer SkypeIn to everybody on earth so that i can answer the phone from my phone, laptop… With good rates on roaming and data. All Windows tablets should be eSIM compatible.
  11. Office will get it’s act together and put in the store great apps, current mobile office apps will remain as readers and light editors for the road.
  12. LXSS (linux subsystem for windows) will become official (not just a developper feature) in Windows PRO and have a it’s own page in the settings app.
  13. When you launch a feature, launch it globally
  14. Make Cortana able to have conversations, enhance it with bots.
  15. Indirect displays (Display link based USB monitors) will be made super efficient (this is a pet peeve since the new driver architecture)

On the hardware side…

  1. Come out with a small dongle that costs 50$, feels like a Roku with a remote like the Roku, and supports miracast, dlna – upnp, EDGE browsing with the wireless air mouse remote, continuum and UWP apps. Call it the YBOX or something. Make it do everything the XBOX can (minus heavy gaming) for 50$. The YBOX is even integrated in monitors and TVs.
  2. Come out with a surface phone that is the center of my life. It has an accessory called Surface which is basically a tablet (8, 10 or 12 inches) and a pen which is basically a second screen for my phone. Requires a Surface Phone to work otherwise you are limited to browsing the web with EDGE via WIFI. Can display any app that my phone is running (win32, UWP, android, PWA) via some Continuum technology. Can extend to my other Windows devices in seamless way.
    For example I turn on my laptop and see Visual Studio in my task bar (running on my laptop) as well as Facebook (an android app running on my phone but being broadcast to my laptop) as well as Twitter (running on my laptop but state being pushed from phone because the apps are both UWP and can sync state).
  3. Keep the Surface Pro, Surface Laptop and Surface Studio lineup as is…

On the media side…

  1. Support live tv and radio by region for a base streaming fee (5-6$ per month), allow plugins for cable providers (i.e. Videotron, Bell or even Netflix)
  2. Support magasines and newspapers as well as ebooks in the store, have an all you can read package for 10-15$ per month).
  3. Google gobbled up Songza… get your hands on DI.FM, evolve it a bit and offer it everywhere for a base streaming fee (3-4$ per month).

 


SQL and extensibility

Having a schema in SQL defeats extensibility – and there is no way i am having columns named “ExtensibleColumn1, ExtensibleColumn2″…

I have come to embrace storing JSON directly in the database, quite easy actually as JSON is simply text…

The bigger problem though was how to extract specific data from this JSON, or filter on it… and here is the solution: OpenJSON !

 


SQL Magic row to column concatenation

Imagine you have a very simple data model with two tables, Invoice and InvoiceTaxes.

When creating a report, i would like to see all invoices and the taxes applied to each, but not as a 1 to n relationship, but rather as a sting concatenation.

i.e.

Invoice1, “TPS”
Invoice2, “TPS, TVQ”
Invoice3, “TVH”

I went around and found a bunch of different ways on StackOverflow, everyone single one looking super duper complicated…

Then i found something called String_AGG, and it’s available on Azure SQL right now !

select invoiceid,
(select string_agg(taxname, ', ') from invoiceTaxes where invoiceTaxes.invoiceID = invoicesid) as Taxes
from invoices

Voilà !


Windows 10 Creator`s update

I have been using the new Windows 10 Creator`s update on my main laptop now for a few days, and things are pretty smooth. The upgrade process didn`t break anything…

The good :

  • Taking screen shots and putting them to the clipboard is not built in. It is the same combination as OneNote used. windowKey + Shift + s
  • Edge seems fast
  • Paired with the latest DisplayLink drivers (8.2) my system doesn`t get as slugish as before
  • The tv and movie apps has a windows on top mode so i can catchup on movies as i work without taking half the screeen
  • Skype is out of preview and actually kinda works. Paired with my phone i can now answer SMS from the desktop without having to take my phone and unlock it each time

The bad :

  • Someone decided that the new window on top feature in skype should activate as soon as skype loses focus. This is horrible when trying to answer email on a second screen when watching a demo which  is streamed to skype.

This is not meant as an exhaustive list of all of the new features, but mainly what i have used a lot since the I have installed the new version.

 


Application Insight Availability

I just helped put a rather big system in production. There are always a lot of things to do and we lately turned on availability monitoring with Azure Application Insights.

Since we knew we were going to use this feature, we had added a “ping” controller to our API tier. This controller had a single method called “IsAlive”. It returns a 200 if it can access the database and a 400 if not.

5 minutes after we turned on monitoring, we were able to visualise the latency from 5 spots on the internet likely to have clients using the system. If something fails, we get alerts thrown that tell us when the system falls and when it gets back online.

Doing this a few years ago would had required specialised tools and now, it is a few clicks away in all of the major platforms. Use it, it’s five minutes to ensure you are warned if a problem arises.


Azure and Memory Leaks

I know I know, how can i have memory leaks, you’ve got a garbage collector in that fancy .net don’t you ?

So this is the second project i work on where we find memory leaks in production. The first one was a third party library that didn’t release a bitmap when it generated reports using it, the second one wants to hold on to Entity Framework contexts after they’ve been used.

Not much i can do about the first case cause i don’t have access to the objects and can release them, but the second one is directly in our code.

The thing is, as soon as Entity Framework context goes out of scope, it should release it’s memory -it’s all managed, and IDispose juste releases the memory deterministically.

Now the fun part, with IOC and DI containers, we tend to receive our references and the container itself manages the lifetime. So if our container is badly configured, we depend on the container to release objects (so they can garbage collected) and just lost the ability to get garbage collection based on out of scope…

DI containers are fun and fancy, and a real plus when you are testing, but PLEASE ensure they are configured correctly !

The first memory leak was hosted on premise with IT people who had no idea how to take a memory snapshot, that was hard.

Azure on the other hand, has all of this stuff built-in, i was completely blown away at how much diagnostic tools were build into the plateform. It’s called “Diagnostics as a Service”. Go discover it !