.NET Standard Libraries and NuGet Package Wizard

Generating NuGet Packages from Visual Studio 2017

A few days ago, Microsoft has released  .NET Standard 2.0, which is the new dreams-come-true platform for libraries. Additionally, Portable Class Libraries (PCL) have since also been deprecated. Therefore, it’s about time to port my existing libraries.

In addition, also Visual Studio 2017 Version 15.3 with full support for .NET Standard 2.0 was released, as well as the latest Windows 10 Fall Creators Update Preview SDK. So, let’s get started!

.NET Standard vs. UWP

However, it turns out that UWP doesn’t yet support .NET Standard 2.0. For the UWP platform, the latest supported .NET Standard version is still 1.4, which is considerably less powerful.

Attempting to reference a .NET Standard 2.0 library from an UWP app leads to errors, including the following that gives it away:

Upgrading the UWP project to the latest SDK Preview for the Windows 10 Fall Creators Update Build 16257 doesn’t change anything; both the SDK and the new Visual Studio 2017 version 15.3 can not yet use .NET Standard 2.0 in conjunction with UWP. According to Microsoft, that will be coming soon with the next UWP version.

.NET Standard 1.4 … for now!

As such, the latest possible version of .NET Standard that also supports UWP is v1.4. As this older version has the same platform compatibility (Linux, Mac and iOS and Android through Xamarin), I saw no harm in keeping the NFC library at the .NET Standard 1.4 for now.

A new library version based on .NET Standard 2.0 can be released later once the tooling is complete; even though that will most likely limit the use of that specific version to the Windows 10 Fall Creators Update. Which would mean that for maximum library compatibility, it’s better to stay at .NET Standard 1.4, or to include both versions into the same NuGet package. We’ll see.

Creating NuGet Packages through Visual Studio

Another convenient new feature of the latest Visual Studio version is that it now supports creating NuGet packages. Through a convenient visual editor interface, it’s now a lot easier for library authors to create the required .nuspec  files that define the library properties.

Generating NuGet Packages from Visual Studio 2017

However, it wasn’t so easy after all. Several things are interesting and important to know:

Title / Product

So far, the .nuspec  files usually had a <title>  tag; I had that defined as:

This tag is not present in the editor. However, Visual Studio offers a <Product>  tag, so I put the text there instead.

When building the project, Visual Studio generates the .nuspec  file in the /obj/  directory.

Looking into this file, it’s curious to see that the generated file neither has a <title> , nor a <product>  tag. The name of the library simply isn’t present in the generated file; only the package ID is used. This issue has already been reported to the Visual Studio team and is being investigated.

The NuGet web site still shows the title on the package web page. However, within the NuGet Package Manager in Visual Studio, the title is gone:

How Libraries are shown within the NuGet Package Manager of Visual Studio

The nuspec file documentation still lists that the <title>  is the human-readable name that’s also used within the Visual Studio NuGet Package Manager.

This situation isn’t ideal, as the package ID (currently “NdefLibrary”) can’t be changed easily. The package ID of my library doesn’t include the term “NFC”. As Visual Studio seems to ignore the package title, in the search other packages with a handful of downloads are ranked higher than the NdefLibrary:

NuGet Package Manager Search Order

I’m wondering if there is a way around this. For now, I’ve kept my manual .nuspec  file with the title, so that it’s shown at least on the NuGet website. I’ve also reported the issue to the Visual Studio Feedback tool.

Assembly Neutral Language

Another tricky thing is the Assembly Neutral Language. By default, the property is not set in the Visual Studio wizard. And you won’t notice that anything is missing for a long time: you can package the library, publish it to NuGet, reference it in a UWP app and test that app locally. Only when you try to package the app for submitting to the store, you will suddenly get the error message:

That’s a bit of a surprise. The wizard interface of Visual Studio is a language drop down, so simply choose “English”. The value is saved in the .csproj  file, where it is then written as “en”.

Just make sure you always select the neutral language, so that you don’t run into issues much later on! See my Visual Studio feedback report for further details.

Symbol Packages

The third issue with the auto-generated nuget packages is that they only contain the final .dll  file, but not the .pdb  file that libraries should publish to the symbol server to make debugging easier for library users.

In the ideal case, the library package also includes the source code, so that developers that have issues can directly see what’s happening within the library.

The code in the .nuspec  file needs to be written manually in order to include these additional items – the auto-generated version by Visual Studio would only include the .dll , nothing else.

The relevant part from the NFC / NDEF library .nuspec :

My Visual Studio UserVoice suggestion for improving the wizard is hereplease vote if you also feel this could be improved!

Publishing the Package to NuGet Servers

Now that the NuGet package is created, you can finally publish the package to the NuGet servers.

The instructions for publishing a package including a symbol package for debugging are not fully up-to-date, however. The current NuGet versions always require specifying a source. They don’t default to the NuGet servers anymore.

In case you have two packages in the same directory – the normal one that goes to the NuGet server (NdefLibrary.4.1.0.nupkg), as well as the symbol package (NdefLibrary.4.1.0.symbols.nupkg), the tool will automatically find the symbol package and push that to the corresponding server without you having to specify that.

NuGet Package Files

Pushing the library *and* the symbol package therefore works with the following command – also see my comment at the Microsoft Docs:

It is a bit strange that the NuGet server has to be specified, but the symbols server is then implicitely assumed. However, as that’s what will be intended in nearly all use cases, it’s fine for me.

Within a few minutes after publishing, the new library is live on the NuGet and the symbol servers!

Resoving Unity Scene Merge Conflicts with UnityYAMLMerge (Smart Merge) and TortoiseGit

When working on Unity HoloLens-projects in teams, sometimes merge conflicts in Unity scenes are unavoidable. Even though the Unity scene file format is text-based, the automatic merge of a standard GIT merge tool wouldn’t always correctly recognize the changes from different versions.

Luckily, Unity comes with a merging tool that is specialized on scene files: UnityYAMLMerge / Smart Merge. However, it’s not straight-forward to integrate into a workflow. Continue reading “Resoving Unity Scene Merge Conflicts with UnityYAMLMerge (Smart Merge) and TortoiseGit”

Improving User Experience for Public Transport Departure Monitor

Raspberry Pi Public Transport Departure Monitor - Yellow: Medium departure time (better hurry!)

The public transport departure monitor has been incredibly helpful – it dramatically cut down the waiting times at the bus stop, as it allows to leave the apartment exactly on time to reach the bus.

The setup is based on a Raspberry Pi with a simple LCD display. I’ve combined this with a motion detecting power plug, so that the Raspberry is only active when I’m actually in the entrance area of the apartment. As such, the energy consumption is minimal. Continue reading “Improving User Experience for Public Transport Departure Monitor”

Using Netgear Arlo Security-Cameras for Periodic Recording

Automating Arlo Camera Recording

The Arlo security camera by Netgear is one of the few cameras that doesn’t need a power supply, so is easier to use outdoors. The cameras have motion-sensing integrated and upload a short video sequence around the motion event to the Netgear backend. Great about the Arlo ecosystem is that this is possible with the free plan as well; you can access the recordings of the last 7 days already with the free basic plan.

For my use case, I wanted to also take periodic pictures / recordings. These can then later be stitched together for a time-lapse. Continue reading “Using Netgear Arlo Security-Cameras for Periodic Recording”

How to Read the Battery Level of Bluetooth LE Devices

Microsoft Surface Dial

At the Microsoft Build Tour in Vienna, I had the opportunity to present an enhanced version of the Bluetooth Beacon talk. With the Windows 10 Creators Update, Microsoft released a massive update to the Bluetooth LE capabilities of the OS. This finally allows developers to use the full potential of modern Bluetooth scenarios, including sensors, wearables and beacons.

At Build 2017, Microsoft released three new sessions explaining the capabilities of the new APIs:

  1. Intro to Bluetooth LE Explorer
  2. Unpaired Bluetooth LE Device Connectivity
  3. Bluetooth GATT Server

Even though the sessions reference example code and blog posts that should have been released together with the session recordings, still none of that is available so far. That gave me the opportunity to explore the new APIs based on the short documentation overview page and the videos. Continue reading “How to Read the Battery Level of Bluetooth LE Devices”

More Realistic HoloLens Spectator View Photos

HoloLens Spectator View - Photoshop - Screen - Darkened

When capturing a Mixed Reality scene through HoloLens Spectator View, the resulting photos and videos look amazing. But how to make them more realistic? The right blending mode in Photoshop helps.

Are Spectator View Photos Real?

Of course, the captured Spectator View photo is in many ways different to what you see in HoloLens. First off, it’s only 2D; in the HoloLens, you’d see a real 3D hologram. In this area, the live HoloLens view is much more impressive.

On the other hand, the actual resolution and field of view of the HoloLens is less than a (potentially) 20 Megapixel+ Unity rendering that shows holograms all around you. But the field of view is difficult and somehow unnecessary to simulate as we’re looking on the scene from a 3rd person perspective. Continue reading “More Realistic HoloLens Spectator View Photos”

Event: Mobile Developer After-Work #15: Next Generation Apps

Mobile Developer After-Work #14

Mobile Apps are no longer simple tools and games. They have grown to amazingly complex systems. Which ingredients are necessary to successfully develop a next generation app?

You will need Artificial Intelligence / Machine Learning. Only the best performance will satisfy your customers – or do you want to wait more than a few seconds in a mobile app? How can you visualize your user interface with HoloLens?

At the #mdaw15, you will learn how to develop and plan such apps with modern frameworks. Join the next After-Work event in St. Pölten for free at https://mobility.builders/

What is a Mobile Developer After-Work Event?

#mdaw events are mixtures of conferences with more casual meet-ups. Different expert speakers approach an overall topic from diverse perspectives. Afterwards, there’s plenty of time for networking and discussion amongst attendees – with snacks and drinks, of course.

The events target mobile developers and decision makers. The goal is to dive deeper into relevant and already known topic areas, as well as to keep up to date with the constantly evolving and changing toolset of the mobile world.

In the meantime, we can look back to 14 previous #mdaw events. Topics so far included business apps, digital healthcare, Xamarin, user experience or a Refugee Hackathon. We’re organizing the events with technology partners like Microsoft, Oracle, IBM, the City of Vienna and many others.

The community has grown to around 500 attendees, and we continue to get more and more developers on board with each event!

Together with Helmut Krämer, I’ve founded the community in 2013 and am proud that it’s still around. We’ve had a tremendous impact on the Austrian developer community so far. With the upcoming #mdaw15, we’re extending the reach geographically and host our first event outside of Vienna, to reach even more developers!

How to set up HoloLens Spectator View, Bonus – Troubleshooting

HoloLens Delete Space

Did you follow the blog post series on setting up Spectator View for HoloLens? The following issues frequently occured when testing Spectator View. To make your life easier, make sure you check these troubleshooting tips & tricks:

HoloLens Sharing Offset

Between your two HoloLenses, there can be some offset in the placing of the holograms. In one HoloLens, you can for example position your hologram directly on the table; on the second HoloLens, it’s one meter next to the table. Continue reading “How to set up HoloLens Spectator View, Bonus – Troubleshooting”

How to set up HoloLens Spectator View, Part 7 – Mixed Reality

HoloLens Spectator View - Sample Photo

In the final part of the HoloLens Spectator View series, I’ll add the final tweak to my sample project and show you what kind of photos the Compositor actually saves on your PC. Getting to this point has taken a lot more work than expected (+ a lot more blog posts, too!), but I still feel that the journey was worth it! You can finally get great photos and videos of the mixed reality experience on HoloLens.

Script Execution Order

Sending the updates didn’t work right away, so I searched for other changes that the sample does differently from my app that might be responsible. One such case was the Script Execution Order.

In Unity, the order in which scripts are initialized is arbitrary. When debugging, I found an issue that an instance of a class wasn’t available yet when a script wanted to access it. Continue reading “How to set up HoloLens Spectator View, Part 7 – Mixed Reality”