<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
  version="2.0">
  <channel>
    <title>Lucian's VBlog</title>
    <atom:link
      href="https://docs.microsoft.com/archive/blogs/lucian/feed.xml"
      rel="self"
      type="application/rss+xml" />
    <link>https://docs.microsoft.com/archive/blogs/lucian/feed.xml</link>
    <description />
    <lastBuildDate>Tue, 28 Jun 2016 04:47:06 GMT</lastBuildDate>
    <language>en-US</language>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <item>
      <title>Visual Studio Text Adornment VSIX using Roslyn</title>
      <link>https://docs.microsoft.com/archive/blogs/lucian/visual-studio-text-adornment-vsix-using-roslyn</link>
      <pubDate>Mon, 27 Jun 2016 22:52:20 GMT</pubDate>
      <dc:creator><![CDATA[Lucian Wischik, MSFT]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/lucian/?p=1575</guid>
      <description><![CDATA[A VSIX is a way to install plugins into Visual Studio. The kind of plugin I'm interested in right...]]></description>
      <content:encoded><![CDATA[A <em>VSIX</em> is a way to install plugins into Visual Studio. The kind of plugin I'm interested in right now is a <em>text adornment</em>. This lets you superimpose things (text, pictures, interactive controls) right on top of a code editor window.

It took me a frustrating day figuring out how to get started. This post is to save everyone else the frustration.
<ul>
	<li>Source code: <a href="https://github.com/ljw1004/blog/tree/master/VSIX/TextAdornmentVsix">https://github.com/ljw1004/blog/tree/master/VSIX/TextAdornmentVsix</a></li>
</ul>
&nbsp;

<strong>Install the Visual Studio SDK</strong>

Its official title is<em> Visual Studio Extensibility Tools</em>. Full instructions are <a href="https://msdn.microsoft.com/en-us/library/mt683786.aspx">here</a>. In a nutshell, quit VS and then do:
<ol>
	<li><span style="color: #0000ff">Control Panel &gt; Add Remove Programs &gt; Microsoft Visual Studio 2015 &gt; Modify</span></li>
	<li><span style="color: #0000ff">Common Tools &gt; Visual Studio Extensibility Tools &gt; Ok</span></li>
</ol>
&nbsp;

<strong>Install Roslyn SDK</strong>

Its official title is <em>.NET Compiler Platform SDK.</em>
<ol>
	<li><span style="color: #0000ff">Visual Studio &gt; Tools &gt; Extensions and Updates &gt; Online</span></li>
	<li><span style="color: #0000ff">Search for ".NET Compiler Platform SDK" &gt; install it, and restart VS</span></li>
</ol>
&nbsp;

<strong>Create a new VSIX project</strong>

Within Visual Studio,
<ol>
	<li><span style="color: #0000ff">File &gt; New &gt; Project &gt; Visual C# &gt; Extensibility &gt; VSIX Project</span></li>
	<li>This has created some files which we no longer need: <span style="color: #0000ff">delete index.html and stylesheet.css from your project</span></li>
</ol>
&nbsp;

<strong>Add references</strong>

Officially the way you're supposed to add a text adornment to your project is right-click on it &gt; Add &gt; New Item &gt; Visual C# &gt; Extensibility &gt; Editor &gt; Editor Text Adornment, which also adds some references. But I found it generated unhelpful references, so I'm adding references manually instead. In a nutshell:
<ol>
	<li><span style="color: #0000ff">Project &gt; References &gt; Add Reference &gt; Framework &gt; check <em>System, PresentationCore, PresentationFramework, WindowsBase </em>&gt; OK</span></li>
	<li><span style="color: #0000ff">Tools &gt; Options &gt; NuGet Package Manager &gt; General &gt; Automatically check for missing packages during build &gt; ensure this button is checked &gt; OK</span></li>
	<li><span style="color: #0000ff">Right-click on project &gt; Add &gt; New Item &gt; Visual C# Items &gt; Web &gt; JSON file, and call it "project.json"</span></li>
	<li><span style="color: #0000ff">Edit the project json and replace its contents with what's below</span></li>
	<li><span style="color: #0000ff">Right-click on project &gt; Unload Project</span></li>
	<li><span style="color: #0000ff">Right-click on project &gt; Reload Project</span></li>
	<li><span style="color: #0000ff">Build &gt; Build Solution.<span style="color: #000000"> This will produce warnings <span style="color: #339966">"Detected package downgrade System.Collections.Immutable from 1.2.0 to 1.1.37" -- </span><em><span style="color: #339966">these warnings are fine, and indeed necessary (see below)</span>.</em> But if there are <span style="color: #ff0000">errors about .NETFramework version</span>, that's because of a mismatch between <em>net46</em> specified in the project.json "frameworks" section and the .NET version in your Project &gt; Properties &gt; Application &gt; TargetFramework. The minimum target is .net46. You should make sure both are in sync.</span></span></li>
	<li><span style="color: #0000ff">Open source.extension.vsixmanifest &gt; Assets &gt; New, type = "MefComponent", source = "A project in current solution", and specify the project.</span></li>
	<li><span style="color: #ff0000">The NuGet version numbers are specific to an update to VS2015: the versions "1.3.x" and "14.3.x" listed here require at least Update3; you should switch to the older "1.2.x" and "14.2.x" for something that will run on Update2.</span></li>
</ol>
<pre>{
    "dependencies": {
        "Microsoft.CodeAnalysis": "1.3.0",
        "Microsoft.VisualStudio.LanguageServices": "1.3.0",
        "Microsoft.VisualStudio.Shell.14.0": "14.3.25407",
        "Microsoft.VisualStudio.Text.UI.Wpf": "14.3.25407",
        "System.Collections.Immutable": "1.1.37",
        "System.ComponentModel": "4.0.1",
        "VSSDK.ComponentModelHost": "12.0.4",
        "VSSDK.DTE": "7.0.4"
    },
    "frameworks": {
        "net46": { }
    },
    "runtimes": {
        "win": { }
    }
}</pre>
&nbsp;

Note 1: As much as possible I'm using <em>NuGet</em> references instead of the traditional <em>framework</em> references under AddReference &gt; Framework. I just prefer NuGet. I hope it'll make this project loadable/buildable even on a machine which doesn't have the Visual Studio SDK installed (but I haven't yet tried). Two of the packages are third-party ones written by the awesome .NET MVP <a href="http://tunnelvisionlabs.com/research">Sam Harwell</a>, which are basically just NuGet repackagings of parts of the VS SDK.

Note 2: For NuGet, I'm using the new-fangled <em>project.json</em> instead of <em>packages.config</em>. This is the faster cleaner way of referencing NuGet packages: with it, the References node in Solution Explorer only shows the 8 NuGets I'm referencing rather than their 20+ dependencies; it also means that NuGets are shared amongst all solutions, rather than being downloaded into a per-solution "packages" directory; and it means your project doesn't break when you change its directory relative to its .sln file. To activate project.json, you have to create the file, then unload your project, then reload your project, then nuget restore. Apparently <a href="https://blogs.msdn.microsoft.com/dotnet/2016/05/23/changes-to-project-json/">the roadmap</a> is for project.json to eventually be folded into .csproj, but until then, project.json is the best we can do.

Note 3: I have an explicit reference to an older version System.Collections.Immutable v1.1.37, which generates warnings every build. Had I removed this reference then it would have picked up the newer System.Collections.Immtuable v1.2.0 <span style="color: #ff0000"><em>which would cause the VSIX to fail</em></span>. The deal is that (as of VS2015 Update3) the Roslyn in your Visual Studio is still built upon v1.1.37, and if your project referenced a newer version, then the CLR would throw a <em>MethodNotFound</em> exception when it tries to enter a method that calls any of the ImmutableArray-returning Roslyn APIs.

&nbsp;

<strong>Add code for the Text Adornment</strong>

We'll add source code for a simple text adornment.
<ol>
	<li><span style="color: #0000ff">Right-click on your project &gt; Add &gt; Class</span></li>
	<li><span style="color: #0000ff">Replace its contents with the following.</span></li>
</ol>
I've written out the code with as few "usings" as possible, instead using fully-qualified names. That's to help you understand the code at-a-glance, to see which library each type comes from. Feel free to switch over to "usings" once you know them!
<pre>using System.Linq;

namespace MefRegistration
{
    using System.ComponentModel.Composition;
    using Microsoft.VisualStudio.Utilities;
    using Microsoft.VisualStudio.Text.Editor;

    [Export(typeof(IWpfTextViewCreationListener)), ContentType("text"), TextViewRole(PredefinedTextViewRoles.Document)]
    public sealed class TextAdornment1TextViewCreationListener : IWpfTextViewCreationListener
    {
        // This class will be instantiated the first time a text document is opened. (That's because our VSIX manifest
        // lists this project, i.e. this DLL, and VS scans all such listed DLLs to find all types with the right attributes).
        // The TextViewCreated event will be raised each time a text document tab is created. It won't be
        // raised for subsequent re-activation of an existing document tab.
        public void TextViewCreated(IWpfTextView textView) =&gt; new TextAdornment1(textView);

#pragma warning disable CS0169 // C# warning "the field editorAdornmentLayer is never used" -- but it is used, by MEF!
        [Export(typeof(AdornmentLayerDefinition)), Name("TextAdornment1"), Order(After = PredefinedAdornmentLayers.Selection, Before = Microsoft.VisualStudio.Text.Editor.PredefinedAdornmentLayers.Text)]
        private AdornmentLayerDefinition editorAdornmentLayer;
#pragma warning restore CS0169
    }
}


public sealed class TextAdornment1
{
    private readonly Microsoft.VisualStudio.Text.Editor.IWpfTextView View;
    private Microsoft.CodeAnalysis.Workspace Workspace;
    private Microsoft.CodeAnalysis.DocumentId DocumentId;
    private System.Windows.Controls.TextBlock Adornment;

    public TextAdornment1(Microsoft.VisualStudio.Text.Editor.IWpfTextView view)
    {
        var componentModel = (Microsoft.VisualStudio.ComponentModelHost.IComponentModel)Microsoft.VisualStudio.Shell.Package.GetGlobalService(typeof(Microsoft.VisualStudio.ComponentModelHost.SComponentModel));
        Workspace = componentModel.GetService&lt;Microsoft.VisualStudio.LanguageServices.VisualStudioWorkspace&gt;();

        View = view;
        View.LayoutChanged += OnLayoutChanged;
     }


    internal void OnLayoutChanged(object sender, Microsoft.VisualStudio.Text.Editor.TextViewLayoutChangedEventArgs e)
    {
        // Raised whenever the rendered text displayed in the ITextView changes - whenever the view does a layout
        // (which happens when DisplayTextLineContainingBufferPosition is called or in response to text or classification
        // changes), and also when the view scrolls or when its size changes.
        // Responsible for adding the adornment to any reformatted lines.

        // This code overlays the document version on line 0 of the file
        if (DocumentId == null)
        {
            var dte = Microsoft.VisualStudio.Shell.Package.GetGlobalService(typeof(EnvDTE.DTE)) as EnvDTE.DTE;
            var activeDocument = dte?.ActiveDocument; // sometimes we're constructed/invoked before ActiveDocument has been set
            if (activeDocument != null) DocumentId = Workspace.CurrentSolution.GetDocumentIdsWithFilePath(activeDocument.FullName).FirstOrDefault();
        }

        if (Adornment == null)
        {
            var line = e.NewOrReformattedLines.SingleOrDefault(l =&gt; l.Start.GetContainingLine().LineNumber == 0);
            if (line == null) return;
            var geometry = View.TextViewLines.GetMarkerGeometry(line.Extent);
            if (geometry == null) return;
            Adornment = new System.Windows.Controls.TextBlock { Width = 400, Height = geometry.Bounds.Height, Background = System.Windows.Media.Brushes.Yellow, Opacity = 0.5 };
            System.Windows.Controls.Canvas.SetLeft(Adornment, 300);
            System.Windows.Controls.Canvas.SetTop(Adornment, geometry.Bounds.Top);
            View.GetAdornmentLayer("TextAdornment1").AddAdornment(Microsoft.VisualStudio.Text.Editor.AdornmentPositioningBehavior.TextRelative, line.Extent, null, Adornment, (tag, ui) =&gt; Adornment = null);
        }

        if (DocumentId != null)
        {
            var document = Workspace.CurrentSolution.GetDocument(DocumentId);
            if (document == null) return;
            Microsoft.CodeAnalysis.VersionStamp version;
            if (!document.TryGetTextVersion(out version)) version = Microsoft.CodeAnalysis.VersionStamp.Default;
            Adornment.Text = version.ToString();
        }
    }
}</pre>
Note 1: VS text adornments normally only exist while they're in view on the screen. VS deletes the ones that have scrolled off-screen, and calls LayoutChanged when new lines get exposed so you can create adornments on-demand.

Note 2: Typical VS text adornments don't need to be "live", i.e. they can be created on demand and ignored after that. But I reckon that typical Roslyn-powered adornments will want to display stuff asynchronously. That's why I save a reference to the adornment that I created -- so my code can go back and update it at a later time (so long as it's still onscreen). If I did async work on a background thread then I'd need View.Dispatcher.Invoke to update the adornment on the UI thread.

&nbsp;

<strong>Run it!</strong>

Press F5 to run it. It should launch a new "experimental" instance of VS, with your VSIX installed into it. When you open any text document you should see the new adornment in yellow:

<a href="https://msdnshared.blob.core.windows.net/media/2016/06/adornment1.png"><img class="alignnone size-full wp-image-1595" src="https://msdnshared.blob.core.windows.net/media/2016/06/adornment1.png" alt="adornment" width="800" height="189" /></a>

&nbsp;

How did it know how to launch and debug your VSIX?
<ol>
	<li><span style="color: #0000ff">Project &gt; Properties &gt; Debug &gt; Start External Program</span> = "C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\devenv.exe": when you created your VSIX project, it was set by default to launch a fresh instance of Visual Studio</li>
	<li><span style="color: #0000ff">Project &gt; Properties &gt; Debug &gt; Command Line Arguments</span> = "/rootsuffix Exp": when VS is launched, it uses an "experimental hive" whose settings and extensions don't affect your main VS instance.</li>
	<li><span style="color: #0000ff">Project &gt; Properties &gt; VSIX &gt; Deploy VSIX content to experimental instance</span> = "checked": when you start debugging, VS will install your VSIX into that experimental instance.</li>
</ol>
Sometimes (e.g. when you uninstall the VSIX from the experimental instance) that final part won't work right. I think that the experimental instance gets stuck thinking "this is a VSIX that has been deleted". The fix for that is to open Windows File Explorer, delete "%userprofile%\appdata\local\Microsoft\VisualStudio\Exp" and "\14.0Exp" and "\roaming\Microsoft\VisualStudio\Exp" and "\14.0Exp". Then launch Regedit and delete all the HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\14.0Exp* keys.

What I like is, when I hit F5, for it to automatically load a test solution into that experimental instance of VS:
<ol>
	<li>Project &gt; Properties &gt; Debug &gt; Command Line Arguments = <span style="color: #0000ff">"c:\...\ConsoleApplication1.sln" /rootsuffix Exp</span></li>
</ol>
&nbsp;

I hope you have fun with Roslyn-powered editor adornments.

&nbsp;

<strong>Troubleshooting</strong>

<em>If it fails to hit breakpoints in your extension</em>, check that it's even loaded: when you've done F5, hit the pause button, open up Debug &gt; Windows &gt; Modules, and look for the name of your DLL in the list. You might need to load symbols. If it's absent from the list, verify that you've added your project as an asset to source.extension.vsixmanifest.

<em>If it crashes without even entering your method</em>, this is often caused by assembly version mismatches. For instance, if your DLL was built against version 1.3.0 of Roslyn, but the current instance of Visual Studio is running version 1.2.2, then any method which invokes a Roslyn API will throw a MissingMethodException or TypeLoadException <em>before the method is even entered.</em> You can test this by having a safe top-level method which only does "try {f();} catch (Exception ex) {Debug.WriteLine(ex.Message);}", and then move the proper body into f(). That way you'll at least find the MissingMethodException.

<i>If you're getting a MissingMethodException or TypeLoadException</i>, check you've referenced the right assemblies. To run in VS2015 you need to use the older System.Collections.Immutable v1.1.37. To run in Update2 you need to reference v1.2.x and v14.2.x of the NuGet packages.

&nbsp;]]></content:encoded>
    </item>
    <item>
      <title>Manifesto: a new fluid UI for desktop/LOB data-entry</title>
      <link>https://docs.microsoft.com/archive/blogs/lucian/manifesto-a-new-fluid-ui-for-desktoplob-data-entry</link>
      <pubDate>Tue, 14 Jun 2016 15:24:53 GMT</pubDate>
      <dc:creator><![CDATA[Lucian Wischik, MSFT]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/lucian/?p=1395</guid>
      <description><![CDATA[I'm fed up with clunky dialog-based UIs.

&nbsp;

Here are two apps, the Windows 7 Calculator...]]></description>
      <content:encoded><![CDATA[I'm fed up with clunky dialog-based UIs.

&nbsp;

Here are two apps, the Windows 7 Calculator and Windows 10 People App. <em>How many of you use Calculator by clicking on buttons with the mouse? And how many do free-form typing with the keyboard? </em>answer: everyone prefers the keyboard. I think that free-form typing is the Holy Grail of LOB apps. Dialogs look cluttered and force users to waste their time on UI rather than directly on data entry.

<a href="https://msdnshared.blob.core.windows.net/media/2016/06/calculator.jpg"><img class="alignnone wp-image-1405" src="https://msdnshared.blob.core.windows.net/media/2016/06/calculator-219x300.jpg" alt="calculator" width="183" height="250" /> <img class="alignnone wp-image-1415" src="https://msdnshared.blob.core.windows.net/media/2016/06/peopleapp-300x288.png" alt="peopleapp" width="269" height="258" /></a>

&nbsp;

&nbsp;

How about medical record software? Whenever I'm at the doctor's office, I peer over shoulders to see what they're using. In the consulting room, nurses and doctors usually seem to use <em>free-form text entry</em> to edit a template. The reception/billing system is usually a clunky dialog filled with too many buttons.

<a href="https://msdnshared.blob.core.windows.net/media/2016/06/vetinarygate.png"><img class="alignnone wp-image-1435" src="https://msdnshared.blob.core.windows.net/media/2016/06/ims-300x183.png" alt="ims" width="366" height="223" />   <img class="alignnone size-medium wp-image-1425" src="https://msdnshared.blob.core.windows.net/media/2016/06/vetinarygate-300x224.png" alt="vetinarygate" width="300" height="224" /></a>

&nbsp;

I want <em>free-form text-based </em><em>data entry</em>. (As for free-form text-based <em>commanding</em>, that's already popular. Here are some examples. The final one is an exciting new indie game called <a href="http://arstechnica.com/gaming/2016/06/duskers-is-spooky-space-exploration-with-a-command-console/">Duskers</a> where you control droids by text-based commanding.)

<a href="https://msdnshared.blob.core.windows.net/media/2016/06/game.png"><img class="alignnone wp-image-1495" src="https://msdnshared.blob.core.windows.net/media/2016/06/vscommand.png" alt="vscommand" width="215" height="118" /></a>  <a href="https://msdnshared.blob.core.windows.net/media/2016/06/vscode1.png"><img class="alignnone wp-image-1485" src="https://msdnshared.blob.core.windows.net/media/2016/06/vscode1-300x105.png" alt="vscode" width="337" height="118" /></a>
<img class="alignnone size-medium wp-image-1475" src="https://msdnshared.blob.core.windows.net/media/2016/06/monkey-300x188.png" alt="monkey" width="300" height="188" /> <img class="alignnone size-medium wp-image-1465" src="https://msdnshared.blob.core.windows.net/media/2016/06/game-300x176.png" alt="game" width="300" height="176" />

&nbsp;

&nbsp;
<h2>Example of free-form text-based data entry</h2>
Let's re-imagine the Windows 10 People app. How could it get away from dialogs, and embrace <em>free-form text entry</em>? Here's my attempt...

(1) A simple text-entry dialog with grayed out suggestions for what to type:

<a href="https://msdnshared.blob.core.windows.net/media/2016/06/pic1.png"><img class="alignnone size-full wp-image-1505" src="https://msdnshared.blob.core.windows.net/media/2016/06/pic1.png" alt="pic1" width="256" height="208" /></a>

(2) While you're typing, heuristics in the editor (e.g. "this line has overtyped the grey Name suggestion") infer that this is the name. The caption is updated to reflect this live while you type:

<a href="https://msdnshared.blob.core.windows.net/media/2016/06/pic2.png"><img class="alignnone size-medium wp-image-1515" src="https://msdnshared.blob.core.windows.net/media/2016/06/pic2.png" alt="pic2" width="255" height="208" /></a>

(3) When you hit ENTER to commit a line, the editor pretty-prints it. Pretty-printing is important to show what's been inferred:

<a href="https://msdnshared.blob.core.windows.net/media/2016/06/pic3.png"><img class="alignnone size-medium wp-image-1525" src="https://msdnshared.blob.core.windows.net/media/2016/06/pic3.png" alt="pic3" width="256" height="208" /></a>

(4) While I type the next line, more heuristics in the editor (e.g. "typing what looks like a phone number even though it's in the Address field") infer that this is the telephone number:

<a href="https://msdnshared.blob.core.windows.net/media/2016/06/pic4.png"><img class="alignnone size-medium wp-image-1535" src="https://msdnshared.blob.core.windows.net/media/2016/06/pic4.png" alt="pic4" width="256" height="208" /></a>

(5) When you hit ENTER, the editor pretty-prints it. In this case there are several kinds of phone number available, but the editor picked the most likely one and offered a way to change that (using the mouse or hitting Ctrl+Dot):

<a href="https://msdnshared.blob.core.windows.net/media/2016/06/pic5.png"><img class="alignnone size-medium wp-image-1545" src="https://msdnshared.blob.core.windows.net/media/2016/06/pic5.png" alt="pic5" width="255" height="208" /></a>

(6) I haven't shown any examples, but I'd also like the editor to show an <i>intellisense completion list</i> with suggestions of what it would expect and understand for you to type right now.

&nbsp;

&nbsp;
<h2><b>Manifesto: fluid UIs for text-based data entry</b></h2>
We should abandon clunky forms with lots of fields.

We should embrace free-form text entry.

This requires a <em>smart text editor</em> with natural language processing, heuristics, and most importantly <em>intellisense</em>.

&nbsp;

&nbsp;

&nbsp;

What's next? My friend Klaus Löffelman had a great insight. He observed that the same characteristics that make for free-form text entry are also well suited to dictation and voice control. You could use them for Cortana/Siri/Alexa. You'd actually use the same heuristics, NLP and AI in for free-form data entry as you do bots in Skype or Facebook Messenger.

Update: there was <a href="https://www.reddit.com/r/programming/comments/4oh2iu/manifesto_a_new_fluid_ui_for_desktoplob_dataentry/">some discussion on reddit</a>. I appreciated this comment from @grauenwolf: "<em>I have built several medical record applications over the years, and I can say without hesitation that there are lots of places where this would have been a perfect fit.</em>"

&nbsp;]]></content:encoded>
    </item>
    <item>
      <title>Async workflow [how to hibernate async methods, part 2]</title>
      <link>https://docs.microsoft.com/archive/blogs/lucian/async-workflow-2</link>
      <pubDate>Wed, 20 Apr 2016 23:18:27 GMT</pubDate>
      <dc:creator><![CDATA[Lucian Wischik, MSFT]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/lucian/?p=1375</guid>
      <description><![CDATA[Four years ago I'd written a post "How to hibernate async methods (how to serialize a task)". I...]]></description>
      <content:encoded><![CDATA[Four years ago I'd written a post "<a href="https://blogs.msdn.microsoft.com/lucian/2012/11/23/how-to-hibernate-async-methods-how-to-serialize-task/">How to hibernate async methods (how to serialize a task)</a>". I decided to dig it up and improve it. Here's what I can now write with it:

<code style="font-size: small">
<span style="color: blue">await</span> AlphaAsync().RunWithCheckpointing(<span style="color: red">"a.json"</span>);
<span style="color: green">// This kicks off the async method. But it allows the async method to
// serialize its state to disk.</span></code>

<code style="font-size: small"><span style="color: blue">await</span> Checkpoint.Save();
<span style="color: green">// This serializes a snapshot of the async method’s current state to disk.
// It also serializes the async caller who is awaiting it, and so on
// all the way up the async callstack (up to "RunWithCheckpointing")</span></code>

<code style="font-size: small"><span style="color: blue">throw new</span> <span style="color: cyan">Checkpoint</span>.Defer(<span style="color: cyan">Timespan</span>.FromHours(1));
<span style="color: green">// I can abort my current method now. A worker will resume
// it in time, once a condition is met (in this case a delay for one hour)</span>
</code>

<code style="font-size: small"><span style="color: cyan">Task</span> t = Checkpoint.ResumeFrom(<span style="color: red">"a.json"</span>);
<span style="color: green">// You can transfer that serialized state across the wire to another machine,
// who can deserialize it to resume work exactly where it left off.
// The task "t" here stands for the top-level AlphaAsync().</span></code>

&nbsp;

My idea is to enable a kind of "async workflow" -- I'd like to write my long-running processes as async methods, using for loops/while loops and exceptions and recursive functions and all that - things where the <em>current execution state</em> is actually a pretty complicated thing to serialize manually, and where I need all the assistance I can get. The "Checkpoint" class provides that assistance.

&nbsp;

Where might it be useful? ...
<ul>
	<li>You could kick off a long-running method on Azure, which saves its state periodically. If the Azure VM goes down then another VM can just pick up where it left off.</li>
	<li>You could write an interactive website which prompts the user to click a button, then saves its state to disk and releases all resources. When the user clicks the button on their website, that incoming HTTP message causes the state to be picked up from where it left off.</li>
	<li>You could write a mobile agent, which can migrate to another machine to be near to some local resources to do the rest of its work.</li>
</ul>
&nbsp;

I don't know if this idea has legs! It might be completely crazy. It might be that serializing state is too difficult to do reliably.

&nbsp;

Source code is here: <a href="https://github.com/ljw1004/blog/tree/master/Async/AsyncWorkflow">https://github.com/ljw1004/blog/tree/master/Async/AsyncWorkflow</a>

&nbsp;

Please let me know if you have thoughts on this - feasibility, directions, improvements etc. Next time I revisit this topic, I plan to make the code more robust - make it deal with VB, with ConfigureAwait(), with Task.WhenAll and Task.WhenAny, and most importantly make it uses EntityFramework to serialize the current state of async methods in the async callstack. Once that's done I'll package it up as a NuGet library.]]></content:encoded>
    </item>
    <item>
      <title>OpenCV: first version up on NuGet</title>
      <link>https://docs.microsoft.com/archive/blogs/lucian/opencv-first-version-up-on-nuget</link>
      <pubDate>Thu, 03 Dec 2015 16:15:00 GMT</pubDate>
      <dc:creator><![CDATA[Lucian Wischik, MSFT]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/lucian/2015/12/03/opencv-first-version-up-on-nuget/</guid>
      <description><![CDATA[I got OpenCV to work via NuGet! Here are the steps to consume it:
&nbsp;
1. File &gt; New &gt; C++...]]></description>
      <content:encoded><![CDATA[<p>I got OpenCV to work via NuGet! Here are the steps to consume it:</p>
<p>&nbsp;</p>
<p><strong>1. File &gt; New &gt; C++ &gt; UWP</strong></p>
<p>&nbsp;</p>
<p><strong>2. References &gt; Manage NuGet References &gt; Add <a href="https://www.nuget.org/packages/OpenCV.UWP.native.imgcodecs/0.0.1-alpha">OpenCV.UWP.native.imgcodecs</a></strong></p>
<p>This package is currently in pre-release, so it only shows up if you check the "Include Pre-release" checkbox.</p>
<p>It brings in two other dependencies: <em>imgproc</em> and <em>imgcore</em>.</p>
<p>&nbsp;</p>
<p><strong>3. Write some code! </strong>Here are some starters: add these to your #include and your using sections in MainPage.xaml.cpp:</p>
<p><span style="font-family: courier new,courier;">#include &lt;robuffer.h&gt;</span><br /><span style="font-family: courier new,courier;">#include &lt;opencv2\imgcodecs.hpp&gt;</span><br /><span style="font-family: courier new,courier;">#include &lt;opencv2\imgproc.hpp&gt;</span></p>
<p><span style="font-family: courier new,courier;">using namespace Windows::UI::Xaml::Media::Imaging;</span><br /><span style="font-family: courier new,courier;">using namespace Windows::Storage::Streams;</span><br /><span style="font-family: courier new,courier;">using namespace Microsoft::WRL;</span></p>
<p>Next add this inside your MainPage constructor, just after InitializeComponents:</p>
<p><span style="font-family: courier new,courier;">cv::Mat bmp1 = cv::imread("demo.jpg");</span><br /><span style="font-family: courier new,courier;">cv::Mat bmp2 = cv::Mat(bmp1.rows, bmp1.cols, CV_8UC4);</span><br /><span style="font-family: courier new,courier;">cv::cvtColor(bmp1, bmp2, CV_BGR2BGRA);</span><br /><span style="font-family: courier new,courier;">WriteableBitmap^ wbmp = ref new WriteableBitmap(bmp2.cols, bmp2.rows);</span><br /><span style="font-family: courier new,courier;">IBuffer^ buffer = wbmp-&gt;PixelBuffer;</span><br /><span style="font-family: courier new,courier;">unsigned char* dstPixels;</span><br /><span style="font-family: courier new,courier;">ComPtr&lt;IBufferByteAccess&gt; pBufferByteAccess;</span><br /><span style="font-family: courier new,courier;">ComPtr&lt;IInspectable&gt; pBuffer((IInspectable*)buffer);</span><br /><span style="font-family: courier new,courier;">pBuffer.As(&amp;pBufferByteAccess);</span><br /><span style="font-family: courier new,courier;">pBufferByteAccess-&gt;Buffer(&amp;dstPixels);</span><br /><span style="font-family: courier new,courier;">memcpy(dstPixels, bmp2.data, bmp2.step.buf[1] * bmp2.cols * bmp2.rows);</span><br /><span style="font-family: courier new,courier;">image1-&gt;Source = wbmp;</span></p>
<p>Next, add an Image to your MainPage.xaml:</p>
<p><span style="font-family: courier new,courier;">&lt;Image x:Name="image1"/&gt;</span></p>
<p>Next find a picture, rename it "demo.jpg", and add it to your project. (By default when you drag a jpg into SolutionExplorer it gets placed in the Assets folder; the code above assumes instead that it's at top level).</p>
<p><strong></strong>&nbsp;</p>
<p><strong>4. Run it!</strong></p>
<p>What's exciting is that this will run on all x86|x64|ARM configurations, and on all Debug|Release. It will pick the correct OpenCV binaries+libraries for the configuration you select.</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p><strong>5. Debugging: download the symbols</strong></p>
<p>I tried to upload the PDBs to symbolsource.org as recommended in the <a href="http://docs.nuget.org/Create/Creating-and-Publishing-a-Symbol-Package">NuGet docs</a>, but symbolsource.org seems to be down or not accepting symbols. So instead, download them from here, and unzip onto your desktop:</p>
<ul>
<li><a href="https://github.com/ljw1004/opencv/releases/download/v0.0.2-alpha/OpenCV.UWP.native.symbols.zip">OpenCV.UWP.native.symbols.zip</a> [145mb; right-click &gt; save-as].</li>
<li>Once it's downloaded, right-click &gt; Properties &gt; Unblock and then right-click &gt; ExtractAll</li>
</ul>
<p>&nbsp;</p>
<p><strong>6. Debugging: step into the OpenCV source code</strong></p>
<ul>
<li>Video: <a href="https://youtu.be/5ZT5Dc6PPp0">Using OpenCV in a UWP C++ app</a> [6mins]</li>
</ul>
<p>The steps here are kind of fiddly, so that video might be the easiest way to follow them. It shows every single step explicitly.</p>
<ol>
<li>The first time you debug, go to Debug &gt; Windows &gt; Modules, sort this list alphabetically by the Name column, look for opencv_*, right-click &gt; LoadSymbolInformation, and point it to the symbol directory you unzipped.</li>
<li>Tools &gt; Options &gt; Debugging &gt; <em>uncheck</em> the "Just My Code" button</li>
<li>Tools &gt; Options &gt; Debugging &gt; "Enable source server support".</li>
</ol>
<p>Once that was set up, I wanted to F11 into my call to "cv::Mat(bmp1.rows, bmp1.cols, CV_8UC4);". At first when I F11 it just stepped through header files, until it got to this line in mat.inl.hpp:</p>
<p><span style="font-family: courier new,courier;">create(2, sz, _type);</span></p>
<p>This particular function isn't inline in a header file; it resides in the DLL. There's something I don't understand about C++. How come, when I F11 now it just skips over that function? And when I right-click step-into-specific then it says no source is available? but then when I hit F11 a second time then it jumps into the source code proper? Anyway, here's how to make ti work. I did right-click &gt; Step Into Specific &gt; cv::Mat::create. This claims the source isn't available, so I click on <em>view disassembly, </em>to this line:</p>
<p><span style="font-family: courier new,courier;">00398F48&nbsp; jmp&nbsp;dword ptr [__imp_cv::Mat::create (03F2490h)]</span></p>
<p>If I hit F11 a second time then it downloads the OpenCV source code file automatically from GitHub (using the "enable source server support" feature that you checked earlier, and a <a href="http://hamishgraham.net/post/GitHub-Source-Symbol-Indexer.aspx">clever technique</a> by Hamish Graham to use GitHub itself as the source server). You can close the disassembly now and double-click on the top frame in the callstack. Now you can step through the source code of the DLL.</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;So far I've only put three of the 15 OpenCV modules on NuGet: core, imgproc and imgcodecs. The work I did to generate these NuPkgs is <a href="https://github.com/ljw1004/opencv/tree/vs2015-samples/vs2015/WS/10.0/NuPkg">here on GitHub</a>.</p>
<p>&nbsp;</p>
<p>&nbsp;</p>]]></content:encoded>
    </item>
    <item>
      <title>PlatformSpecific.Analayzer - to spot when you're using platform-specific UWP APIs</title>
      <link>https://docs.microsoft.com/archive/blogs/lucian/platformspecific-analayzer-to-spot-when-youre-using-platform-specific-uwp-apis</link>
      <pubDate>Wed, 02 Dec 2015 16:26:00 GMT</pubDate>
      <dc:creator><![CDATA[Lucian Wischik, MSFT]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/lucian/2015/12/02/platformspecific-analayzer-to-spot-when-youre-using-platform-specific-uwp-apis/</guid>
      <description><![CDATA[With the release of 10586, I&rsquo;ve wanted to know whether an API I just used was newly introduced...]]></description>
      <content:encoded><![CDATA[<p>With the release of 10586, I&rsquo;ve wanted to know whether an API I just used was newly introduced in 10586 or was already present back in 10240.</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/12/06/0336.platforms.png" original-url="http://blogs.msdn.com/cfs-filesystemfile.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-12-06/0336.platforms.png"><img style="max-height: 135px; max-width: 500px;" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/12/06/0336.platforms.png" original-url="http://blogs.msdn.com/cfs-filesystemfile.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-12-06/0336.platforms.png" alt="" border="0" /></a></p>
<p>So what I did is write a &ldquo;Roslyn Analyzer&rdquo; for VB/C# and put it on NuGet. It detects whether an API I&rsquo;ve used is platform-specific or version-specific. If so then it puts in a warning squiggle and gives you a quickfix (unless you've already put an ApiInformation.IsTypePresent check, or similar)</p>
<p><a href="https://raw.githubusercontent.com/ljw1004/blog/master/Analyzers/PlatformSpecificAnalyzer/Screenshot.png"><img style="max-height: 188px; max-width: 550px;" src="https://raw.githubusercontent.com/ljw1004/blog/master/Analyzers/PlatformSpecificAnalyzer/Screenshot.png" alt="" border="0" /></a></p>
<p>I&rsquo;d love for folks to try this out and see if you find it helpful!</p>
<ul>
<li>To use, add a NuGet reference to <a href="https://www.nuget.org/packages/PlatformSpecific.Analyzer">PlatformSpecific.Analyzer</a> from your VB/C# UWP project to this NuGet package (2k+ downloads so far)</li>
<li>Documentation and source code <a href="https://github.com/ljw1004/blog/tree/master/Analyzers/PlatformSpecificAnalyzer">here on GitHub</a>.</li>
<li>Short 3-minute <a href="https://github.com/ljw1004/blog/raw/master/Analyzers/PlatformSpecificAnalyzer/ReadMe.mp4">training video</a></li>
<li>More focused on the version-specific aspects, <a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/12/06/7853.version-specific.mp4" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-12-06/7853.version_2D00_specific.mp4">another short video</a></li>
<li>Mike Taulty wrote a <a href="http://mtaulty.com/CommunityServer/blogs/mike_taultys_blog/archive/2015/12/01/windows-10-10586-visual-studio-2015-update-1-contract-definitions.aspx">blogpost about it</a></li>
<li>What's new in 10586 UWP? I typed up the "diff" in <a href="https://github.com/ljw1004/blog/blob/master/Analyzers/PlatformSpecificAnalyzer/PlatformSpecificAnalyzer.vb">this file</a>.</li>
</ul>
<p>&nbsp;</p>
<p>What I&rsquo;d like to learn is this:</p>
<ol>
<li><em>Overall, does the analyzer add value, not just for your simplistic examples, but also for your advanced/large projects?</em></li>
<li><em>The analyzer has its convention for &ldquo;transitivity&rdquo; where you can mark an entire method or field as platform-specific. If you use this, does it work out okay?</em></li>
<li><em>This kind of analysis can never be perfect, so it falls back on loosey-goosey heuristics. Are they too loosey-goosey? Do you find places where you&rsquo;d expected a warning but it produced none? Do you find places where it produced an erroneous warning?</em></li>
</ol>
<p>If people really find it useful, then I&rsquo;ll push for it to be included by default in the File&gt;New&gt;UWP project template. But that&rsquo;s a big unprecedented step so I&rsquo;m cautious.</p>
<p>&nbsp;</p>
<p>Here are some of the new 10586 APIs you could test it on! &hellip;</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/12/06/5165.platform-examples.png" original-url="http://blogs.msdn.com/cfs-filesystemfile.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-12-06/5165.platform_2D00_examples.png"><img style="max-height: 445px; max-width: 550px;" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/12/06/5165.platform-examples.png" original-url="http://blogs.msdn.com/cfs-filesystemfile.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-12-06/5165.platform_2D00_examples.png" alt="" border="0" /></a></p>]]></content:encoded>
    </item>
    <item>
      <title>OpenCV: how to split it up into components</title>
      <link>https://docs.microsoft.com/archive/blogs/lucian/opencv-how-to-split-it-up-into-components</link>
      <pubDate>Mon, 30 Nov 2015 23:13:00 GMT</pubDate>
      <dc:creator><![CDATA[Lucian Wischik, MSFT]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/lucian/2015/11/30/opencv-how-to-split-it-up-into-components/</guid>
      <description><![CDATA[[This article documents my ongoing attempts to get OpenCV working in UWP apps]
&nbsp;
My goal is...]]></description>
      <content:encoded><![CDATA[<p>[This article documents my ongoing attempts to get OpenCV working in UWP apps]</p>
<p>&nbsp;</p>
<p>My goal is to figure out how to package OpenCV up into several individual NuGet packages. For instance, I expect that these files would all be packaged together into a single "OpenCV.native.flann" package. The question is, which other similar NuGet packages would it depend upon?</p>
<ul>
<li>DLL: opencv_flann300.dll</li>
<li>import library: opencv_flann300.lib</li>
<li>include file: opencv2\flann.hpp</li>
<li>include files: opencv2\flann\*.h*</li>
</ul>
<p>&nbsp;</p>
<p>I looked through every DLL that makes up OpenCV and used "dumpbin" to figure out which ones depend on which others. I also looked through all the header files in the include directory to see which ones depend on which others. (I also looked at how the project files in GitHub Microsoft/opencv/tree/vs2015-samples claim to depend upon each other, but that seemed to include superfluous dependencies - ones that aren't reflected in dumpbin or in include files - so I discounted them).</p>
<p>&nbsp;</p>
<p>The end result is this dependency graph below. This shows all the NuGet packages that I intended to create. For instance, the "OpenCV.native.flann" package will include all the files listed above, and it will have a NuGet dependency solely upon "OpenCV.native.core". A few packages also need to contain extra header files, beyond those that follow the example of "flann", and they're indicated in the graph below.</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/12/06/6874.dependencies.png" original-url="http://blogs.msdn.com/cfs-filesystemfile.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-12-06/6874.dependencies.png"><img style="max-height: 600px; max-width: 550px;" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/12/06/6874.dependencies.png" original-url="http://blogs.msdn.com/cfs-filesystemfile.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-12-06/6874.dependencies.png" alt="" border="0" /></a></p>
<p>&nbsp;</p>
<p>(Note: the picture above seems to have cut off the final line of headers that go into the package <em>allheaders.</em> It should also have included "opencv\cv.h, cv.hpp, cvaux.h*").</p>
<p>It's mysterious that these <em>allheaders</em> headers from OpenCV don't also include the headers for <em>shape</em> and <em>stitching</em> and <em>videostab</em>&nbsp;and <em>winrt</em>. I'm undecided whether to create an "opencv.native.complete" NuGet package that depends upon every single package, or merely the ones suggested by the "opencv.hpp" header file.</p>
<p>&nbsp;</p>]]></content:encoded>
    </item>
    <item>
      <title>OpenCV: building UWP binaries</title>
      <link>https://docs.microsoft.com/archive/blogs/lucian/opencv-building-uwp-binaries</link>
      <pubDate>Fri, 27 Nov 2015 21:19:00 GMT</pubDate>
      <dc:creator><![CDATA[Lucian Wischik, MSFT]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/lucian/2015/11/27/opencv-building-uwp-binaries/</guid>
      <description><![CDATA[[This blog article documents my continuing mission to figure out how to use OpenCV in UWP...]]></description>
      <content:encoded><![CDATA[<p>[This blog article documents my continuing mission to figure out how to use OpenCV in UWP apps...]</p>
<p>&nbsp;</p>
<h2>How to build OpenCV&nbsp;native dlls for UWP&nbsp;</h2>
<p>OpenCV is on GitHub. There are three relevant forks/branches, as of writing on November 2015:</p>
<p><span style="font-family: courier new,courier;">&nbsp;&nbsp; [1] <a href="https://github.com/itseez/opencv">https://github.com/itseez/opencv</a></span></p>
<p><span style="font-family: courier new,courier;">&nbsp;&nbsp;&nbsp;&nbsp; +- [2] fork&nbsp;</span><span style="font-family: courier new,courier;"><a href="https://github.com/Microsoft/opencv">https://github.com/Microsoft/opencv</a></span></p>
<p><span style="font-family: courier new,courier;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; +- [3] branch <a href="https://github.com/Microsoft/opencv/tree/vs2015-samples">https://github.com/Microsoft/opencv/tree/vs2015-samples</a></span></p>
<p>Repository [1] is the master. In it, the native OpenCV binaries are built for all different platforms using CMake. As far as I can tell, this repository only has support via CMake for building Windows Store and Windows Phone 8.0 and 8.1 apps. It doesn't seem to have UWP.&nbsp;And it also requires you to install some particular old versions of VS, as per its <a href="https://github.com/Itseez/opencv/blob/master/platforms/winrt/readme.txt">readme.txt</a>.</p>
<p>Fork [2] doesn't seem to bring anything new.</p>
<p>Branch [3] contains Visual Studio .sln files from which you can build UWP versions of all the native OpenCV binaries: x86, x64 and ARM, Debug and Release. The Release builds actually were a bit wonky, but I submitted <a href="https://github.com/Microsoft/opencv/pull/69">PR #69</a>&nbsp;to make them build right. <strong>So: if you clone this repository, select this branch, <a href="https://github.com/Microsoft/opencv/blob/vs2015-samples/README.md">set an environment variable</a>, and open up vs2015/WS/10.0/ARM/OpenCV.sln, or x86/OpenCV.sln, or x64/OpenCV.sln, then you can successfully build UWP binaries for OpenCV.</strong> This will produce 15 binaries for each architecture+build combination.</p>
<p><strong></strong>&nbsp;</p>
<h2>How to use OpenCV native dlls for UWP</h2>
<p>I tried out the OpenCV native dlls in a C++ UWP app, and they worked fine.</p>
<p>More interestingly, the dlls all together add up to about 30mb, but I was able to use just three of them that I needed and they worked fine. This satisfies one of my central requirements, to be able to deploy just a cut-down version of OpenCV with my store app, to keep size down.</p>
<p>I did File&gt;New&gt;C++&gt;Windows&gt;UWP blank app. In Solution Explorer I added three DLLs as "content" files in the root directory of my project so they would be copied into the resulting appx, adjacent to the .exe:</p>
<p><span style="font-family: courier new,courier;">opencv_core300d.dll</span><br /><span style="font-family: courier new,courier;">opencv_igmcodecs300d.dll</span><br /><span style="font-family: courier new,courier;">opencv_igmproc300d.dll</span></p>
<p>In Solution Explorer I added three import-libraries. By default, when you add LIBs to a C++ project, they are taken as import libraries:</p>
<p><span style="font-family: courier new,courier;">opencv_core300d.lib</span><br /><span style="font-family: courier new,courier;">opencv_igmcodecs300d.lib</span><br /><span style="font-family: courier new,courier;">opencv_igmproc300d.lib</span></p>
<p>In Project Properties I added an include directory to my C++ project options</p>
<p><span style="font-family: courier new,courier;">vs2015/WS/10.0/include</span></p>
<p>In my mainpage C++ file, I added a bunch of #include and using statements:</p>
<p><span style="font-family: courier new,courier;">#include &lt;robuffer.h&gt;</span><br /><span style="font-family: courier new,courier;">#include &lt;opencv2\imgcodecs.hpp&gt;</span><br /><span style="font-family: courier new,courier;">#include &lt;opencv2\imgproc.hpp&gt;</span></p>
<p><span style="font-family: courier new,courier;">using namespace Windows::UI::Xaml::Media::Imaging;</span><br /><span style="font-family: courier new,courier;">using namespace Windows::Storage::Streams;</span><br /><span style="font-family: courier new,courier;">using namespace Microsoft::WRL;</span></p>
<p>I added a content file "demo.jpg" in Solution Explorer, and in MainPage.xaml I added an Image control named "image1", and added these lines in OnNavigatedTo in my mainpage C++ file:</p>
<p><span style="font-family: courier new,courier;">cv::Mat bmp1 = cv::imread("demo.jpg");</span><br /><span style="font-family: courier new,courier;">cv::Mat bmp2 = cv::Mat(bmp1.rows, bmp1.cols, CV_8UC4);</span><br /><span style="font-family: courier new,courier;">cv::cvtColor(bmp1, bmp2, CV_BGR2BGRA);</span><br /><span style="font-family: courier new,courier;">WriteableBitmap^ wbmp = ref new WriteableBitmap(bmp2.cols, bmp2.rows);</span><br /><span style="font-family: courier new,courier;">IBuffer^ buffer = wbmp-&gt;PixelBuffer;</span><br /><span style="font-family: courier new,courier;">unsigned char* dstPixels;</span><br /><span style="font-family: courier new,courier;">ComPtr&lt;IBufferByteAccess&gt; pBufferByteAccess;</span><br /><span style="font-family: courier new,courier;">ComPtr&lt;IInspectable&gt; pBuffer((IInspectable*)buffer);</span><br /><span style="font-family: courier new,courier;">pBuffer.As(&amp;pBufferByteAccess);</span><br /><span style="font-family: courier new,courier;">pBufferByteAccess-&gt;Buffer(&amp;dstPixels);</span><br /><span style="font-family: courier new,courier;">memcpy(dstPixels, bmp2.data, bmp2.step.buf[1] * bmp2.cols * bmp2.rows);</span><br /><span style="font-family: courier new,courier;">image1-&gt;Source = wbmp;</span></p>
<p>Result: it all worked. The image displayed correctly.</p>
<p>&nbsp;</p>
<h2>Next Steps</h2>
<p>I want to package each individual DLL up as a NuGet package, for 15 NuGet packages in total. Each package should include x86+x64+ARM versions of the DLLs, and corresponding import libraries. It should also include the include files pertaining to that DLL.&nbsp;That way, as a C++ author, I will be able to bring in only the particular DLLs that I want. To do this I'll have to figure out the dependencies between the DLLs, and the dependencies between header files, and then express these as NuGet dependencies. (I don't yet know how to create NuGet packages for C++. I'll look to "Win2d.uwp" as the canonical example. I don't know if each package should also include debug builds, but I suspect not. I don't know where PDBs should go.)</p>
<p>I think that NuGet generation should be done as part of [3] branch vs2015-samples. This is the branch that has .sln files for building all the DLLs, so it's appropriate for it to also include NuGet-package-building. I don't know if this is within the vision of the owners of that branch or not. Ultimately, in the future, I don't know if the owners of Itseez/opencv would be open to their CMake system building the NuGet packages as well?</p>
<p>&nbsp;</p>
<p>Beyond that, the major issue is that OpenCV has a C++ API. This is not friendly to pinvoke interop with .NET. OpenCV used to have a plain C API which is friendly, but the C API has been deprecated and is not getting new features. I don't wish to invent a pinvoke-friendly wrapper around the OpenCV C++ API.</p>
<p>Approach (1): I'd like to test the scenario of a hybrid app, where most of the app is in .NET, and it calls into a C++ winrt component that I author, and this C++ component does all the calls into OpenCV, which it obtains via NuGet.</p>
<p>Approach (2): OpenCVSharp has a BSD license and already contains a set of 'extern "C"' wrappers around the C++ API. The ideal would be for OpenCVSharp to be able to consume my native UWP dlls for OpenCV. There already is a "dll-free" version of OpenCVSharp, which merely contains the pinvoke wrappers, and expects you to supply the OpenCV DLLs some other way. There are a few unknowns with this approach. I don't know if the OpenCVSharp project has different version of OpenCV (and hence different include files) as compared to the one in branch [3]. I don't know if the native extern "C" assembly that comes with OpenCVSharp will be compatible with the DLLs I build, and the fact that there are 15 of them rather than just 1 big "world" dll. I don't know if it will need to switch to "delay-load" to support the scenario where you only package say 3 of the OpenCV dlls with your store app.</p>
<p>&nbsp;</p>
<h2>Notes</h2>
<p>I am hugely excited! It was thrilling to see the UWP versions of all the DLLs get built properly. I think I know how to package up DLLs into NuGet better than most folk, and I can do a best-in-class job. I'm excited that I was able to get something working end-to-end at least in C++.</p>
<p>&nbsp;</p>
<p>&nbsp;</p>]]></content:encoded>
    </item>
    <item>
      <title>OpenCV: unsure how to proceed</title>
      <link>https://docs.microsoft.com/archive/blogs/lucian/opencv-unsure-how-to-proceed</link>
      <pubDate>Wed, 25 Nov 2015 10:43:00 GMT</pubDate>
      <dc:creator><![CDATA[Lucian Wischik, MSFT]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/lucian/2015/11/25/opencv-unsure-how-to-proceed/</guid>
      <description><![CDATA[OpenCV http://opencv.org/ is the standard open-source library that everyone uses for image...]]></description>
      <content:encoded><![CDATA[<p>OpenCV <a href="http://opencv.org/">http://opencv.org/</a> is the standard open-source library that everyone uses for image detection. It's written in C++.</p>
<p>I want to use it from my .NET UWP apps, but I'm struggling to figure out how. If anyone has solid guidance on how to proceed, I'd love to know! This blog post is just a documentation of my first tentative investigations. (Also eventually I want to use OpenCV from my cross-platform .NET Core apps as well, so I can write an ASP.NET5 webservice running on Linux that does face detection).</p>
<p>I think&nbsp;there should ideally be three layers of NuGet packages:</p>
<ol>
<li><strong>OpenCV.dlls</strong> - there should just be a base NuGet package whose only job is to carry the native C++ dlls. It needs to carry the three flavors, x86 + x64 + ARM. It should use the new features in NuGet3 so it can carry all three flavors of dll in a single NuGet package, and at build-time the project.json should pick out the right binaries.</li>
<ul>
<li>There's a catch. The normal "opencv_world300.dll" is huge at 30mb and includes absolutely all OpenCV functionality. Typically my store apps will only need a small subset of that functionality. I see that the "OpenCV.NET" NuGet package instead delivers it split up into 19 separate DLLs, each of them about 1-2mb. It would be best if you could get the DLLs also through a load of smaller NuGet packages, one by one, to pick out which of those binaries you need.</li>
<li>Note that a C++ DLL that you built for an earlier version of Windows Store or Windows Phone will <em>not</em> work in UWP. That's because&nbsp;even though UWP supports all the same APIs that were there in the earlier WinRT platforms, it divides them up into different "api-sets", so the binaries are&nbsp;incompatible.</li>
<li>Ideally this NuGet package should also carry the&nbsp;native C++ dlls for Linux and for OSX, so it can be used on other .NET Core platforms. I don't know&nbsp;how native dlls are carried on those platforms<br />&nbsp;</li>
</ul>
<li><strong>OpenCV.interop</strong> - there should be an intermediate NuGet package whose job is solely to contain p/invoke declarations for those DLLs without any fancy wrapping.</li>
<ul>
<li>Maybe it would also include header files, for consumption by C++</li>
<li>I don't know how p/invoke declarations work for cross-platform .NET Core.</li>
<li>Why decouple this from the raw DLLs? solely to enable the "pick-and-choose" idea above. Maybe it's not worth it. Maybe the "OpenCV.dlls" and "OpenCV.interop" should be combined.<br />&nbsp;</li>
</ul>
<li><strong>OpenCV.Net</strong> - there should be a higher-level set of wrapper classes, more .NET friendly.</li>
<ul>
<li>Maybe this package need never be written, if everyone is happy using the unwrapped versions of the APIs.</li>
<li>Maybe there will be multiple competing versions of this package, with different API designs, some more friendly than others.</li>
</ul>
</ol>
<p>&nbsp;</p>
<h2>OpenCV itself&nbsp;</h2>
<p><a href="http://opencv.org/">http://opencv.org/</a> - the main website has a "download binaries for Windows" link. This includes x64+x86 builds of "opencv_world300.dll" (32mb). I don't know if they're built for UWP but I suspect not. It has&nbsp;two 8.1-era Phone+Store sample apps but they didn't build out of the box. It has a directory called "sources\platforms\winrt" which has instructions for building on WinRT, but these instructions don't include x64, and I suspect they date from before UWP.</p>
<p><a href="https://github.com/Itseez/opencv">https://github.com/Itseez/opencv</a>&nbsp;- the main GitHub repository for OpenCV</p>
<p><a href="https://msopentech.com/blog/2015/03/06/opencv-enabled-for-windows-runtime-family/">https://msopentech.com/blog/2015/03/06/opencv-enabled-for-windows-runtime-family/</a>&nbsp;- has pre-UWP instructions on how to build&nbsp;binaries from the main GitHub repository&nbsp;using CMake</p>
<p><a href="https://www.nuget.org/packages/OpenCV/">https://www.nuget.org/packages/OpenCV/</a> - this NuGet package with 18k downloads claims to contain "binaries and build targets". This isn't true. It contains C++ header files, and it contains a .targets file which (based on build parameters) pick up the OpenCV native DLLs that it assumes you got from elsewhere and copied into a particular location. It only does this for x86 and x64; not ARM.</p>
<p>There are two old sites -&nbsp;<a href="https://github.com/Microsoft/opencv">https://github.com/Microsoft/opencv</a>&nbsp;was the old staging repo where WinRT support was first added to the main OpenCV GitHub, and&nbsp;<a href="http://code.opencv.org/projects/opencv/wiki/WindowsRT">http://code.opencv.org/projects/opencv/wiki/WindowsRT</a>&nbsp;had old instructions on how to build for WinRT. I think both links are out of date.</p>
<p><em>Analysis: I suspect there are no "ready-to-go" binaries here for UWP, nor any useful NuGet packages. If I want to use OpenCV from source, I'll have to learn the thing's build system, configure it to build UWP, and built it myself. I'll have to write a OpenCV.dlls NuGet package from scratch myself. I don't know whether the work I do here can be submitted back into OpenCV's daily builds, or if I'll have to keep it separate.</em></p>
<p>&nbsp;</p>
<h2>OpenCV Extension SDK&nbsp;</h2>
<p><a href="https://channel9.msdn.com/Events/Build/2015/3-82">https://channel9.msdn.com/Events/Build/2015/3-82</a>&nbsp;- this video discusses an "OpenCV for Windows Store" Extension SDK which contains native binaries for UWP apps. However, the Extension SDK has never been publically released. (Also, ExtensionSDKs were used in the past because prior versions of NuGet weren't good at selecting x64/x86/ARM binaries based on build-time configuration. That limitation has gone away, and now NuGet is a much better option than ExtensionSDK).</p>
<p><em>Analysis: The author of the video has moved on to a different team. I've contacted his former colleagues to see if I can get anywhere with this. I don't know if it will be a single huge 30mb "world" dll, or a series of smaller ones.</em></p>
<p>&nbsp;</p>
<h2>OpenCVSharp</h2>
<p>This NuGet package contains a 30mb "world" binary for x86+x64 (not ARM) that come from <a href="https://github.com/shimat/opencvsharp/tree/master/lib/opencv/x64/vc12/bin">here</a>. It also contains C# wrappers that are as close as possible to the raw C API. This is the most widely used package, with 32k downloads total.</p>
<p>I'm confused, because the NuGet package has that huge DLL, but then the project's <a href="https://github.com/shimat/opencvsharp/blob/master/nuget/tools/install-AnyCPU.ps1">install.ps1</a>&nbsp;seems to have them split up into separate pieces.</p>
<p>The NuGet package only installs onto desktop .NET Framework 4.0 and higher -- not .NETCore, and not UWP.</p>
<p>As for the raw native binaries themselves, I don't know. But given the desktop focus, and the lack of ARM, I strongly suspect they won't work on UWP.</p>
<p><a href="https://github.com/shimat/opencvsharp">https://github.com/shimat/opencvsharp</a> - this is the main repository.</p>
<p>The OpenCVSharp NuGet is actually offered in four flavors:</p>
<ol>
<li><a href="https://www.nuget.org/packages/OpenCvSharp3-AnyCPU/">https://www.nuget.org/packages/OpenCvSharp3-AnyCPU/</a>&nbsp;- the main one for OpenCV3 which was released in 2015; most recent</li>
<li><a href="https://www.nuget.org/packages/OpenCvSharp3-WithoutDll/">https://www.nuget.org/packages/OpenCvSharp3-WithoutDll/</a>&nbsp;- as above, but missing the "world.dll" (so you'll pick it up yourself elsewhere)</li>
<li><a href="https://www.nuget.org/packages/OpenCvSharp-AnyCPU/">https://www.nuget.org/packages/OpenCvSharp-AnyCPU/</a>&nbsp;- like [1] but for OpenCV 2.4</li>
<li><a href="https://www.nuget.org/packages/OpenCvSharp-WithoutDll/">https://www.nuget.org/packages/OpenCvSharp-WithoutDll/</a>&nbsp;- like [2] but for OpenCV 2.4</li>
</ol>
<p>There's also this NuGet package <a href="https://www.nuget.org/packages/OpenCVSharp/">https://www.nuget.org/packages/OpenCVSharp/</a>&nbsp;but it doesn't seem to be related.</p>
<p><em>Analysis: this project seems to provide the correct "interop p/invoke" layer. But I think it won't be a good source of binaries for UWP.</em></p>
<p>&nbsp;</p>
<h2>OpenCV.NET</h2>
<p>This NuGet package has a nicer .NET-style set of wrapper classes. I don't understand how/where the NuGet package picks up its raw binaries from, but it appears to get them somehow! The binaries seem to be x86 only (not x64, not ARM) and are split into ~15 smaller DLLs. The package has been downloaded 8k times. The most recent update was 9 months ago.</p>
<p>The NuGet package only works on desktop .NET Framework 4.0 and higher (not UWP).</p>
<p><a href="https://www.nuget.org/packages/OpenCV.Net/">https://www.nuget.org/packages/OpenCV.Net/</a></p>
<p><em>Analysis: I think it'd be ideal to split out the "interop p/inoke" layer from the wrapper classes. I'm interested to know whether the interop declarations for "split-into-separate-dlls" that this project uses is different from the interop declarations for "world.dll". In any case, this project isn't a suitable source for raw binaries.</em></p>
<p>&nbsp;</p>
<h2>Emgu</h2>
<p>This project does provide ARM and WinRT for 8.1-era. However I haven't read anything to indicate support for UWP. Its NuGet package was last updated 20 months ago and has 6k downloads.</p>
<p>This project requires a commercial license for ARM and WinRT.</p>
<p><a href="http://www.emgu.com/wiki/index.php/Main_Page">http://www.emgu.com/wiki/index.php/Main_Page</a></p>
<p><a href="https://www.nuget.org/packages/VVVV.EmguCV/">https://www.nuget.org/packages/VVVV.EmguCV/</a></p>
<p><em>Analysis: this isn't in the OSS spirit that I like about&nbsp;.NET Core, so I haven't pursued it.</em></p>
<p>&nbsp;<br />&nbsp;</p>
<h2>Stack Overflow&nbsp;</h2>
<p><a href="http://stackoverflow.com/questions/14065370/using-opencv-in-a-windows-store-app-with-visual-c">http://stackoverflow.com/questions/14065370/using-opencv-in-a-windows-store-app-with-visual-c</a>&nbsp;- this seems to be the most valuable StackOverflow resource. It has Raman Sharma (author&nbsp;of the "OpenCV for Windows Store Apps" ExtensionSDK) give some answers on how he built OpenCV for WinRT.</p>
<p>&nbsp;</p>]]></content:encoded>
    </item>
    <item>
      <title>How to call UWP APIs from a desktop VB/C# app</title>
      <link>https://docs.microsoft.com/archive/blogs/lucian/how-to-call-uwp-apis-from-a-desktop-vbc-app</link>
      <pubDate>Fri, 23 Oct 2015 11:12:00 GMT</pubDate>
      <dc:creator><![CDATA[Lucian Wischik, MSFT]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/lucian/2015/10/23/how-to-call-uwp-apis-from-a-desktop-vbc-app/</guid>
      <description><![CDATA[Latest update:
I've put this functionality into a&nbsp;NuGet package. To use&nbsp;UWP APIs from...]]></description>
      <content:encoded><![CDATA[<h1>Latest update:</h1>
<p>I've put this functionality into a&nbsp;NuGet package. To use&nbsp;UWP APIs from your &gt;=.NET45 desktop app, simply add a NuGet reference:</p>
<ul>
<li><a href="https://www.nuget.org/packages/UwpDesktop">UWP for Desktop</a>&nbsp;NuGet package</li>
</ul>
<p>&nbsp;</p>
<p>I've also moved&nbsp;the technical information from this blog over to the package's GitHub project site:</p>
<ul>
<li><a href="https://github.com/ljw1004/uwp-desktop/blob/master/README.md">UWP for Desktop</a> GitHub project page</li>
</ul>
<p>&nbsp;</p>
<h2>Out of date: first steps</h2>
<p>Add these references to your project, by right-clicking on your project in Solution Explorer and doing References &gt; AddReference &gt; Browse. This&nbsp;minimum needed&nbsp;to get going.</p>
<ol>
<li><span style="font-family: courier new,courier;">c:\Program Files (x86)\Windows Kits\10\References\Windows.Foundation.FoundationContract\1.0.0.0\Windows.Foundation.FoundationContract.winmd</span></li>
<li><span style="font-family: courier new,courier;">c:\Program Files (x86)\Windows Kits\10\References\Windows.Foundation.UniversalApiContract\1.0.0.0\Windows.Foundation.UniversalApiContract.winmd</span></li>
<li><span style="font-family: courier new,courier;">c:\Program Files (x86)\Windows Kits\10\UnionMetadata\Facade\Windows.WinMD</span></li>
<li><span style="font-family: courier new,courier;">c:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETCore\v4.5\System.Runtime.WindowsRuntime.dll</span></li>
</ol>
<h2>The complete set of Desktop WinRT APIs</h2>
<p>Here is a MSDN&nbsp;<a href="https://msdn.microsoft.com/en-us/library/windows/desktop/dn554295(v=vs.85).aspx">list of WinRT APIs that can be called from desktop apps</a>&nbsp;(but I believe this list is incomplete).</p>
<p>&nbsp;</p>
<p>Just the four references is enough to get you 90% of the WinRT APIs you'll need in practice.</p>
<p>But to go the full mile, I think the best way would be to&nbsp;package it up as&nbsp;a NuGet package according to the instructions below. I'll explore that idea later. I'd want to get the other UWP facades, get something that works with newer UWP SDKs than just 10240, also include APIs from the Desktop Extension SDK, include the remaining .NET interop DLLs, and get all the default namespace-imports.</p>
<p>Until I or someone else produces that NuGet package, here below is a detailed explanation:</p>
<h2>Explanation</h2>
<p><strong>To find&nbsp;the UWP WinRT APIs themselves</strong>, look for example at this file:</p>
<p style="padding-left: 30px;"><span style="font-family: courier new,courier;">C:\Program Files (x86)\Windows Kits\10\Platforms\UAP\10.0.10240.0\Platform.xml</span></p>
<p>This Platform.xml file&nbsp;conveys which WinRT APIs are available in "version 10240" of the UWP SDK. (This was the version that came out at VS2015 RTM. Newer versions will come out periodically). The Platform.xml file works by being an index into a set of other winmd files. It looks like this:</p>
<p style="padding-left: 30px;"><span style="font-family: courier new,courier;">&lt;ApiContract name="Windows.Foundation.FoundationContract" version="1.0.0.0" /&gt;</span><br /><span style="font-family: courier new,courier;">&lt;ApiContract name="Windows.Foundation.UniversalApiContract" version="1.0.0.0" /&gt;</span><br /><span style="font-family: courier new,courier;">&lt;ApiContract name="Windows.Networking.Connectivity.WwanContract" version="1.0.0.0" /&gt;</span></p>
<p>Each line&nbsp;denote a .winmd file in the "C:\Program Files (x86)\Windows Kits\10\References directory". That's how I picked up exact filenames and pathnames to add as references. (I should really have added a reference to the WwanContract.winmd file as well, but couldn't be bothered)</p>
<p>These three winmd files make up the WinRT APIs available across all Win10 devices. You might additionally want to use the additional WinRT APIs that are part of Desktop. Look at this file:</p>
<p style="padding-left: 30px;"><span style="font-family: courier new,courier;">C:\Program Files (x86)\Windows Kits\10\Extension SDKs\WindowsDesktop\10.0.10240.0\SDKManifest.xml</span></p>
<p>It has a load more &lt;ApiContract&gt; directives, pointing to additional .winmd files you should reference from the "C:\Program Files (x86)\Windows Kits\10\References" directory. I haven't bothered to do that.</p>
<p>&nbsp;</p>
<p><strong>To interop with DLLs or WINMDs build for Win8.1 or WindowsPhone8.1</strong>, the issue is that those old DLLs and WinMDs used to think that all WinRT types were in a file called "windows.winmd". But they're not anymore! Instead they're in files called Windows.Foundation.FoundationContract.winmd and the like. The solution is a <em>fa&ccedil;ade winmd</em>, which is basically a load of type-forwarders from windows.winmd to the new winmd files.</p>
<p style="padding-left: 30px;"><span style="font-family: courier new,courier;">c:\Program Files (x86)\Windows Kits\10\UnionMetadata\Facade\Windows.WinMD</span></p>
<p>&nbsp;</p>
<p><strong>To use "await" on WinRT types</strong><strong>,</strong> this and other interop between .NET and WinRT are provided by&nbsp;the following DLL. Note that it's an 8.1-era DLL, and therefore only works in conjunction with "facade\windows.winmd" above. (There are several other interop assemblies but they're not so crucial).</p>
<p style="padding-left: 30px;"><span style="font-family: courier new,courier;">c:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETCore\v4.5\System.Runtime.WindowsRuntime.dll</span></p>
<p>If you fail to add <em>both</em> these two assemblies, then you'll get error messages like this:</p>
<ul>
<li>BC36930: 'Await' requires that the type 'IAsyncAction' have a suitable GetAwaiter method</li>
<li>CS0012: The type 'IAsyncAction' is defined in an assembly that is not referenced. You must add a reference to assembly 'Windows, Version=255.255.255.0, Culture=neutral, PublicKeyToken=null, ContentType=WindowsRuntime'.</li>
<li>CS4036: 'IAsyncAction' does not contain a definition for 'GetAwaiter' and no extension method 'GetAwaiter' accept a first argument of type 'IAsyncAction' could be found (are you missing a using directive for 'System'?)</li>
</ul>
<p>&nbsp;</p>
<h2>Example code (VB)</h2>
<p>Here's an example console app in VB which uses UWP WinRT APIs:</p>
<p><span style="font-family: courier new,courier;">Imports System.IO</span></p>
<p><span style="font-family: courier new,courier;">Module Module1</span><br /><span style="font-family: courier new,courier;">&nbsp;&nbsp;&nbsp; Sub Main()</span><br /><span style="font-family: courier new,courier;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MainAsync().GetAwaiter().GetResult()</span><br /><span style="font-family: courier new,courier;">&nbsp;&nbsp;&nbsp; End Sub</span></p>
<p><span style="font-family: courier new,courier;">&nbsp;&nbsp;&nbsp; Async Function MainAsync() As Task</span><br /><span style="font-family: courier new,courier;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ' basics</span><br /><span style="font-family: courier new,courier;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dim folder = Windows.Storage.KnownFolders.DocumentsLibrary</span><br /><span style="font-family: courier new,courier;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dim opts As New Windows.Storage.Search.QueryOptions(</span><br /><span style="font-family: courier new,courier;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Windows.Storage.Search.CommonFileQuery.OrderByName, {".txt"})</span><br /><span style="font-family: courier new,courier;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dim files = Await folder.CreateFileQueryWithOptions(opts).GetFilesAsync(0, 20)</span><br /><span style="font-family: courier new,courier;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; For Each file In files</span><br /><span style="font-family: courier new,courier;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Console.WriteLine(IO.Path.GetFileName(file.Path))</span><br /><span style="font-family: courier new,courier;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Next</span></p>
<p><span style="font-family: courier new,courier;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ' streams</span><br /><span style="font-family: courier new,courier;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Using reader = New IO.StreamReader(Await files.First.OpenStreamForReadAsync())</span><br /><span style="font-family: courier new,courier;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dim txt = Await reader.ReadToEndAsync()</span><br /><span style="font-family: courier new,courier;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Console.WriteLine(txt.Substring(0, 100))</span><br /><span style="font-family: courier new,courier;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End Using</span></p>
<p><span style="font-family: courier new,courier;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ' pictures</span><br /><span style="font-family: courier new,courier;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dim pics = Await Windows.Storage.KnownFolders.PicturesLibrary.GetFilesAsync(</span><br /><span style="font-family: courier new,courier;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Windows.Storage.Search.CommonFileQuery.OrderBySearchRank, 0, 1)</span><br /><span style="font-family: courier new,courier;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Using stream = Await pics.First.OpenReadAsync()</span><br /><span style="font-family: courier new,courier;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dim decoder = Await Windows.Graphics.Imaging.BitmapDecoder.CreateAsync(stream)</span><br /><span style="font-family: courier new,courier;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Console.WriteLine(decoder.OrientedPixelWidth &amp; "x" &amp; decoder.OrientedPixelHeight)</span><br /><span style="font-family: courier new,courier;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End Using</span></p>
<p><span style="font-family: courier new,courier;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ' httpclient</span><br /><span style="font-family: courier new,courier;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dim client As New Net.Http.HttpClient()</span><br /><span style="font-family: courier new,courier;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dim html = Await client.GetStringAsync("<a href="http://www.microsoft.com">http://www.microsoft.com</a>")</span><br /><span style="font-family: courier new,courier;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Console.WriteLine(html.Substring(0, 100))</span></p>
<p><span style="font-family: courier new,courier;">&nbsp;&nbsp;&nbsp; End Function</span><br /><span style="font-family: courier new,courier;">End Module</span></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<h2>Example code (C#)</h2>
<p>Here's an example console app in&nbsp;C# which uses UWP WinRT APIs:</p>
<p><span style="font-family: courier new,courier;">using System;</span><br /><span style="font-family: courier new,courier;">using System.Collections.Generic;</span><br /><span style="font-family: courier new,courier;">using System.IO;</span><br /><span style="font-family: courier new,courier;">using System.Linq;</span><br /><span style="font-family: courier new,courier;">using System.Threading.Tasks;</span></p>
<p><span style="font-family: courier new,courier;">class Program</span><br /><span style="font-family: courier new,courier;">{</span><br /><span style="font-family: courier new,courier;">&nbsp;&nbsp;&nbsp; static void Main()</span><br /><span style="font-family: courier new,courier;">&nbsp;&nbsp;&nbsp; {</span><br /><span style="font-family: courier new,courier;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MainAsync().GetAwaiter().GetResult();</span><br /><span style="font-family: courier new,courier;">&nbsp;&nbsp;&nbsp; }</span></p>
<p><span style="font-family: courier new,courier;">&nbsp;&nbsp;&nbsp; static async Task MainAsync()</span><br /><span style="font-family: courier new,courier;">&nbsp;&nbsp;&nbsp; {</span><br /><span style="font-family: courier new,courier;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // basics</span><br /><span style="font-family: courier new,courier;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var folder = Windows.Storage.KnownFolders.DocumentsLibrary;</span><br /><span style="font-family: courier new,courier;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var opts = new Windows.Storage.Search.QueryOptions(Windows.Storage.Search.CommonFileQuery.OrderByName, new[] { ".txt" });</span><br /><span style="font-family: courier new,courier;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var files = await folder.CreateFileQueryWithOptions(opts).GetFilesAsync(0, 20);</span><br /><span style="font-family: courier new,courier;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; foreach (var file in files)</span><br /><span style="font-family: courier new,courier;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {</span><br /><span style="font-family: courier new,courier;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Console.WriteLine(System.IO.Path.GetFileName(file.Path));</span><br /><span style="font-family: courier new,courier;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</span></p>
<p><span style="font-family: courier new,courier;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // streams</span><br /><span style="font-family: courier new,courier;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; using (var reader = new System.IO.StreamReader(await files.First().OpenStreamForReadAsync()))</span><br /><span style="font-family: courier new,courier;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {</span><br /><span style="font-family: courier new,courier;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var txt = await reader.ReadToEndAsync();</span><br /><span style="font-family: courier new,courier;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Console.WriteLine(txt.Substring(0, 100));</span><br /><span style="font-family: courier new,courier;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</span></p>
<p><span style="font-family: courier new,courier;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // pictures</span><br /><span style="font-family: courier new,courier;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var pics = await Windows.Storage.KnownFolders.PicturesLibrary.GetFilesAsync(</span><br /><span style="font-family: courier new,courier;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Windows.Storage.Search.CommonFileQuery.OrderBySearchRank, 0, 1);</span><br /><span style="font-family: courier new,courier;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; using (var stream = await pics.First().OpenReadAsync())</span><br /><span style="font-family: courier new,courier;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {</span><br /><span style="font-family: courier new,courier;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var decoder = await Windows.Graphics.Imaging.BitmapDecoder.CreateAsync(stream);</span><br /><span style="font-family: courier new,courier;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Console.WriteLine($"{decoder.OrientedPixelWidth} x&nbsp; {decoder.OrientedPixelHeight}");</span><br /><span style="font-family: courier new,courier;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</span></p>
<p><span style="font-family: courier new,courier;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // httpclient</span><br /><span style="font-family: courier new,courier;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var client = new System.Net.Http.HttpClient();</span><br /><span style="font-family: courier new,courier;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var html = await client.GetStringAsync("<a href="http://www.microsoft.com">http://www.microsoft.com</a>");</span><br /><span style="font-family: courier new,courier;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Console.WriteLine(html.Substring(0, 100));</span><br /><span style="font-family: courier new,courier;">&nbsp;&nbsp;&nbsp; }</span><br /><span style="font-family: courier new,courier;">}</span></p>
<p>&nbsp;</p>]]></content:encoded>
    </item>
    <item>
      <title>Writing a NuGet package for VS2015 RTM [repost]</title>
      <link>https://docs.microsoft.com/archive/blogs/lucian/writing-a-nuget-package-for-vs2015-rtm-repost</link>
      <pubDate>Tue, 15 Sep 2015 08:26:00 GMT</pubDate>
      <dc:creator><![CDATA[Lucian Wischik, MSFT]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/lucian/2015/09/15/writing-a-nuget-package-for-vs2015-rtm-repost/</guid>
      <description><![CDATA[There are some exciting changes coming to NuGet in VS2015 RTM, under the name NuGet 3.1, also known...]]></description>
      <content:encoded><![CDATA[There are some exciting changes coming to NuGet in VS2015 RTM, under the name NuGet 3.1, also known as "<em>project.json</em>". You should read about them on the NuGet team blog [<a href="http://blog.nuget.org/20150729/Introducing-nuget-uwp.html">link</a>].

<strong><em>How should you prepare for this as a NuGet package author? This article explains.</em></strong>

<strong><em> </em></strong>

<em>Disclaimer: I'm not on the NuGet team, and this post is my non-authoritative personal opinion</em>
<h1>Motivation</h1>
As explained on the <a href="http://blog.nuget.org/20150729/Introducing-nuget-uwp.html">NuGet team blog</a>, project.json is a new way for Visual Studio projects to consume NuGet packages. It brings several benefits, which is why NuGet package <em>consumers</em> will like it, and why NuGet package <em>authors</em> will have to support it too:
<ul>
	<li>Your .vbproj/.csproj no longer gets polluted with NuGet artifacts. They are kept completely separate.</li>
	<li>You can change your app target platform, and change debug/release and x86/x64/arm/anycpu, and NuGet packages will now pick this up immediately -- before you had to uninstall+reinstall them.</li>
	<li>You can have two different solutions in two different directories that include the same project (this is particularly useful when you're working across two different repositories)</li>
	<li>Your SolutionExplorer&gt;References node looks cleaner because it only includes the packages you've actually installed, rather than all their dependencies too.</li>
	<li>Uninstalling NuGet packages is easier, again because you only have to uninstall the ones you installed rather than all their dependencies.</li>
	<li>Packages are cached globally (on a per-user per-machine) basis rather than being downloaded and unzipped into every single solution that uses them.</li>
	<li>File &gt; New and Managed NuGet Packages &gt; Install both become faster.</li>
	<li>You get more precise control over NuGet package upgrades, and version mismatches.</li>
</ul>
The intent of project.json is this: <em> "Installing a NuGet package is nothing more than adding a line to the project.json file; at build-time the libs and .targets from that NuGet package get consumed by msbuild." </em>

Project.json - for now - will be used in the following kinds of projects in VS2015. Look for this list to grow longer as new project types are introduced which will also use project.json:
<ul>
	<li><strong>In ASP.NET 5 ("DNX") projects</strong>
<ul>
	<li>Currently still in preview form</li>
</ul>
</li>
	<li><strong>For Windows 10 Universal app projects ("UWP")</strong>
<ul>
	<li>Requires installation of the <em>VS Universal Windows app development tools</em>. If they're not already installed, you can install them with "Add/Remove Programs &gt; VisualStudio2015 &gt; Modify".</li>
</ul>
</li>
	<li><strong>For modern Portable Class Library ("PCL") development</strong>
<ul>
	<li>"Modern PCLs" are ones whose targets are limited to amongst ASP.NET Core 5.0 ("DNX"), Windows 10 ("UWP") and .NET46.</li>
	<li>Again this requires installation of the VS universal windows tools.</li>
</ul>
</li>
	<li><strong>For <em>any other project type</em>,</strong>
<ul>
	<li>You can delete packages.config and add a project.json file manually, to take advantage of its benefits [<a href="http://blogs.msdn.com/b/lucian/archive/2015/08/19/using-project-json-for-other-project-types.aspx">instructions</a>].</li>
	<li>This path isn't officially supported. It mostly works, except that if you have a P2P (Project-to-project) reference from a packages.config project to a project.json library. In that case, any NuGet dependencies in project.json will fail to be copied to the consuming project.</li>
	<li>VS universal windows tools are required.</li>
</ul>
</li>
</ul>
<h1>Master table of all the various .NET frameworks</h1>
There have been many different versions of the .NET framework over the years. Key points:
<ol>
	<li>As a NuGet package author you have to be aware of the different versions to write your NuGet packages effectively.</li>
	<li>Microsoft has gotten on top of the problem with a solution called the "<span style="color: #0000ff;">dotnet</span>" TxM, described below (TxM stands for "Target x Moniker" and refers to the codes in the table below). The <em>project.json</em> approach was introduced in part to support <span style="color: #0000ff;">dotnet</span>.</li>
</ol>
Various codes, such as "net45" and "win81" and "<span style="color: #0000ff;">dotnet</span>" are an essential part of your NuGet package authoring. It is important to understand why they're available, and what they're compatible with.

The following table is based upon that in the <a href="http://blog.nuget.org/20150729/Introducing-nuget-uwp.html">NuGet team blog</a>, but contains additional color codes you'll find useful when authoring your class libraries.

<img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/12/06/UWP/7534.master-table.png" alt="" width="627" height="581" />

Backwards-compatibility works within a row, but there's no compatibility across different rows. For instance, a library or NuGet package designed for "net40" will work in "net45" but might not work (and NuGet will refuse to add a reference) in "win81". That's because it might depend on some .NET APIs that are present in net40 but absent in win81.

<strong>As explained in the </strong> <a href="http://blog.nuget.org/20150729/Introducing-nuget-uwp.html"><strong>NuGet team blog</strong></a> <strong>, Microsoft's solution is the "<span style="color: #0000ff;">dotnet</span>" TxM. You won't author NuGet package <em>"for a particular platform or set of platforms" </em>any longer. Instead you will author your NuGet package for "<span style="color: #0000ff;">dotnet</span>", and you will call out which particular APIs your package depends upon. This way your package will install fine <em>on any platform</em>, past present or future, which can offer those APIs. </strong>

For instance, if your code uses <em>List&lt;T&gt;</em> internally, then you'll author your NuGet package with a dependency on Microsoft's <em>System.Collections</em> NuGet package since that's where List&lt;T&gt; is implemented. Your package will install fine on every platform that System.Collections can be installed onto. (Microsoft will author their System.Collections package with diligence, and will be quick to make sure it's updated for all new platforms…) Let's look at some interesting platforms…
<ul>
	<li><strong>.NET46.</strong> This is the framework that's installed as part of the Windows Desktop+Server operating system. If you write an app which targets this, and you add a reference to the System.Collections NuGet package, all it says is " <em>nothing to do here since System.Collections is already part of the OS platform which this code will run on</em>".&nbsp;</li>
	<li><strong>UAP10.0 (Windows 10 Universal Apps) and DNXCORE50 (ASP.Net 5 Core).</strong> These platforms expect apps to carry their .NET runtime and framework with them, app-locally. If you write an app which targets either of these platforms, and you add a reference to the System.Collections NuGet package, then it copies the actual DLL which implements <em>List&lt;T&gt; </em> right there into your application's "bin" directory, adjacent to your EXE.</li>
</ul>
Here's a subtle but practical question… Why is <strong>uap10.0</strong> in the same row as <strong>win81</strong>? Let's walk through these platforms: The win81 platform is guaranteed to provide lots of .NET APIs since they're part of the operating system. When you do File&gt;New&gt;Universal&gt;Blank to create a new uap10.0 app then it creates a project which includes all those APIs (and more) app-locally via NuGet references. <em>The app author is at liberty to delete those NuGet references, resulting in something with fewer .NET APIs that win81.</em> So how can the table honestly say that uap10.0 is in the same row and bigger than win81?

Well, uap10.0 is in the same row as win81 simply because that reflects the rules that NuGet uses for judging compatibility. As for the possibility that an app might delete their default NuGet references from their app? You as a NuGet package author must defend against this by specifying <em>dependencies</em> on everything you depend upon.
It seems likely all of Microsoft's future .NET platforms will operate the same way as UAP10.0 and DNXCORE50: they won't expect the .NET framework to be part of the operating system, they will instead expect it to be delivered app-locally via NuGet packages, and the way to target them will be to author your NuGet packages with "dotnet".

Just how large are we talking? The .NET runtime and framework together add up to ~20mb, which seems a lot. On platforms that use .NET Native, this strips away everything that you're not using and gets it down to ~6mb. On platforms that don't, you can probably expect disk-deduplication or other techniques to reduce the footprint to something manageable.
Color code for the above table:
<table class="MsoTableGrid" style="border: currentColor; border-collapse: collapse;" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td style="width: 49.25pt; background: #F4B083; padding: 0in 5.4pt 0in 5.4pt;" valign="top" width="99">
<p style="margin-bottom: .0001pt; line-height: normal;"><em> </em></p>
</td>
<td style="width: 418.25pt; padding: 0in 5.4pt 0in 5.4pt;" valign="top" width="837">
<p style="margin-bottom: .0001pt; line-height: normal;"><em> Red: These are older platforms that are not recommended for future development. When you code for these then your DLL generally references "mscorlib" (which makes it hard to know which APIs you're using and impossible to use on new platforms). And/or these platforms lack modern language functionality such as async/await. </em></p>
</td>
</tr>
<tr>
<td style="width: 49.25pt; background: #FFD966; padding: 0in 5.4pt 0in 5.4pt;" valign="top" width="99">
<p style="margin-bottom: .0001pt; line-height: normal;"><em> </em></p>
</td>
<td style="width: 418.25pt; padding: 0in 5.4pt 0in 5.4pt;" valign="top" width="837">
<p style="margin-bottom: .0001pt; line-height: normal;"><em> Yellow: by all means support them. When you code for these then your DLL references "contracts" from which you can easily figure out which APIs (i.e. which NuGet packages) your library depends upon. These platforms provide a modern base level of functionality. </em></p>
&nbsp;</td>
</tr>
<tr>
<td style="width: 49.25pt; border: none; border-bottom: double red 4.5pt; background: #A8D08D; padding: 0in 5.4pt 0in 5.4pt;" valign="top" width="99">
<p style="margin-bottom: .0001pt; line-height: normal;"><em> </em></p>
</td>
<td style="width: 418.25pt; padding: 0in 5.4pt 0in 5.4pt;" valign="top" width="837">
<p style="margin-bottom: .0001pt; line-height: normal;"><em> Green: these platforms are the future. If you write a DLL which targets only green platforms, then it will be built from the ground up with NuGet dependencies. </em></p>
&nbsp;</td>
</tr>
<tr>
<td style="width: 49.25pt; border: double red 4.5pt; border-top: none; background: #A8D08D; padding: 0in 5.4pt 0in 5.4pt;" valign="top" width="99">
<p style="margin-bottom: .0001pt; line-height: normal;"><em> </em></p>
</td>
<td style="width: 418.25pt; border: none; padding: 0in 5.4pt 0in 5.4pt;" valign="top" width="837">
<p style="margin-bottom: .0001pt; line-height: normal;"><em> Green with red border: these platforms don't assume that .NET is part of the platform. Everything -- the .NET runtime, Microsoft's .NET framework libraries, third-party libraries --all are referenced as NuGet packages and deployed app-locally. </em></p>
</td>
</tr>
<tr>
<td style="width: 49.25pt; border: none; border-top: double red 4.5pt; padding: 0in 5.4pt 0in &lt;/p&gt;&lt;p&gt;5.4pt; text-align: right;" valign="top" width="99">
<p style="margin-bottom: .0001pt; line-height: normal;">*</p>
</td>
<td style="width: 418.25pt; padding: 0in 5.4pt 0in 5.4pt;" valign="top" width="837">
<p style="margin-bottom: .0001pt; line-height: normal;">"win" and "windows" can be used interchangeably.
"wp" and "windowsphone" can be used interchangeably.
"net" can be omitted; it is the default</p>
</td>
</tr>
</tbody>
</table>
<h1>A worked example</h1>
Goal: <em> I wish to write NuGet package which can be used by as many project types as possible. However, I'm only going to bother making it work on &gt;=.NET45 project types, i.e. ones where I can use modern features like Async/Await and CallerMemberInfo without fuss. Also, my package uses Json.Net internally. </em>

NuGet is hugely expressive. There's a many goals you can achieve, and a large number of ways to accomplish any one goal. I can't explain everything. So what I'll do is pick just one goal, present my solution, explain my rationale for it, and describe the under-the-hood algorithms that NuGet uses. From that you'll be able to figure out how to accomplish your own goals.
<h1>Step 1: Create the DLL</h1>
Do File &gt; New &gt; ClassLibrary (Portable) and pick the following targets. This is sometimes known as a "Profile 259 PCL" [ <a href="http://embed.plnkr.co/03ck2dCtnJogBKHJ9EjY/preview">see this webpage for why</a>].

<strong><img id="Profile259 PCL targets" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/12/06/UWP/2605.pcl-targets.png" alt="" width="379" height="382" border="0" /></strong>

<em>Rationale:</em> As NuGet package authors we start by thinking about all the platforms that we want our package to be used by. I referred to the Master Table earlier in this document and for each row (i.e. each possible target platform), I picked the oldest version that was still yellow. That gives me the widest reach, without bogging myself down into the difficult-and-niche areas.

<span style="color: #ff0000;">Exception: I have to <em>unselect</em> the ASP.NET Core 5.0 checkbox</span>. This is counter-intuitive since my DLL will still run fine on ASP.NET 5, thanks to being in a NuGet package with "dependencies". It's just a point-in-time bug that will be fixed in the first VS2015 update.

Note: the bottom three "Xamarin" rows appear in the dialog because I've installed the Xamarin tools into VS. But even if you haven't installed the Xamarin tools, no matter: these three checkboxes are <em>placebos</em>, since the other checkmarks <em>implicitly imply</em> that my PCL will also work on Xamarin.
<strong>Portable Class Library</strong>. <em>I want PCLs to be able to consume my NuGet package</em>. The deal is: given that I create my ClassLibrary1.dll with the targets above, then my ClassLibrary1.dll can be consumed by any PCL whose targets are <em>the same or more relaxed</em>. A more relaxed set of targets is where either some rows are unchecked, or they're switched to higher versions. (Thus, to make my library maximally consumable, that's why I checked as many targets as I could, and picked versions as low as possible).
<strong>Testing that my PCL can be consumed by the different project types</strong>. This step isn't strictly necessary but it's useful. And indeed this is how I debug my PCLs.

For all project types that I want to consume my NuPkg, I can actually first try having them reference my PCL directly -- either with a Project-to-Project "P2P" reference (Reference &gt; AddReference &gt; Solution &gt; ClassLibrary1) or with a raw file reference (References &gt; AddReference &gt; Browse).

There are a few known limitations:
<ul>
	<li>You can't P2P reference your <em>Profile259 PCL</em> from a <em>Modern PCL</em> that has ASP.NET Core checked. (A "Profile259 PCL" is one whose targets are as picked at the top of this section; a <em>Modern PCL</em> is one whose targets are limited to amongst .NET46, Win10, ASP.NET Core). This is a point-in-time bug that will be fixed in the first VS2015 update. As a workaround you can still do a raw file reference. And once you turn your PCL into a NuGet package then it will work fine. Another workaround, for testing purposes, is to just go to your consuming project's targets and remove ASP.NET Core and then the P2P reference will work.</li>
	<li>You can't P2P reference your Profile259 PCL from a "DNX" project (i.e. ASP.Net 5). And you can't even add a raw file reference because the "Browse" button doesn't work in DNX projects. Don't worry. Once you turn your PCL into a NuGet package then it will work fine.</li>
</ul>
&nbsp;

<strong>Test in .NET Native</strong>. I urge everyone to test their libraries from a Win10 application ("UWP") in Release mode. That's especially true if your library uses reflection or serialization in any way.

"UWP Release mode" is the first .NET platform to use <em>Ahead-Of-Time "AOT" compilation</em>: it compiles the application and its libraries into native machine code; later, when the app is then deployed and run on customer machines, it no longer even uses the CLR! (As you can imagine, native machine code has a harder time with reflection and serialization than does the CLR). I wouldn't be surprised to see AOT on more .NET platforms in future. That's why I'd prefer to validate my library right now while I'm first architecting it, rather than having to work around issues after-the-fact.

If your library runs into problems, there's a technique called " <a href="http://blogs.msdn.com/b/dotnet/archive/2014/05/24/net-native-deep-dive-optimizing-with-runtime-&lt;/p&gt;
&lt;p&gt;directives.aspx">rd.xml</a> files" by which your library can provide hints to the AOT compiler. If you discover you need these, then the rd.xml file should be deployed in your NuGet package. Best way to do this is to set the build action for your rd.xml to be "embedded resource" - more details <a href="http://blogs.msdn.com/b/dotnet/archive/2014/05/23/net-native-deep-dive-making-your-library-great.aspx">here</a>.
<h1>Step 2: plan the NuPkg directory structure</h1>
My NuPkg will have the following structure. Note that there are two identical copies of ClassLibrary1.dll in it.
<p style="margin-left: .5in; background: #F2F2F2;"><span style="font-size: 9.0pt; line-height: 107%; font-family: Consolas; color: #0070c0;">WorkedExample.1.0.0.0.nupkg
+-- WorkedExample.nuspec
+-- lib
+-- dotnet
|    +-- ClassLibrary1.dll
+-- portable-net45+win8+wpa81+wp8
+-- ClassLibrary1.dll</span></p>
<em>Rationale</em> . This requires an in-depth explanation. I want to start by saying that the "<strong>lib\dotnet</strong>" subdirectory is the way of the future. We recommend using the dotnet folder structure as a best-practice for all packages that expect to target multiple platforms. The only reason I have an additional subdirectory in here is so that my NuGet can be consumed by traditional PCLs, which can't consume the "lib\dotnet" subdirectory. This table shows which directories are used by which project types:
<table class="MsoTable15Grid1LightAccent5" style="border: currentColor; border-collapse: collapse;" border="1" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td style="width: 188.75pt; border: solid #B4C6E7 1.0pt; border-bottom: solid #8EAADB 1.5pt; padding: 0in 5.4pt 0in 5.4pt;" valign="top" width="378">
<p style="margin-bottom: .0001pt; line-height: normal;"><strong>Directory</strong></p>
</td>
<td style="width: 278.75pt; border-top: solid #B4C6E7 1.0pt; border-left: none; border-bottom: solid #8EAADB 1.5pt; border-right: solid #B4C6E7 1.0pt; padding: 0in 5.4pt 0in 5.4pt;" valign="top" width="558">
<p style="margin-bottom: .0001pt; line-height: normal;"><strong>Used by these project types</strong></p>
</td>
</tr>
<tr>
<td style="width: 188.75pt; border: solid #B4C6E7 1.0pt; border-top: none; padding: 0in 5.4pt 0in &lt;/p&gt;&lt;p&gt;5.4pt;" valign="top" width="378">
<p style="margin-bottom: .0001pt; line-height: normal;"><em>&lt;no match; fails to install&gt;</em></p>
</td>
<td style="width: 278.75pt; border-top: none; border-left: none; border-bottom: solid #B4C6E7 &lt;/p&gt;&lt;p&gt;1.0pt; border-right: solid #B4C6E7 1.0pt; padding: 0in 5.4pt 0in 5.4pt;" valign="top" width="558">
<p style="margin-bottom: .0001pt; line-height: normal;">Any platform &lt; .NET45</p>
</td>
</tr>
<tr>
<td style="width: 188.75pt; border: solid #B4C6E7 1.0pt; border-top: none; padding: 0in 5.4pt 0in &lt;/p&gt;&lt;p&gt;5.4pt;" valign="top" width="378">
<p style="margin-bottom: .0001pt; line-height: normal;">lib\portable-net45+win8+wpa81+wp8</p>
</td>
<td style="width: 278.75pt; border-top: none; border-left: none; border-bottom: solid #B4C6E7 &lt;/p&gt;&lt;p&gt;1.0pt; border-right: solid #B4C6E7 1.0pt; padding: 0in 5.4pt 0in 5.4pt;" valign="top" width="558">
<p style="margin-bottom: .0001pt; line-height: normal;">Traditional PCLs.</p>
</td>
</tr>
<tr>
<td style="width: 188.75pt; border: solid #B4C6E7 1.0pt; border-top: none; padding: 0in 5.4pt 0in &lt;/p&gt;&lt;p&gt;5.4pt;" valign="top" width="378">
<p style="margin-bottom: .0001pt; line-height: normal;">lib\dotnet</p>
</td>
<td style="width: 278.75pt; border-top: none; border-left: none; border-bottom: solid #B4C6E7 &lt;/p&gt;&lt;p&gt;1.0pt; border-right: solid #B4C6E7 1.0pt; padding: 0in 5.4pt 0in 5.4pt;" valign="top" width="558">
<p style="margin-bottom: .0001pt; line-height: normal;">Everything else (e.g. UWP apps, .NET Framework apps, Xamarin apps, Modern PCLs)</p>
</td>
</tr>
</tbody>
</table>
<em>NuGet algorithm</em> . How can you figure out which lib\subdirectories you need? And how can you figure out which project types will use which lib\subdirectory? Here I'll spell out the algorithm that NuGet uses. When you have a project which wants to consume a NuGet package, NuGet will look at your project type, and look at the name of all the lib\subdirectories, and figure out which single subdirectory is the "best match". The rules for best-match are complicated, and depend crucially on the Master Table earlier in this article.
<ul>
	<li><strong>If your project isn't a portable class library</strong>, then it uses these tie-breakers in order to search for the best match…
<ol>
	<li>Look for an "exact match platform". For instance, if your project is "uap10.0" and there is a subdirectory called "lib\uap10.0" then use it.</li>
	<li>Failing that, look for an earlier version of the platform or for the unnumbered code for that platform (i.e. in the Master Table, look in the same row, but further to the left)
<ul>
	<li>Example: if the project is .NET45, and there's no "lib\net45" subdirectory, then look for "lib\net40", failing that "lib\net35" and so on.</li>
	<li>Example: if the project is UWP and there's no "lib\uap10.0" subdirectory, then look for "lib\uap", failing that "lib\win81" or "lib\netcore451", and so on.</li>
</ul>
</li>
	<li><span style="color: #ff0000;">Failing that, and if your project is &gt;=45, then look for "lib\dotnet"</span></li>
	<li>Failing that, look for all subdirectories of the form "lib\portable-xyz" where your project type is amongst those "xyz" as per rules 1..4. Amongst all of those portable-* candidates, there's a rule for picking the best one, but I don't know it.</li>
	<li>Failing that, <span style="color: #ff0000;">packages.config used to look just in the root "lib\" folder, but that functionality is no longer supported in packages.json. If your nupkg used to put DLLs directly in the root "lib\" folder then it has to change.</span></li>
</ol>
</li>
	<li><strong>If your project is a PCL<span style="color: #ff0000;">,</span></strong>
<ol>
	<li><span style="color: #ff0000;">If your project is a "modern PCL" and there exists a subdirectory "lib\dotnet", then use it.</span> (A "modern PCL" is one which targets some or all of .NET46, Win10 and ASP.NetCore, and which targets nothing other than those three.)</li>
	<li>Failing that, calculate your project's targets. In the case of a traditional PCL, the targets are those listed in the PCL targets dialog. In the case of a modern PCL, I don't know what the targets are. Then look for a lib subdirectory that is an exact match for your project's targets.</li>
	<li>Failing that, look for the best-match "lib\portable-*" subdirectory. I don't know the rules for "best-match" in this case.</li>
</ol>
</li>
</ul>
Attentive readers might spot that I could have got away with just a single subdirectory, called "portable-net45+win8+wpa81+wp8+dnxcore50". That's possible, but not best-practice. Best practice is to embrace the "<strong>lib\dotnet</strong>" folder. The reason for this approach is to make it easier on you the package author. It's so that your NuGet package will continue to work when Microsoft or Xamarin or anyone else introduces a new platform that isn't net/win/wpa/wp/dnxcore, but yet still does understand lib\dotnet.
<h1>Step 3: Craft the .nuspec dependencies</h1>
I create a .nuspec file as follows. This .nuspec file should be part of your project. We will discuss the &lt;dependencies&gt; section below...
<p style="margin-bottom: .0001pt; line-height: normal; text-autospace: none;"><span style="font-&lt;/p&gt;&lt;p&gt;size: 9.5pt; font-family: Consolas; color: blue; background: white;">&lt;?</span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">xml</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;"> </span><span style="font-size: 9.5pt; font-family: Consolas; color: red; background: white;">version</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">=</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">1.0</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">?&gt;</span>
<span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">&lt;</span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">package</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">&gt;</span>
<span style="font-size: 9.5pt; font-&lt;/p&gt;&lt;p&gt;family: Consolas; color: blue; background: white;"> &lt;</span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">metadata</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">&gt;</span>
<span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;"> &lt;</span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">id</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">&gt;</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">SampleNuGetPackage</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">&lt;/</span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">id</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">&gt;</span>
<span style="font-size: 9.5pt; font-&lt;/p&gt;&lt;p&gt;family: Consolas; color: blue; background: white;"> &lt;</span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">version</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">&gt;</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">1.0.0.2</span><span style="font-&lt;/p&gt;&lt;p&gt;size: 9.5pt; font-family: Consolas; color: blue; background: white;">&lt;/</span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">version</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">&gt;</span>
<span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;"> &lt;</span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">title</span><span style="font-size: 9.5pt; font-&lt;/p&gt;&lt;p&gt;family: Consolas; color: blue; background: white;">&gt;</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">Sample NuGet Package</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">&lt;/</span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">title</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">&gt;</span>
<span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;"> &lt;</span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">authors</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">&gt;</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">Lucian Wischik</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">&lt;/</span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">authors</span><span style="font-size: 9.5pt; font-&lt;/p&gt;&lt;p&gt;family: Consolas; color: blue; background: white;">&gt;</span>
<span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;"> &lt;</span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">owners</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">&gt;</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">Lucian Wischik</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">&lt;/</span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">owners</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">&gt;</span>
<span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;"> &lt;</span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">requireLicenseAcceptance</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">&gt;</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">false</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">&lt;/</span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">requireLicenseAcceptance</span><span style="font-&lt;/p&gt;&lt;p&gt;size: 9.5pt; font-family: Consolas; color: blue; background: white;">&gt;</span>
<span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;"> &lt;</span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">description</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">&gt;</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">This is a demo portable .NET class library</span><span style="font-&lt;/p&gt;&lt;p&gt;size: 9.5pt; font-family: Consolas; color: blue; background: white;">&lt;/</span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">description</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">&gt;</span>
<span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;"> &lt;</span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">summary</span><span style="font-size: 9.5pt; font-&lt;/p&gt;&lt;p&gt;family: Consolas; color: blue; background: white;">&gt;</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">It is referencable by all &gt;=.NET45 clients, including WindowsStore and Phone</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">&lt;/</span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">summary</span><span style="font-size: 9.5pt; font-&lt;/p&gt;&lt;p&gt;family: Consolas; color: blue; background: white;">&gt;</span>
<span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;"> &lt;</span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">dependencies</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">&gt;</span>
<span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;"> &lt;</span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">group</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;"> </span><span style="font-&lt;/p&gt;&lt;p&gt;size: 9.5pt; font-family: Consolas; color: red; background: white;">targetFramework</span> <span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">=</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">net</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">&gt;</span>
<span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;"> &lt;</span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">dependency</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;"> </span><span style="font-size: 9.5pt; font-family: Consolas; color: red; background: white;">id</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">=</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">Newtonsoft.Json</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;"> </span><span style="font-size: 9.5pt; font-family: Consolas; color: red; background: white;">version</span><span style="font-size: 9.5pt; font-&lt;/p&gt;&lt;p&gt;family: Consolas; color: blue; background: white;">=</span><span style="font-size: 9.5pt; font-&lt;/p&gt;&lt;p&gt;family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.5pt; font-&lt;/p&gt;&lt;p&gt;family: Consolas; color: blue; background: white;">7.0.1</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;"> /&gt;</span>
<span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;"> &lt;/</span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">group</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">&gt;</span>
<span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;"> &lt;</span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">group</span><span style="font-&lt;/p&gt;&lt;p&gt;size: 9.5pt; font-family: Consolas; color: blue; background: white;"> </span><span style="font-size: 9.5pt; font-family: Consolas; color: red; background: white;">targetFramework</span> <span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">=</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">win</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">&gt;</span>
<span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;"> &lt;</span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">dependency</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;"> </span><span style="font-size: 9.5pt; font-family: Consolas; color: red; background: white;">id</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">=</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">Newtonsoft.Json</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;"> </span><span style="font-size: 9.5pt; font-family: Consolas; color: red; background: white;">version</span><span style="font-size: 9.5pt; font-&lt;/p&gt;&lt;p&gt;family: Consolas; color: blue; background: white;">=</span><span style="font-size: 9.5pt; font-&lt;/p&gt;&lt;p&gt;family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.5pt; font-&lt;/p&gt;&lt;p&gt;family: Consolas; color: blue; background: white;">7.0.1</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;"> /&gt;</span>
<span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;"> &lt;/</span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">group</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">&gt;</span>
<span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;"> &lt;</span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">group</span><span style="font-&lt;/p&gt;&lt;p&gt;size: 9.5pt; font-family: Consolas; color: blue; background: white;"> </span><span style="font-size: 9.5pt; font-family: Consolas; color: red; background: white;">targetFramework</span> <span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">=</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">wp</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">&gt;</span>
<span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;"> &lt;</span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">dependency</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;"> </span><span style="font-size: 9.5pt; font-family: Consolas; color: red; background: white;">id</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">=</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">Newtonsoft.Json</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;"> </span><span style="font-size: 9.5pt; font-family: Consolas; color: red; background: white;">version</span><span style="font-size: 9.5pt; font-&lt;/p&gt;&lt;p&gt;family: Consolas; color: blue; background: white;">=</span><span style="font-size: 9.5pt; font-&lt;/p&gt;&lt;p&gt;family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.5pt; font-&lt;/p&gt;&lt;p&gt;family: Consolas; color: blue; background: white;">7.0.1</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;"> /&gt;</span>
<span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;"> &lt;/</span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">group</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">&gt;</span>
<span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;"> &lt;</span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">group</span><span style="font-&lt;/p&gt;&lt;p&gt;size: 9.5pt; font-family: Consolas; color: blue; background: white;"> </span><span style="font-size: 9.5pt; font-family: Consolas; color: red; background: white;">targetFramework</span> <span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">=</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">wpa</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">&gt;</span>
<span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;"> &lt;</span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">dependency</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;"> </span><span style="font-size: 9.5pt; font-family: Consolas; color: red; background: white;">id</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">=</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">Newtonsoft.Json</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;"> </span><span style="font-size: 9.5pt; font-family: Consolas; color: red; background: white;">version</span><span style="font-size: 9.5pt; font-&lt;/p&gt;&lt;p&gt;family: Consolas; color: blue; background: white;">=</span><span style="font-size: 9.5pt; font-&lt;/p&gt;&lt;p&gt;family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.5pt; font-&lt;/p&gt;&lt;p&gt;family: Consolas; color: blue; background: white;">7.0.1</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;"> /&gt;</span>
<span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;"> &lt;/</span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">group</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">&gt;</span>
<span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;"> &lt;</span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">group</span><span style="font-&lt;/p&gt;&lt;p&gt;size: 9.5pt; font-family: Consolas; color: blue; background: white;"> </span><span style="font-size: 9.5pt; font-family: Consolas; color: red; background: white;">targetFramework</span> <span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">=</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">MonoAndroid</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">&gt;</span>
<span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;"> &lt;</span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">dependency</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;"> </span><span style="font-size: 9.5pt; font-family: Consolas; color: red; background: white;">id</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">=</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">Newtonsoft.Json</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;"> </span><span style="font-size: 9.5pt; font-family: Consolas; color: red; background: white;">version</span><span style="font-size: 9.5pt; font-&lt;/p&gt;&lt;p&gt;family: Consolas; color: blue; background: white;">=</span><span style="font-size: 9.5pt; font-&lt;/p&gt;&lt;p&gt;family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.5pt; font-&lt;/p&gt;&lt;p&gt;family: Consolas; color: blue; background: white;">7.0.1</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;"> /&gt;</span>
<span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;"> &lt;/</span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">group</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">&gt;</span>
<span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;"> &lt;</span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">group</span><span style="font-&lt;/p&gt;&lt;p&gt;size: 9.5pt; font-family: Consolas; color: blue; background: white;"> </span><span style="font-size: 9.5pt; font-family: Consolas; color: red; background: white;">targetFramework</span> <span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">=</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">MonoTouch</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">&gt;</span>
<span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;"> &lt;</span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">dependency</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;"> </span><span style="font-size: 9.5pt; font-family: Consolas; color: red; background: white;">id</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">=</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">Newtonsoft.Json</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;"> </span><span style="font-size: 9.5pt; font-family: Consolas; color: red; background: white;">version</span><span style="font-size: 9.5pt; font-&lt;/p&gt;&lt;p&gt;family: Consolas; color: blue; background: white;">=</span><span style="font-size: 9.5pt; font-&lt;/p&gt;&lt;p&gt;family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.5pt; font-&lt;/p&gt;&lt;p&gt;family: Consolas; color: blue; background: white;">7.0.1</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;"> /&gt;</span>
<span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;"> &lt;/</span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">group</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">&gt;</span>
<span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;"> &lt;</span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">group</span><span style="font-&lt;/p&gt;&lt;p&gt;size: 9.5pt; font-family: Consolas; color: blue; background: white;"> </span><span style="font-size: 9.5pt; font-family: Consolas; color: red; background: white;">targetFramework</span> <span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">=</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">Xamarin.iOS</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">&gt;</span>
<span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;"> &lt;</span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">dependency</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;"> </span><span style="font-size: 9.5pt; font-family: Consolas; color: red; background: white;">id</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">=</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">Newtonsoft.Json</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;"> </span><span style="font-size: 9.5pt; font-family: Consolas; color: red; background: white;">version</span><span style="font-size: 9.5pt; font-&lt;/p&gt;&lt;p&gt;family: Consolas; color: blue; background: white;">=</span><span style="font-size: 9.5pt; font-&lt;/p&gt;&lt;p&gt;family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.5pt; font-&lt;/p&gt;&lt;p&gt;family: Consolas; color: blue; background: white;">7.0.1</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;"> /&gt;</span>
<span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;"> &lt;/</span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">group</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">&gt;</span>
<span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;"> &lt;</span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">group</span><span style="font-&lt;/p&gt;&lt;p&gt;size: 9.5pt; font-family: Consolas; color: blue; background: white;"> </span><span style="font-size: 9.5pt; font-family: Consolas; color: red; background: white;">targetFramework</span> <span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">=</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">portable-net45+win8+wpa81+wp8</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">&gt;</span>
<span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;"> &lt;</span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">dependency</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;"> </span><span style="font-size: 9.5pt; font-&lt;/p&gt;&lt;p&gt;family: Consolas; color: red; background: white;">id</span><span style="font-size: 9.5pt; font-&lt;/p&gt;&lt;p&gt;family: Consolas; color: blue; background: white;">=</span><span style="font-size: 9.5pt; font-&lt;/p&gt;&lt;p&gt;family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.5pt; font-&lt;/p&gt;&lt;p&gt;family: Consolas; color: blue; background: white;">Newtonsoft.Json</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;"> </span><span style="font-&lt;/p&gt;&lt;p&gt;size: 9.5pt; font-family: Consolas; color: red; background: white;">version</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">=</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">7.0.1</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;"> /&gt;</span>
<span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;"> &lt;/</span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">group</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">&gt;</span>
<span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;"> &lt;</span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">group</span><span style="font-&lt;/p&gt;&lt;p&gt;size: 9.5pt; font-family: Consolas; color: blue; background: white;"> </span><span style="font-size: 9.5pt; font-family: Consolas; color: red; background: white;">targetFramework</span> <span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">=</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">uap</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">&gt;</span>
<span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;"> &lt;</span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">dependency</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;"> </span><span style="font-size: 9.5pt; font-family: Consolas; color: red; background: white;">id</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">=</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">Newtonsoft.Json</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;"> </span><span style="font-size: 9.5pt; font-family: Consolas; color: red; background: white;">version</span><span style="font-size: 9.5pt; font-&lt;/p&gt;&lt;p&gt;family: Consolas; color: blue; background: white;">=</span><span style="font-size: 9.5pt; font-&lt;/p&gt;&lt;p&gt;family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.5pt; font-&lt;/p&gt;&lt;p&gt;family: Consolas; color: blue; background: white;">7.0.1</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;"> /&gt;</span>
<span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;"> &lt;</span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">dependency</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;"> </span><span style="font-size: 9.5pt; font-&lt;/p&gt;&lt;p&gt;family: Consolas; color: red; background: white;">id</span><span style="font-size: 9.5pt; font-&lt;/p&gt;&lt;p&gt;family: Consolas; color: blue; background: white;">=</span><span style="font-size: 9.5pt; font-&lt;/p&gt;&lt;p&gt;family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.5pt; font-&lt;/p&gt;&lt;p&gt;family: Consolas; color: blue; background: white;">System.Runtime</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;"> </span><span style="font-&lt;/p&gt;&lt;p&gt;size: 9.5pt; font-family: Consolas; color: red; background: white;">version</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">=</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">4.0.0</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">/&gt;</span>
<span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;"> &lt;</span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">dependency</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;"> </span><span style="font-size: 9.5pt; font-&lt;/p&gt;&lt;p&gt;family: Consolas; color: red; background: white;">id</span><span style="font-size: 9.5pt; font-&lt;/p&gt;&lt;p&gt;family: Consolas; color: blue; background: white;">=</span><span style="font-size: 9.5pt; font-&lt;/p&gt;&lt;p&gt;family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.5pt; font-&lt;/p&gt;&lt;p&gt;family: Consolas; color: blue; background: white;">System.Resources.ResourceManager</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;"> </span><span style="font-size: 9.5pt; font-family: Consolas; color: red; background: white;">version</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">=</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">4.0.0</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">/&gt;</span>
<span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;"> &lt;</span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">dependency</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;"> </span><span style="font-size: 9.5pt; font-family: Consolas; color: red; background: white;">id</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">=</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">System.Collections</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;"> </span><span style="font-size: 9.5pt; font-family: Consolas; color: red; background: white;">version</span><span style="font-size: 9.5pt; font-&lt;/p&gt;&lt;p&gt;family: Consolas; color: blue; background: white;">=</span><span style="font-size: 9.5pt; font-&lt;/p&gt;&lt;p&gt;family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.5pt; font-&lt;/p&gt;&lt;p&gt;family: Consolas; color: blue; background: white;">4.0.0</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">/&gt;</span>
<span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;"> &lt;</span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">dependency</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;"> </span><span style="font-size: 9.5pt; font-&lt;/p&gt;&lt;p&gt;family: Consolas; color: red; background: white;">id</span><span style="font-size: 9.5pt; font-&lt;/p&gt;&lt;p&gt;family: Consolas; color: blue; background: white;">=</span><span style="font-size: 9.5pt; font-&lt;/p&gt;&lt;p&gt;family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.5pt; font-&lt;/p&gt;&lt;p&gt;family: Consolas; color: blue; background: white;">System.Linq</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;"> </span><span style="font-&lt;/p&gt;&lt;p&gt;size: 9.5pt; font-family: Consolas; color: red; background: white;">version</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">=</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">4.0.0</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">/&gt;</span>
<span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;"> &lt;/</span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">group</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">&gt;</span>
<span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;"> &lt;</span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">group</span><span style="font-&lt;/p&gt;&lt;p&gt;size: 9.5pt; font-family: Consolas; color: blue; background: white;"> </span><span style="font-size: 9.5pt; font-family: Consolas; color: red; background: white;">targetFramework</span> <span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">=</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">dotnet</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">&gt;</span>
<span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;"> &lt;</span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">dependency</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;"> </span><span style="font-size: 9.5pt; font-family: Consolas; color: red; background: white;">id</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">=</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">Newtonsoft.Json</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;"> </span><span style="font-size: 9.5pt; font-family: Consolas; color: red; background: white;">version</span><span style="font-size: 9.5pt; font-&lt;/p&gt;&lt;p&gt;family: Consolas; color: blue; background: white;">=</span><span style="font-size: 9.5pt; font-&lt;/p&gt;&lt;p&gt;family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.5pt; font-&lt;/p&gt;&lt;p&gt;family: Consolas; color: blue; background: white;">7.0.1</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;"> /&gt;</span>
<span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;"> &lt;</span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">dependency</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;"> </span><span style="font-size: 9.5pt; font-&lt;/p&gt;&lt;p&gt;family: Consolas; color: red; background: white;">id</span><span style="font-size: 9.5pt; font-&lt;/p&gt;&lt;p&gt;family: Consolas; color: blue; background: white;">=</span><span style="font-size: 9.5pt; font-&lt;/p&gt;&lt;p&gt;family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.5pt; font-&lt;/p&gt;&lt;p&gt;family: Consolas; color: blue; background: white;">System.Runtime</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;"> </span><span style="font-&lt;/p&gt;&lt;p&gt;size: 9.5pt; font-family: Consolas; color: red; background: white;">version</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">=</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">4.0.0</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">/&gt;</span>
<span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;"> &lt;</span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">dependency</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;"> </span><span style="font-size: 9.5pt; font-&lt;/p&gt;&lt;p&gt;family: Consolas; color: red; background: white;">id</span><span style="font-size: 9.5pt; font-&lt;/p&gt;&lt;p&gt;family: Consolas; color: blue; background: white;">=</span><span style="font-size: 9.5pt; font-&lt;/p&gt;&lt;p&gt;family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.5pt; font-&lt;/p&gt;&lt;p&gt;family: Consolas; color: blue; background: white;">System.Resources.ResourceManager</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;"> </span><span style="font-size: 9.5pt; font-family: Consolas; color: red; background: white;">version</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">=</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">4.0.0</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">/&gt;</span>
<span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;"> &lt;</span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">dependency</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;"> </span><span style="font-size: 9.5pt; font-family: Consolas; color: red; background: white;">id</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">=</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">System.Collections</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;"> </span><span style="font-size: 9.5pt; font-family: Consolas; color: red; background: white;">version</span><span style="font-size: 9.5pt; font-&lt;/p&gt;&lt;p&gt;family: Consolas; color: blue; background: white;">=</span><span style="font-size: 9.5pt; font-&lt;/p&gt;&lt;p&gt;family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.5pt; font-&lt;/p&gt;&lt;p&gt;family: Consolas; color: blue; background: white;">4.0.0</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">/&gt;</span>
<span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;"> &lt;</span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">dependency</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;"> </span><span style="font-size: 9.5pt; font-&lt;/p&gt;&lt;p&gt;family: Consolas; color: red; background: white;">id</span><span style="font-size: 9.5pt; font-&lt;/p&gt;&lt;p&gt;family: Consolas; color: blue; background: white;">=</span><span style="font-size: 9.5pt; font-&lt;/p&gt;&lt;p&gt;family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.5pt; font-&lt;/p&gt;&lt;p&gt;family: Consolas; color: blue; background: white;">System.Linq</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;"> </span><span style="font-&lt;/p&gt;&lt;p&gt;size: 9.5pt; font-family: Consolas; color: red; background: white;">version</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">=</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">4.0.0</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">/&gt;</span>
<span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;"> &lt;/</span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">group</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">&gt;</span>
<span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;"> &lt;/</span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">dependencies</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">&gt;</span>
<span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;"> &lt;/</span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">metadata</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">&gt;</span>
<span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">&lt;/</span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">package</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">&gt;</span></p>
<em>Goal.</em> My DLL depends on certain other DLLs. I must ensure that when an app references my NuGet package then it also transitively references certain other NuGet packages that contain those other DLLs. The exact set of DLLs that I depend upon varies by platform. I don't want to cause an app to take on more NuGet dependencies than it strictly needs. (This is particularly important for traditional packages.config projects, where each additional NuGet dependency looks poor in Solution Explorer &gt; References, and is awkward to uninstall via Manage NuGet References).
<strong>There's a tool to auto-generate the dependencies</strong> . Oren Novotny has written a great tool called <a href="https://www.nuget.org/packages/NuSpec.ReferenceGenerator/1.0.1">NuSpec.ReferenceGenerator</a>. It's a NuGet package. You add it do your class-library project, and automatically generates the correct dependencies in the .nuspec file within your project.

In the rest of this section I'm going to explain how to do stuff manually instead of using the tool. This is merely so you can understand what's going on under-the-hood, or in case the tool doesn't work for whatever reason. Let's first take stock of what we know...

<strong>Source code</strong> . My library project's source code is listed below. The code is obviously using Json.Net, and Linq, and List&lt;T&gt;, and String.Format.
<p style="line-&lt;/p&gt;&lt;p&gt;height: normal; text-autospace: none; margin: 0in 0in .0001pt .5in;"><span style="font-size: 9.0pt; font-family: Consolas; color: blue; background: white;">Public</span><span style="font-size: 9.0pt; font-family: Consolas; color: black; background: white;"> </span><span style="font-size: 9.0pt; font-&lt;/p&gt;&lt;p&gt;family: Consolas; color: blue; background: white;">Class</span><span style="font-size: 9.0pt; font-family: Consolas; color: black; background: white;"> </span><span style="font-size: 9.0pt; font-family: Consolas; color: #2b91af; background: white;">Class1</span>
<span style="font-size: 9.0pt; font-family: Consolas; color: blue; background: white;">Public</span><span style="font-size: 9.0pt; font-family: Consolas; color: black; background: white;"> </span><span style="font-size: 9.0pt; font-family: Consolas; color: blue; background: white;">Shared</span><span style="font-size: 9.0pt; font-family: Consolas; color: black; background: white;"> </span><span style="font-size: 9.0pt; font-family: Consolas; color: blue; background: white;">Function</span><span style="font-size: 9.0pt; font-&lt;/p&gt;&lt;p&gt;family: Consolas; color: black; background: white;"> f() </span><span style="font-size: 9.0pt; font-family: Consolas; color: blue; background: white;">As</span><span style="font-size: 9.0pt; font-family: Consolas; color: black; background: white;"> </span><span style="font-size: 9.0pt; font-family: Consolas; color: blue; background: white;">String</span>     <span style="font-size: 9.0pt; font-family: Consolas; color: blue; background: white;">Dim</span><span style="font-size: 9.0pt; font-family: Consolas; color: black; background: white;"> s = </span><span style="font-size: 9.0pt; font-family: Consolas; color: #a31515; background: white;">"[""hello"",""world""]"</span>
<span style="font-size: 9.0pt; font-family: Consolas; color: blue; background: white;">Dim</span><span style="font-size: 9.0pt; font-family: Consolas; color: black; background: white;"> x = Newtonsoft.Json.</span><span style="font-size: 9.0pt; font-family: Consolas; color: #2b91af; background: white;">JsonConvert</span><span style="font-size: 9.0pt; font-family: Consolas; color: black; background: white;">.DeserializeObject(</span><span style="font-size: 9.0pt; font-family: Consolas; color: blue; background: white;">Of</span><span style="font-size: 9.0pt; font-family: Consolas; color: black; background: white;"> </span><span style="font-size: 9.0pt; font-&lt;/p&gt;&lt;p&gt;family: Consolas; color: #2b91af; background: white;">List</span><span style="font-size: 9.0pt; font-family: Consolas; color: black; background: white;">(</span><span style="font-size: 9.0pt; font-family: Consolas; color: blue; background: white;">Of</span><span style="font-size: 9.0pt; font-family: Consolas; color: black; background: white;"> </span><span style="font-size: 9.0pt; font-family: Consolas; color: blue; background: white;">String</span><span style="font-&lt;/p&gt;&lt;p&gt;size: 9.0pt; font-family: Consolas; color: black; background: white;">))(s)</span>
<span style="font-size: 9.0pt; font-family: Consolas; color: blue; background: white;">Return</span><span style="font-size: 9.0pt; font-family: Consolas; color: black; background: white;"> </span><span style="font-size: 9.0pt; font-family: Consolas; color: #a31515; background: white;">$"</span><span style="font-size: 9.0pt; font-family: Consolas; color: black; background: white;">{x.First}</span><span style="font-size: 9.0pt; font-family: Consolas; color: #a31515; background: white;"> I am here"</span>
<span style="font-size: 9.0pt; font-family: Consolas; color: blue; background: white;">End</span><span style="font-size: 9.0pt; font-family: Consolas; color: black; background: white;"> </span><span style="font-size: 9.0pt; font-family: Consolas; color: blue; background: white;">Function</span></p>
<p style="line-&lt;/p&gt;&lt;p&gt;height: normal; text-autospace: none; margin: 0in 0in .0001pt .5in;"><span style="font-size: 9.0pt; font-family: Consolas; color: blue; background: white;">End</span><span style="font-size: 9.0pt; font-family: Consolas; color: black; background: white;"> </span><span style="font-size: 9.0pt; font-family: Consolas; color: blue; background: white;">Class</span></p>
&nbsp;

<strong>Packages.config</strong> . My library project's "packages.config" file is below. My library obviously depends upon Json.Net.
<p style="line-&lt;/p&gt;&lt;p&gt;height: normal; text-autospace: none; margin: 0in 0in .0001pt .5in;"><span style="font-size: 9.0pt; font-family: Consolas; color: blue; background: white;">&lt;?</span><span style="font-size: 9.0pt; font-family: Consolas; color: #a31515; background: white;">xml</span><span style="font-size: 9.0pt; font-family: Consolas; color: blue; background: white;"> </span><span style="font-size: 9.0pt; font-&lt;/p&gt;&lt;p&gt;family: Consolas; color: red; background: white;">version</span><span style="font-size: 9.0pt; font-family: Consolas; color: blue; background: white;">=</span><span style="font-size: 9.0pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.0pt; font-family: Consolas; color: blue; background: white;">1.0</span><span style="font-size: 9.0pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.0pt; font-family: Consolas; color: blue; background: white;"> </span><span style="font-size: 9.0pt; font-family: Consolas; color: red; background: white;">encoding</span><span style="font-&lt;/p&gt;&lt;p&gt;size: 9.0pt; font-family: Consolas; color: blue; background: white;">=</span><span style="font-&lt;/p&gt;&lt;p&gt;size: 9.0pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-&lt;/p&gt;&lt;p&gt;size: 9.0pt; font-family: Consolas; color: blue; background: white;">utf-8</span><span style="font-size: 9.0pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.0pt; font-family: Consolas; color: blue; background: white;">?&gt;</span>
<span style="font-size: 9.0pt; font-family: Consolas; color: blue; background: white;">&lt;</span><span style="font-size: 9.0pt; font-family: Consolas; color: #a31515; background: white;">packages</span><span style="font-size: 9.0pt; font-family: Consolas; color: blue; background: white;">&gt;</span>
<span style="font-size: 9.0pt; font-&lt;/p&gt;&lt;p&gt;family: Consolas; color: blue; background: white;"> &lt;</span><span style="font-size: 9.0pt; font-family: Consolas; color: #a31515; background: white;">package</span><span style="font-size: 9.0pt; font-family: Consolas; color: blue; background: white;"> </span><span style="font-&lt;/p&gt;&lt;p&gt;size: 9.0pt; font-family: Consolas; color: red; background: white;">id</span><span style="font-&lt;/p&gt;&lt;p&gt;size: 9.0pt; font-family: Consolas; color: blue; background: white;">=</span><span style="font-&lt;/p&gt;&lt;p&gt;size: 9.0pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-&lt;/p&gt;&lt;p&gt;size: 9.0pt; font-family: Consolas; color: blue; background: white;">Newtonsoft.Json</span><span style="font-size: 9.0pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.0pt; font-family: Consolas; color: blue; background: white;"> </span><span style="font-size: 9.0pt; font-family: Consolas; color: red; background: white;">version</span><span style="font-size: 9.0pt; font-family: Consolas; color: blue; background: white;">=</span><span style="font-size: 9.0pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.0pt; font-family: Consolas; color: blue; background: white;">7.0.1</span><span style="font-size: 9.0pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.0pt; font-family: Consolas; color: blue; background: white;"> /&gt;</span>
<span style="font-size: 9.0pt; line-height: 107%; font-family: Consolas; color: blue; background: white;">&lt;/</span><span style="font-size: 9.0pt; line-height: 107%; font-family: Consolas; color: #a31515; background: white;">packages</span><span style="font-size: 9.0pt; line-height: 107%; font-family: Consolas; color: blue; background: white;">&gt;</span></p>
<strong>Assembly manifest</strong>. I built my library, and opened the resulting DLL in the "ildasm" tool (which comes with Visual Studio 2015). The <em>MANIFEST</em> section looks like this. This provides a list of DLLs which it depends upon.
<p style="line-&lt;/p&gt;&lt;p&gt;height: normal; text-autospace: none; margin: 0in 0in .0001pt .5in;"><span style="font-size: 9.0pt; font-family: Consolas;">.assembly extern System.Runtime {.ver 4:0:0:0 }</span></p>
<p style="line-&lt;/p&gt;&lt;p&gt;height: normal; text-autospace: none; margin: 0in 0in .0001pt .5in;"><span style="font-size: 9.0pt; font-family: Consolas;">.assembly extern System.Resources.ResourceManager { .ver 4:0:0:0 }</span></p>
<p style="line-&lt;/p&gt;&lt;p&gt;height: normal; text-autospace: none; margin: 0in 0in .0001pt .5in;"><span style="font-size: 9.0pt; font-family: Consolas;">.assembly extern System.Collections { .ver 4:0:0:0 }</span></p>
<p style="line-&lt;/p&gt;&lt;p&gt;height: normal; text-autospace: none; margin: 0in 0in .0001pt .5in;"><span style="font-size: 9.0pt; font-family: Consolas;">.assembly extern Newtonsoft.Json { .ver 7:0:0:0 }</span></p>
<p style="line-&lt;/p&gt;&lt;p&gt;height: normal; text-autospace: none; margin: 0in 0in .0001pt .5in;"><span style="font-size: 9.0pt; font-family: Consolas;">.assembly extern System.Linq { .ver 4:0:0:0 }</span></p>
&nbsp;

From this I can produce the list of NuGet packages that my library depends upon:
<ol>
	<li><em>Newtonsoft.Json version 7.0.1</em>
<ol>
	<li>This comes straight from my library project's "packages.config"</li>
	<li>Note that 7.0.1 is the version of the Newtonsoft.Json <em>NuGet package</em> which I depend upon and I read this version number from packages.config; the number { .ver 7:0:0:0 } doesn't refer to a NuGet package version; it is instead the <em>assembly version</em> of the file Newtonsoft.Json.dll which is contained within that NuGet package.</li>
	<li>It's good to write the exact NuGet package version number you depend upon (rather than just writing an earlier number like 7.0.0). This way, NuGet package restore can avoid an extra search.</li>
</ol>
</li>
	<li><em> System.Runtime version 4.0.0
System.Resources.ResourceManager version 4.0.0
System.Collections version 4.0.0
System.Linq version 4.0.0 </em>
<ol>
	<li>For the .NET framework, Microsoft adopted a simple 1:1 mapping between DLL names, and the NuGet packages that contain them.</li>
	<li>(This 1:1 mapping only works because the PCL targets none of the <em>red</em> platforms in the Master Table. Those red platforms simply use <em>mscorlib</em> as a reference, which wouldn't provide any clues as to which NuGet packages are needed).</li>
	<li>I had no idea which NuGet package versions to use. So I just did File&gt;New&gt;UWP as a throwaway example of a modern platform, built it, then opened the "project.lock.json" file. From this I was able to find some typical NuGet package version numbers for each of these NuGet packages.</li>
</ol>
</li>
</ol>
<strong>Second, craft platform-specific .nuspec dependencies</strong>

Now that I have this full list of NuGet package dependencies, I could simply write it into the .nuspec file as below.

<span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;"> &lt;</span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">dependencies</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">&gt;</span>
<span style="font-size: 9.5pt; font-&lt;/p&gt;&lt;p&gt;family: Consolas; color: blue; background: white;"> &lt;</span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">dependency</span><span style="font-&lt;/p&gt;&lt;p&gt;size: 9.5pt; font-family: Consolas; color: blue; background: white;"> </span><span style="font-size: 9.5pt; font-family: Consolas; color: red; background: white;">id</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">=</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">Newtonsoft.Json</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;"> </span><span style="font-size: 9.5pt; font-family: Consolas; color: red; background: white;">version</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">=</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">7.0.1</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;"> /&gt;</span>
<span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;"> &lt;</span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">dependency</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;"> </span><span style="font-size: 9.5pt; font-family: Consolas; color: red; background: white;">id</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">=</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">System.Runtime</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;"> </span><span style="font-size: 9.5pt; font-family: Consolas; color: red; background: white;">version</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">=</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">4.0.0</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">/&gt;</span>
<span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;"> &lt;</span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">dependency</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;"> </span><span style="font-size: 9.5pt; font-&lt;/p&gt;&lt;p&gt;family: Consolas; color: red; background: white;">id</span><span style="font-size: 9.5pt; font-&lt;/p&gt;&lt;p&gt;family: Consolas; color: blue; background: white;">=</span><span style="font-size: 9.5pt; font-&lt;/p&gt;&lt;p&gt;family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.5pt; font-&lt;/p&gt;&lt;p&gt;family: Consolas; color: blue; background: white;">System.Resources.ResourceManager</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;"> </span><span style="font-size: 9.5pt; font-family: Consolas; color: red; background: white;">version</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">=</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">4.0.0</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">/&gt;</span>
<span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;"> &lt;</span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">dependency</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;"> </span><span style="font-size: 9.5pt; font-&lt;/p&gt;&lt;p&gt;family: Consolas; color: red; background: white;">id</span><span style="font-size: 9.5pt; font-&lt;/p&gt;&lt;p&gt;family: Consolas; color: blue; background: white;">=</span><span style="font-size: 9.5pt; font-&lt;/p&gt;&lt;p&gt;family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.5pt; font-&lt;/p&gt;&lt;p&gt;family: Consolas; color: blue; background: white;">System.Collections</span><span style="font-&lt;/p&gt;&lt;p&gt;size: 9.5pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-&lt;/p&gt;&lt;p&gt;size: 9.5pt; font-family: Consolas; color: blue; background: white;"> </span><span style="font-size: 9.5pt; font-family: Consolas; color: red; background: white;">version</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">=</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">4.0.0</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">/&gt;</span>
<span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;"> &lt;</span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">dependency</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;"> </span><span style="font-size: 9.5pt; font-&lt;/p&gt;&lt;p&gt;family: Consolas; color: red; background: white;">id</span><span style="font-size: 9.5pt; font-&lt;/p&gt;&lt;p&gt;family: Consolas; color: blue; background: white;">=</span><span style="font-size: 9.5pt; font-&lt;/p&gt;&lt;p&gt;family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.5pt; font-&lt;/p&gt;&lt;p&gt;family: Consolas; color: blue; background: white;">System.Linq</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;"> </span><span style="font-&lt;/p&gt;&lt;p&gt;size: 9.5pt; font-family: Consolas; color: red; background: white;">version</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">=</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">4.0.0</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">/&gt;</span>
<span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;"> &lt;/</span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">dependencies</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">&gt;</span>

This approach would certainly <em>work</em>. But I think it's inelegant because <em>anyone who references my NuGet package</em> from one of the traditional platforms like .NET45 will get those additional NuGet references. They don't even need them.

<img id="needless references" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/12/06/UWP/1803.needless-references.png" alt="" width="364" height="401" border="0" />
<em>NuGet algorithm</em> . The way I solved this problem was through use of <em>nuspec dependency groups</em>. The .nuspec &lt;dependency&gt; section can have either a flat list of dependencies (as above) or a list of groups of dependencies (as at the start of this section), each one tagged with a "targetFramework".

In the case where the .nuspec &lt;dependency&gt; section has a list of groups, then it picks a single best-match group for the current project. It does this using exactly the same algorithm as it used to pick a single best-match <em>lib\subdirectory </em>for the current project.

If you consult the Master Table, and work it through with the NuGet algorithm for picking best match, then here's how my selection of dependency groups will be used by different project types:
<table class="MsoTable15Grid1LightAccent5" style="border: currentColor; border-collapse: collapse;" border="1" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td style="width: 188.75pt; border: solid #B4C6E7 1.0pt; border-bottom: solid #8EAADB 1.5pt; padding: 0in 5.4pt 0in 5.4pt;" valign="top" width="378">
<p style="margin-bottom: .0001pt; line-height: normal;"><strong>Dependency group targetFramework</strong></p>
</td>
<td style="width: 278.75pt; border-top: solid #B4C6E7 1.0pt; border-left: none; border-bottom: solid #8EAADB 1.5pt; border-right: solid #B4C6E7 1.0pt; padding: 0in 5.4pt 0in 5.4pt;" valign="top" width="558">
<p style="margin-bottom: .0001pt; line-height: normal;"><strong>Used by these project types</strong></p>
</td>
</tr>
<tr>
<td style="width: 188.75pt; border: solid #B4C6E7 1.0pt; border-top: none; padding: 0in 5.4pt 0in &lt;/p&gt;&lt;p&gt;5.4pt;" valign="top" width="378">
<p style="margin-bottom: .0001pt; line-height: normal;">net</p>
</td>
<td style="width: 278.75pt; border-top: none; border-left: none; border-bottom: solid #B4C6E7 &lt;/p&gt;&lt;p&gt;1.0pt; border-right: solid #B4C6E7 1.0pt; padding: 0in 5.4pt 0in 5.4pt;" valign="top" width="558">
<p style="margin-bottom: .0001pt; line-height: normal;">net45, net451, net452, net46</p>
</td>
</tr>
<tr>
<td style="width: 188.75pt; border: solid #B4C6E7 1.0pt; border-top: none; padding: 0in 5.4pt 0in &lt;/p&gt;&lt;p&gt;5.4pt;" valign="top" width="378">
<p style="margin-bottom: .0001pt; line-height: normal;">win</p>
</td>
<td style="width: 278.75pt; border-top: none; border-left: none; border-bottom: solid #B4C6E7 &lt;/p&gt;&lt;p&gt;1.0pt; border-right: solid #B4C6E7 1.0pt; padding: 0in 5.4pt 0in 5.4pt;" valign="top" width="558">
<p style="margin-bottom: .0001pt; line-height: normal;">win8, win81,</p>
</td>
</tr>
<tr>
<td style="width: 188.75pt; border: solid #B4C6E7 1.0pt; border-top: none; padding: 0in 5.4pt 0in &lt;/p&gt;&lt;p&gt;5.4pt;" valign="top" width="378">
<p style="margin-bottom: .0001pt; line-height: normal;">wp</p>
</td>
<td style="width: 278.75pt; border-top: none; border-left: none; border-bottom: solid #B4C6E7 &lt;/p&gt;&lt;p&gt;1.0pt; border-right: solid #B4C6E7 1.0pt; padding: 0in 5.4pt 0in 5.4pt;" valign="top" width="558">
<p style="margin-bottom: .0001pt; line-height: normal;">wp8, wp81</p>
</td>
</tr>
<tr>
<td style="width: 188.75pt; border: solid #B4C6E7 1.0pt; border-top: none; padding: 0in 5.4pt 0in &lt;/p&gt;&lt;p&gt;5.4pt;" valign="top" width="378">
<p style="margin-bottom: .0001pt; line-height: normal;">wpa</p>
</td>
<td style="width: 278.75pt; border-top: none; border-left: none; border-bottom: solid #B4C6E7 &lt;/p&gt;&lt;p&gt;1.0pt; border-right: solid #B4C6E7 1.0pt; padding: 0in 5.4pt 0in 5.4pt;" valign="top" width="558">
<p style="margin-bottom: .0001pt; line-height: normal;">wpa81</p>
</td>
</tr>
<tr>
<td style="width: 188.75pt; border: solid #B4C6E7 1.0pt; border-top: none; padding: 0in 5.4pt 0in &lt;/p&gt;&lt;p&gt;5.4pt;" valign="top" width="378">
<p style="margin-bottom: .0001pt; line-height: normal;">MonoAndroid
MonoTouch
Xamarin.iOS</p>
</td>
<td style="width: 278.75pt; border-top: none; border-left: none; border-bottom: solid #B4C6E7 &lt;/p&gt;&lt;p&gt;1.0pt; border-right: solid #B4C6E7 1.0pt; padding: 0in 5.4pt 0in 5.4pt;" valign="top" width="558">
<p style="margin-bottom: .0001pt; line-height: normal;">MonoAndroid10</p>
<p style="margin-bottom: .0001pt; line-height: normal;">MonoTouch10
Xamarin.iOS10</p>
</td>
</tr>
<tr>
<td style="width: 188.75pt; border: solid #B4C6E7 1.0pt; border-top: none; padding: 0in 5.4pt 0in &lt;/p&gt;&lt;p&gt;5.4pt;" valign="top" width="378">
<p style="margin-bottom: .0001pt; line-height: normal;">uap</p>
</td>
<td style="width: 278.75pt; border-top: none; border-left: none; border-bottom: solid #B4C6E7 &lt;/p&gt;&lt;p&gt;1.0pt; border-right: solid #B4C6E7 1.0pt; padding: 0in 5.4pt 0in 5.4pt;" valign="top" width="558">
<p style="margin-bottom: .0001pt; line-height: normal;">uap10.0</p>
</td>
</tr>
<tr>
<td style="width: 188.75pt; border: solid #B4C6E7 1.0pt; border-top: none; padding: 0in 5.4pt 0in &lt;/p&gt;&lt;p&gt;5.4pt;" valign="top" width="378">
<p style="margin-bottom: .0001pt; line-height: normal;">dotnet</p>
</td>
<td style="width: 278.75pt; border-top: none; border-left: none; border-bottom: solid #B4C6E7 &lt;/p&gt;&lt;p&gt;1.0pt; border-right: solid #B4C6E7 1.0pt; padding: 0in 5.4pt 0in 5.4pt;" valign="top" width="558">
<p style="margin-bottom: .0001pt; line-height: normal;">dnxcore, modern PCLs</p>
</td>
</tr>
<tr>
<td style="width: 188.75pt; border: solid #B4C6E7 1.0pt; border-top: none; padding: 0in 5.4pt 0in &lt;/p&gt;&lt;p&gt;5.4pt;" valign="top" width="378">
<p style="margin-bottom: .0001pt; line-height: normal;">portable-net45+win8+wpa81+wp8</p>
</td>
<td style="width: 278.75pt; border-top: none; border-left: none; border-bottom: solid #B4C6E7 &lt;/p&gt;&lt;p&gt;1.0pt; border-right: solid #B4C6E7 1.0pt; padding: 0in 5.4pt 0in 5.4pt;" valign="top" width="558">
<p style="margin-bottom: .0001pt; line-height: normal;">traditional PCLs</p>
</td>
</tr>
</tbody>
</table>
&nbsp;

<em>Rationale</em> . For the modern project types with a red border around them (uap10 and dnxcore50), plus for any conjectured future project types (likely based on dotnet and deploying the framework app-locally), then I need to spell out all of the dependencies including the framework ones:
<ul>
	<li><strong>[Full dependencies] </strong> Newtonsoft.Json, System.Runtime, System.Resources.ResourceManager, System.Collections, System.Linq</li>
</ul>
But for all other project types, I can safely assume that the framework dependencies are already satisfied by the platform/OS, so all I want to do is spell out the extra ones:
<ul>
	<li><strong>[Brief dependencies]</strong> Newtonsoft.Json</li>
	<li>(Pedantically, you were supposed to add &lt;frameworkAssembly&gt; directives to your .nuspec just in case the user had manually deleted important framework references from their References node. But no one ever used these directives correctly, and it wasn't worth doing.)</li>
</ul>
The only way I could figure out how to do this, going by the Master Table and the NuGet best-match algorithm, was to spell out every single traditional dependency group and also spell out uap10.0 explicitly. In a nutshell, the reason it ends up like this is (1) I need to specify full dependencies for dotnet; (2) dotnet matches every traditional platform, but the traditional platforms should only have brief dependencies, so each one must be explicitly exempted; (3) uap10.0 the traditional "win" platform, but needs full dependencies, so it has to be exempted once again.

(If anyone can see an easier way to achieve this, please let me know!)
<strong>The lazy approach</strong>

The work to craft a proper .nuspec &lt;dependencies&gt; section is a bit awkward. I want to explicitly rule out some tempting "lazy" alternatives, because they don't give a good experience for the consumer of your NuGet package…
<ol>
	<li><em>I might omit the &lt;dependencies&gt; section entirely.</em> But then if my NuGet package is referenced by a project which doesn't also reference Newtonsoft.Json, then it will fail at runtime with a DllLoadException.</li>
	<li><em>I might merely put into &lt;dependencies&gt; the items in my library project's packages.config, </em> in this case Newtonsoft.Json. This will run fine on all traditional platforms. It will likely run fine on uap10.0 unless the app author has gone out of their way to delete the default NuGet references, or unless Microsoft in future decides to trim down the set of default NuGet references for a faster leaner system. It will likely fail on dnxcore50, since those projects have just a tiny set of default NuGet references. It will likely fail on future platforms, since they're most likely to follow the lead of dnxcore50.</li>
	<li><em> I might merely put into the &lt;dependencies&gt; those items in my library project's packages.config, plus the single catch-all "Microsoft.NETCore" </em> . The Microsoft.NETCore package represents all of the default NuGet references. This approach will run fine on uap10. It will run fine on dnxcore50 and on future platforms, but it will bloat them due to including "the whole world and the kitchen sink" while they aim to be lean. It will work on traditional platforms, but will look really terrible since 100+ NuGet references will be added to them.</li>
	<li><em>I might abandon the complicated "dependency groups", and merely use a flat list of dependencies</em> . As discussed above, this will work on all platforms. On traditional platforms, however, it adds superfluous NuGet references to traditional platforms -- in this case just 4 superfluous references plus their transitive dependencies, but in more realistic libraries it might add 50 or more.</li>
</ol>
<h1>Step 4: produce the .nupkg file as part of your build</h1>
It's best to make the .nupkg be automatically generated as part of my PCL project's build. This section shows how.

First, from my PCL project, I add a NuGet reference to the "NuGet.CommandLine" package.

Second, I unload my project, edit the .vbproj/.csproj, and add these lines near the end:

<span style="font-size: 9.0pt; font-family: Consolas; color: blue; background: white;"> &lt;</span><span style="font-size: 9.0pt; font-family: Consolas; color: #a31515; background: white;">Target</span><span style="font-size: 9.0pt; font-family: Consolas; color: blue; background: white;"> </span><span style="font-size: 9.0pt; font-family: Consolas; color: red; background: white;">Name</span><span style="font-size: 9.0pt; font-family: Consolas; color: blue; background: white;">=</span><span style="font-size: 9.0pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.0pt; font-family: Consolas; color: blue; background: white;">AfterBuild</span><span style="font-size: 9.0pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.0pt; font-family: Consolas; color: blue; background: white;">&gt;</span>
<span style="font-size: 9.0pt; font-family: Consolas; color: blue; background: white;"> &lt;</span><span style="font-size: 9.0pt; font-family: Consolas; color: #a31515; background: white;">Copy</span><span style="font-size: 9.0pt; font-family: Consolas; color: blue; background: white;"> </span><span style="font-size: 9.0pt; font-&lt;/p&gt;&lt;p&gt;family: Consolas; color: red; background: white;">SkipUnchangedFiles</span><span style="font-size: 9.0pt; font-family: Consolas; color: blue; background: white;">=</span><span style="font-size: 9.0pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.0pt; font-family: Consolas; color: blue; background: white;">true</span><span style="font-size: 9.0pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.0pt; font-family: Consolas; color: blue; background: white;">
</span><span style="font-size: 9.0pt; font-family: Consolas; color: red; background: white;">SourceFiles</span><span style="font-size: 9.0pt; font-family: Consolas; color: blue; background: white;">=</span><span style="font-size: 9.0pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.0pt; font-family: Consolas; color: blue; background: white;">bin\$(Configuration)\ClassLibrary1.dll</span><span style="font-size: 9.0pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.0pt; font-family: Consolas; color: blue; background: white;">
</span><span style="font-size: 9.0pt; font-family: Consolas; color: red; background: white;">DestinationFiles</span><span style="font-size: 9.0pt; font-family: Consolas; color: blue; background: white;">=</span><span style="font-size: 9.0pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.0pt; font-family: Consolas; color: blue; background: white;">bin\$(Configuration)\nupkg\lib\dotnet \ClassLibrary1.dll</span><span style="font-size: 9.0pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.0pt; font-family: Consolas; color: blue; background: white;"> /&gt;</span>
<span style="font-size: 9.0pt; font-family: Consolas; color: blue; background: white;"> &lt;</span><span style="font-size: 9.0pt; font-family: Consolas; color: #a31515; background: white;">Copy</span><span style="font-size: 9.0pt; font-family: Consolas; color: blue; background: white;"> </span><span style="font-size: 9.0pt; font-&lt;/p&gt;&lt;p&gt;family: Consolas; color: red; background: white;">SkipUnchangedFiles</span><span style="font-size: 9.0pt; font-family: Consolas; color: blue; background: white;">=</span><span style="font-size: 9.0pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.0pt; font-family: Consolas; color: blue; background: white;">true</span><span style="font-size: 9.0pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.0pt; font-family: Consolas; color: blue; background: white;">
</span><span style="font-size: 9.0pt; font-family: Consolas; color: red; background: white;">SourceFiles</span><span style="font-size: 9.0pt; font-family: Consolas; color: blue; background: white;">=</span><span style="font-size: 9.0pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.0pt; font-family: Consolas; color: blue; background: white;">bin\$(Configuration)\ClassLibrary1.xml</span><span style="font-size: 9.0pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.0pt; font-family: Consolas; color: blue; background: white;">
</span><span style="font-size: 9.0pt; font-family: Consolas; color: red; background: white;">DestinationFiles</span><span style="font-size: 9.0pt; font-family: Consolas; color: blue; background: white;">=</span><span style="font-size: 9.0pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.0pt; font-family: Consolas; color: blue; background: white;">bin\$(Configuration)\nupkg\lib\dotnet \ClassLibrary1.xml</span><span style="font-size: 9.0pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.0pt; font-family: Consolas; color: blue; background: white;"> /&gt;</span>
<span style="font-size: 9.0pt; font-family: Consolas; color: blue; background: white;"> &lt;</span><span style="font-size: 9.0pt; font-family: Consolas; color: #a31515; background: white;">Copy</span><span style="font-size: 9.0pt; font-family: Consolas; color: blue; background: white;"> </span><span style="font-size: 9.0pt; font-&lt;/p&gt;&lt;p&gt;family: Consolas; color: red; background: white;">SkipUnchangedFiles</span><span style="font-size: 9.0pt; font-family: Consolas; color: blue; background: white;">=</span><span style="font-size: 9.0pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.0pt; font-family: Consolas; color: blue; background: white;">true</span><span style="font-size: 9.0pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.0pt; font-family: Consolas; color: blue; background: white;">
</span><span style="font-size: 9.0pt; font-family: Consolas; color: red; background: white;">SourceFiles</span><span style="font-size: 9.0pt; font-family: Consolas; color: blue; background: white;">=</span><span style="font-size: 9.0pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.0pt; font-family: Consolas; color: blue; background: white;">bin\$(Configuration)\ClassLibrary1.pdb</span><span style="font-size: 9.0pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.0pt; font-family: Consolas; color: blue; background: white;">
</span><span style="font-size: 9.0pt; font-family: Consolas; color: red; background: white;">DestinationFiles</span><span style="font-size: 9.0pt; font-family: Consolas; color: blue; background: white;">=</span><span style="font-size: 9.0pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.0pt; font-family: Consolas; color: blue; background: white;">bin\$(Configuration)\nupkg\lib\dotnet \ClassLibrary1.pdb</span><span style="font-size: 9.0pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.0pt; font-family: Consolas; color: blue; background: white;"> /&gt;</span>
<span style="font-size: 9.0pt; font-family: Consolas; color: blue; background: white;"> &lt;</span><span style="font-size: 9.0pt; font-family: Consolas; color: #a31515; background: white;">Copy</span><span style="font-size: 9.0pt; font-family: Consolas; color: blue; background: white;"> </span><span style="font-size: 9.0pt; font-&lt;/p&gt;&lt;p&gt;family: Consolas; color: red; background: white;">SkipUnchangedFiles</span><span style="font-size: 9.0pt; font-family: Consolas; color: blue; background: white;">=</span><span style="font-size: 9.0pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.0pt; font-family: Consolas; color: blue; background: white;">true</span><span style="font-size: 9.0pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.0pt; font-family: Consolas; color: blue; background: white;">
</span><span style="font-size: 9.0pt; font-family: Consolas; color: red; background: white;">SourceFiles</span><span style="font-size: 9.0pt; font-family: Consolas; color: blue; background: white;">=</span><span style="font-size: 9.0pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.0pt; font-family: Consolas; color: blue; background: white;">bin\$(Configuration)\ClassLibrary1.dll</span><span style="font-size: 9.0pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.0pt; font-family: Consolas; color: blue; background: white;">
</span><span style="font-size: 9.0pt; font-family: Consolas; color: red; background: white;">DestinationFiles</span><span style="font-size: 9.0pt; font-family: Consolas; color: blue; background: white;">=</span><span style="font-size: 9.0pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.0pt; font-family: Consolas; color: blue; background: white;">bin\$(Configuration)\nupkg\lib\portable- net45+win8+wpa81+wp8\ClassLibrary1.dll</span><span style="font-size: 9.0pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.0pt; font-family: Consolas; color: blue; background: white;"> /&gt;</span>
<span style="font-size: 9.0pt; font-family: Consolas; color: blue; background: white;"> &lt;</span><span style="font-size: 9.0pt; font-family: Consolas; color: #a31515; background: white;">Copy</span><span style="font-size: 9.0pt; font-&lt;/p&gt;&lt;p&gt;family: Consolas; color: blue; background: white;"> </span><span style="font-size: 9.0pt; font-family: Consolas; color: red; background: white;">SkipUnchangedFiles</span><span style="font-size: 9.0pt; font-family: Consolas; color: blue; background: white;">=</span><span style="font-size: 9.0pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.0pt; font-family: Consolas; color: blue; background: white;">true</span><span style="font-size: 9.0pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.0pt; font-family: Consolas; color: blue; background: white;">
</span><span style="font-size: 9.0pt; font-family: Consolas; color: red; background: white;">SourceFiles</span><span style="font-size: 9.0pt; font-family: Consolas; color: blue; background: white;">=</span><span style="font-size: 9.0pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.0pt; font-family: Consolas; color: blue; background: white;">bin\$(Configuration)\ClassLibrary1.xml</span><span style="font-size: 9.0pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.0pt; font-family: Consolas; color: blue; background: white;">
</span><span style="font-size: 9.0pt; font-family: Consolas; color: red; background: white;">DestinationFiles</span><span style="font-size: 9.0pt; font-family: Consolas; color: blue; background: white;">=</span><span style="font-size: 9.0pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.0pt; font-family: Consolas; color: blue; background: white;">bin\$(Configuration)\nupkg\lib\portable- net45+win8+wpa81+wp8\ClassLibrary1.xml</span><span style="font-size: 9.0pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.0pt; font-family: Consolas; color: blue; background: white;"> /&gt;</span>
<span style="font-size: 9.0pt; font-family: Consolas; color: blue; background: white;"> &lt;</span><span style="font-size: 9.0pt; font-family: Consolas; color: #a31515; background: white;">Copy</span><span style="font-size: 9.0pt; font-&lt;/p&gt;&lt;p&gt;family: Consolas; color: blue; background: white;"> </span><span style="font-size: 9.0pt; font-family: Consolas; color: red; background: white;">SkipUnchangedFiles</span><span style="font-size: 9.0pt; font-family: Consolas; color: blue; background: white;">=</span><span style="font-size: 9.0pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.0pt; font-family: Consolas; color: blue; background: white;">true</span><span style="font-size: 9.0pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.0pt; font-family: Consolas; color: blue; background: white;">
</span><span style="font-size: 9.0pt; font-family: Consolas; color: red; background: white;">SourceFiles</span><span style="font-size: 9.0pt; font-family: Consolas; color: blue; background: white;">=</span><span style="font-size: 9.0pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.0pt; font-family: Consolas; color: blue; background: white;">bin\$(Configuration)\ClassLibrary1.pdb</span><span style="font-size: 9.0pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.0pt; font-family: Consolas; color: blue; background: white;">
</span><span style="font-size: 9.0pt; font-family: Consolas; color: red; background: white;">DestinationFiles</span><span style="font-size: 9.0pt; font-family: Consolas; color: blue; background: white;">=</span><span style="font-size: 9.0pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.0pt; font-family: Consolas; color: blue; background: white;">bin\$(Configuration)\nupkg\lib\portable- net45+win8+wpa81+wp8\ClassLibrary1.pdb</span><span style="font-size: 9.0pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.0pt; font-family: Consolas; color: blue; background: white;"> /&gt;</span>
<span style="font-size: 9.0pt; font-family: Consolas; color: blue; background: white;"> &lt;</span><span style="font-size: 9.0pt; font-family: Consolas; color: #a31515; background: white;">Copy</span><span style="font-size: 9.0pt; font-&lt;/p&gt;&lt;p&gt;family: Consolas; color: blue; background: white;"> </span><span style="font-size: 9.0pt; font-family: Consolas; color: red; background: white;">SkipUnchangedFiles</span><span style="font-size: 9.0pt; font-family: Consolas; color: blue; background: white;">=</span><span style="font-size: 9.0pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.0pt; font-family: Consolas; color: blue; background: white;">true</span><span style="font-size: 9.0pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.0pt; font-family: Consolas; color: blue; background: white;">
</span><span style="font-size: 9.0pt; font-family: Consolas; color: red; background: white;">SourceFiles</span><span style="font-size: 9.0pt; font-family: Consolas; color: blue; background: white;">=</span><span style="font-size: 9.0pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.0pt; font-family: Consolas; color: blue; background: white;">SampleNugetPackage.nuspec</span><span style="font-size: 9.0pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.0pt; font-family: Consolas; color: blue; background: white;">
</span><span style="font-size: 9.0pt; font-family: Consolas; color: red; background: white;">DestinationFiles</span><span style="font-size: 9.0pt; font-family: Consolas; color: blue; background: white;">=</span><span style="font-size: 9.0pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.0pt; font-family: Consolas; color: blue; background: white;">bin\$(Configuration)\nupkg \SampleNugetPackage.nuspec</span><span style="font-size: 9.0pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.0pt; font-family: Consolas; color: blue; background: white;"> /&gt;</span>
<span style="font-size: 9.0pt; font-family: Consolas; color: blue; background: white;"> &lt;</span><span style="font-size: 9.0pt; font-family: Consolas; color: #a31515; background: white;">Exec</span><span style="font-size: 9.0pt; font-&lt;/p&gt;&lt;p&gt;family: Consolas; color: blue; background: white;"> </span><span style="font-size: 9.0pt; font-family: Consolas; color: red; background: white;">Command</span><span style="font-size: 9.0pt; font-family: Consolas; color: blue; background: white;">=</span><span style="font-size: 9.0pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.0pt; font-family: Consolas; color: blue; background: white;">..\..\..\..\packages \NuGet.CommandLine.2.8.6\tools\NuGet.exe pack SampleNugetPackage.nuspec -OutputDirectory ..</span><span style="font-size: 9.0pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.0pt; font-family: Consolas; color: blue; background: white;">
</span><span style="font-size: 9.0pt; font-&lt;/p&gt;&lt;p&gt;family: Consolas; color: red; background: white;">WorkingDirectory</span><span style="font-size: 9.0pt; font-family: Consolas; color: blue; background: white;">=</span><span style="font-size: 9.0pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.0pt; font-family: Consolas; color: blue; background: white;">bin\ $(Configuration)\nupkg</span><span style="font-size: 9.0pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.0pt; font-family: Consolas; color: blue; background: white;">
</span><span style="font-size: 9.0pt; font-family: Consolas; color: red; background: white;">Outputs</span><span style="font-&lt;/p&gt;&lt;p&gt;size: 9.0pt; font-family: Consolas; color: blue; background: white;">=</span><span style="font-&lt;/p&gt;&lt;p&gt;size: 9.0pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-&lt;/p&gt;&lt;p&gt;size: 9.0pt; font-family: Consolas; color: blue; background: white;">bin\ $(Configuration)\*.nupkg</span><span style="font-size: 9.0pt; font-family: Consolas; color: black; background: white;">"</span><span style="font-size: 9.0pt; font-family: Consolas; color: blue; background: white;"> /&gt;</span>
<span style="font-size: 9.0pt; font-family: Consolas; color: blue; background: white;"> &lt;/</span><span style="font-size: 9.0pt; font-family: Consolas; color: #a31515; background: white;">Target</span><span style="font-size: 9.0pt; font-&lt;/p&gt;&lt;p&gt;family: Consolas; color: blue; background: white;">&gt;</span>

<em>Rationale</em> . After the project has been built, these msbuild steps create a "bin\Debug\nupkg" directory which contains the .nuspec and contains the "lib\" directory structure we discussed earlier. Then it runs the "nuget.exe" command-line tool to turn it into a .nupkg and sticks it into your bin\Debug directory. Or Release directory, if you're building in Release mode.

I'm not a great expert on msbuild. These msbuild steps have a few shortcomings, which I'm sure an msbuild expert can point out J But they're the best I've got.

The easiest way to test your .nupkg is Tools &gt; Options &gt; NuGet &gt; PackageSources, and add a new source which points straight to your project's bin\debug directory. Then you can easily add a NuGet reference to it from any other app.
<h1>Special Circumstances</h1>
There are a number of advanced NuGet features. Some of them no longer work with project.json. I've colored these back-compat breaks in red. Some of them are also discussion on the <a href="http://blog.nuget.org/20150729/Introducing-nuget-uwp.html">NuGet team blog</a>.

<span style="color: #ff0000;"><strong>"Content" no longer supported by project.json. </strong></span> A few NuGet packages use "content". These are files such as .cs or .png which, in traditional packages.config, got added as source files to your project when you install a NuGet package. You were even able to modify these files once they've been added. (Content files are no longer supported by project.json and are simply ignored. You must either rewrite your package to avoid it, or <a href="https://github.com/NuGet/Home/issues/627">join in the discussion</a> with the NuGet team about how content should work.

<span style="color: #ff0000;"><strong>"Lib\files" no longer supported by project.json. </strong></span> It used to be you could include files directly in the root of the lib\ directory, and if no appropriate lib\subdirectory was found, then NuGet would pick files straight from the root. This is no longer supported by project.json and such files are simply ignored. You should consult the Master Table to figure out which lib\subdirectory (or subdirectories) are more appropriate now.

<span style="color: #ff0000;"><strong>"Build\files" no longer supported by project.json. </strong></span> Likewise it used to be you could include files directly in the root of the build\ directory. This is not currently supported by project.json. You must either rewrite your package to avoid it, again by consulting the Master Table, or follow the NuGet team's progress on fixing <a href="https://github.com/NuGet/Home/issues/965">this bug</a>.

<span style="color: #ff0000;"><strong>"install.ps1" no longer supported by project.json. </strong></span> It used to be you could have an arbitrary powershell script be invoked when the package is added or removed. This no longer makes sense in the world where NuGet packages are resolved by msbuild, and so install.ps1 and uninstall.ps1 are now simply ignored. You must figure out alternatives. A really powerful alternative is .targets files in a build\subdirectory.

<span style="color: #ff0000;"><strong>Analyzers have changed since VS2015 RC</strong>.</span> An "Analyzer" is a mechanism by which a NuGet package can provide additional warning messages, error messages and quick-fixes inside the VS2015 code editor for VB/C#. You get started with an analyzer by installing the <a href="https://visualstudiogallery.msdn.microsoft.com/2ddb7240-5249-4c8c-969e-5d05823bcb89?SRC=VSIDE">.NET Compiler Platform SDK</a> and doing File&gt;New&gt;Extensibility&gt;Analyzer. How do Analyzer NuGet packages install? In packages.config projects, they install via "install1.ps". In project.json projects, they install by convention that they're inside an "analyzers\dotnet" directory (or "analyzers\dotnet\vb" or "analyzers\dotnet\cs" if the analyzer is VB or C# specific). Note that "analyzers\dotnet" here doesn't follow the same rules as "lib\<em>subdirectory</em>"... it should be "dotnet" exactly. (This rule isn't currently enforced, but it might be in future). If you created an analyzer prior to VS2015 RTM (release date July 29th 2015) then I suspect your analyzer NuGet package is out of date. You should do File&gt;New&gt;Extensibility&gt;Analyzer once again and copy+paste your old code.

<strong>mscorlib-based projects. </strong> If you want to write a NuGet package which is very portable, including to .NET4-era targets, things get more complicated. (1) When you try to write such a PCL, it is "mscorlib"-based. That means the DLL contains an assembly reference to "mscorlib". I don't know how to figure out which NuGet packages this corresponds to. (2) Such an mscorlib-based PCL cannot be referenced by a dnxcore50 project. Therefore, at the bare minimum, you must build two separate DLLs, one for older project types and one for newer ones. (3) You'll typically want to include references to packages like Microsoft.Bcl and Microsoft.Bcl.Async and Microsoft.Net.Http. I don't know which of these packages should also be depended upon by modern <a>targets</a>.]]></content:encoded>
    </item>
  </channel>
</rss>