Quantcast
Channel: Category Name
Viewing all 10804 articles
Browse latest View live

The week in .NET: .NET Core 1.0.1 – On .NET with Peachpie – Avalonia – Folk Tale

$
0
0

To read last week’s post, see The week in .NET – 9/7/2016.

.NET Core 1.0.1 shipped!

We shipped .NET Core 1.0.1 yesterday. Check out the announcement!

On .NET

Last week, we spoke with Benjamin Fistein and Jakub Míšek about Peachpie, a PHP compiler for .NET. We’ve had Ben and Jakub on the show before, and they came back to show us some of the new features they’ve built: .NET Core compatibility, debugging in VS Code, Docker deployment, and NuGet package building and consumption.

This week, we’ll speak about Steeltoe, a .NET toolkit for common microservice patterns. The show begins at 10AM Pacific Time on Channel 9. We’ll take questions on Gitter, on the dotnet/home channel. Please use the #onnet tag. It’s OK to start sending us questions in advance if you can’t do it live during the show.

Project of the week: Avalonia

Avalonia is a multi-platform UI toolkit, somewhat like WPF. It supports XAML and a flexible styling system, and runs on Windows, Linux, macOS, iOS, and Android.

Game of the Week: Folk Tale

Folk Tale blends the mechanics of a real-time strategy with role playing elements. Players balance building a thriving village from nothing whilst exploring the vast world, making new relationships and discovering new loot. Folk Tale features random events and a dynamic story, letting you run your village the way you want while never knowing exactly how the story will unfold. Both campaign and sandbox modes can be enjoyed in addition to an in-game editor which the community can use to make their own worlds.

game

Folk Tale was created by Games Foundry using Unity and C#. It is currently in early access on Steam and is available for Windows and Mac OS X.

User group meeting of the week: ASP.NET Core – What you need to know to be productive on day 1, in Durham, NC

TRINUG hold a user group meeting on Wednesday, September 14 at 5:30PM about ASP.NET Core and what you need to know to be productive on day 1. Steve Michelotti will be the speaker.

.NET

ASP.NET

F#

Check out F# Weekly for more great content from the F# community.

Azure

Xamarin

Games

And this is it for this week!

Contribute to the week in .NET

As always, this weekly post couldn’t exist without community contributions, and I’d like to thank all those who sent links and tips. The F# section is provided by Phillip Carter, the gaming section by Stacey Haffner, and the Xamarin section by Dan Rigby.

You can participate too. Did you write a great blog post, or just read one? Do you want everyone to know about an amazing new contribution or a useful library? Did you make or play a great game built on .NET?
We’d love to hear from you, and feature your contributions on future posts:

This week’s post (and future posts) also contains news I first read on The ASP.NET Community Standup, on Weekly Xamarin, on F# weekly, on ASP.NET Weekly, and on Chris Alcock’s The Morning Brew.


Apps built using the Desktop Bridge now available in the Windows Store!

$
0
0

A few months ago, during Build 2016, we announced the Desktop Bridge, enabling developers to bring their existing desktop apps and games over to the Universal Windows Platform (UWP) by converting their app or game with the Desktop App Converter and then enhancing and extending it with UWP functionality. This then enables the path to gradually migrate the app or game to reach all Windows 10 devices over time, including phones, Xbox One and HoloLens.

Last month, along with the Windows 10 Anniversary Update SDK, we announced a process for you to start bringing these converted apps and games to the Windows Store for easier and safer distribution to customers.

First apps available in the Windows Store

Today we’re pleased to announce that new apps including Evernote, Arduino IDE, Double Twist, PhotoScape, MAGIX Movie Edit Pro, Virtual Robotics Kit, Relab, SQL Pro, Voya Media, Predicted Desire and korAccount will become available in the Windows Store within the next few days for Windows 10 customers running the Anniversary Update (if you haven’t updated yet here’s how you can). As the apps become available in the Store, you will be able to find them in a full collection of apps built using the Desktop Bridge in the Windows Store.

These are the same apps that customers know and love, but are now available for download in the trusted Windows Store. For your customers, the Windows Store is the safest and most secure place for them to find and manage content across a range of Windows devices, including PCs, phones, Xbox One and HoloLens. For developers, the Desktop Bridge enables you to make use of the new functionality available to UWP apps right out of the gate, including access to a host of new APIs like Live Tiles, Cortana and Action Center that provide best-in-class support for thousands of scenarios across all of Windows. Evernote is already taking advantage of the new APIs to bring innovation to customers.

“We’re excited to bring our full-featured Evernote app to the Windows Store. The Desktop Bridge vastly simplifies our installer and uninstaller. It also opens up UWP APIs that we’ve taken advantage of, including the live tiles and notifications. And having the full-featured Evernote app in the Windows Store means future improvements will reach users faster.”—Seth Hitchings, VP Engineering, Evernote

Tooling updates for the Desktop Bridge

In addition, we’re happy to announce that today we have made the Desktop App Converter available for download directly from the Windows Store. This will enable updates of the Desktop App Converter with the latest features and bug-fixes to automatically be available to you as soon as we release them.

Finally, we are expanding the ways in which developers can create apps using the Desktop Bridge. Our partners, Flexera Software with InstallShield, FireGiant with WiX and Caphyon with Advanced Installer – three of the most popular Windows installer technologies  have included support for the Desktop Bridge, enabling developers to directly build an app package with their existing desktop app using the bridge as part of their existing developer workflow.

“Working in parallel with Microsoft, we are making it easy for our customers to transition their existing InstallShield MSI projects to build Universal Windows Platform and Windows Server App packages.  InstallShield is the only product that enables developers to test their apps for compatibility with the Desktop Bridge and WSAs – saving countless hours of time, effort and investigative work.”–  Maureen Polte, Vice President of Product Management at Flexera Software

“AppX packages and the Universal Windows Platform are the future of application deployment and development. It is our team’s core belief to support and educate our users, but also to provide them with the best packaging tool and services. We provide developers with the option to easily build a UWP app package for existing desktop applications from their existing MSI projects.”– Bogdan Mitrache, Advanced Installer

“The FireGiant AppX Extension works from your current WiX source code and integrates seamlessly into your WiX build process. There is no conversion process or managing of separate projects. Developers use the code they already have and the tools they’ve already learned to create both MSI and AppX packages.”– Rob Mensching, FireGiant CEO

We are thrilled with the community’s response to the Desktop Bridge, but there is always more to learn.

Other resources include:

 

Changes to Visual Studio “15” Setup

$
0
0

We’ve listened to feedback over the years, and while each new release brought changes to the setup experience of Visual Studio and related products, none have been more significant than what we’re doing for Visual Studio “15”.

New setup engine

With Visual Studio supporting so many platforms and toolkits, one of the goals for Visual Studio “15” is to provide choice and install just what you need. To make it easier for our partners to author component packages for Visual Studio while making sure you get all the required components, an underlying engine needs to provide granularity and cohesion with dependencies. Existing package managers like NuGet and NPM provided much of the inspiration, and we bolstered dependency resolution with additional flexibility. This means that whatever workloads and components you select, and whatever product languages you choose to install, you should get everything you need and only what you need.

Another goal is to install faster. Along with a ground-up rewrite of the setup engine, we also extended VSIX packages to install the core product and many of its components while still supporting platform-specific functionality we had with Windows Installer packages like creating file associations, shortcuts, and NGEN’ing assemblies. Now we can install Visual Studio “15” faster and with better isolation. Many legacy and some updated components continue to ship Windows Installer packages or black box executables, but this work in progress has already seen a lot of migration to the new format and more will follow. These mostly-extracted installations are isolated and can be updated with less interaction with other products or editions.

Product instances

To support a model with lightweight and isolated installations that do not interfere with other products and editions, we needed a way for all partners to query for products that match some set of requirements, like finding the latest Visual Studio “15” that have C++ compilers installed. Registry queries wouldn’t provide the flexibility required in many scenarios we discussed with partners. So we created the concept of “instances” – basically the root folder of an installation and other information about what was installed in that folder (and outside that folder, for legacy packages). Each instance also has its own private registry so they can be configured independently.

The COM server DLLs that implement this functionality will be installed by the setup engine and available on any systems with at least one instance of a product installed. If CoCreateInstance returns REGDB_E_CLASSNOTREG (0x80040154) or a COMException is thrown in managed code with the same HRESULT, it’s a good bet no instances are installed.

While we are exploring other ways to provide discovery, we recently published a set of NuGet packages for native and managed code for VS15:

I have posted a simple sample in the gallery for C#, C++, and Visual Basic.

You can query all instances installed by the new setup engine, or get an instance for a specified path or the current process path. Using the information provided (and we will be exposing more as we collect feedback), you can determine what workloads and components are installed, and resolve paths to compilers and other tools.

If, for example, you wanted to check if some component package was installed before attempting to light up a dependent feature in the current instance, you could do something like the following:

bool IsInstalled(string component)
{
    if (component == null)
    {
        throw new ArgumentNullException(nameof(component));
    }

    var instance = (ISetupInstance2)new SetupConfiguration().GetInstanceForCurrentPath();
    return instance?.Packages?.Any(package => string.Equals(package.Id, component, StringComparison.OrdinalIgnoreCase));
}

We will be publishing more about the updated VSIX extension format, how it supports prior releases, and how to depend on workloads and components for VS15 in future posts. For updated samples, please see https://github.com/microsoft/vs-setup-samples.

Putting (my VB6) Windows Apps in the Windows 10 Store - Project Centennial

$
0
0

Evernote in the Windows 10 Store with Project CentennialI noticed today that Evernote was in the Windows Store. I went to the store, installed Evernote, and it ran. No nextnextnextfinish-style install, it just worked and it worked nicely. It's a Win32 app and it appears to use NodeWebKit for part of it's UI. But it's a Windows app, just like VB6 apps and just like .NET apps and just like UWP (Universal Windows Platform) apps, so I found this to be pretty cool. Now that the Evernote app is a store app it can use Windows 10 specific features like Live Tiles and Notifications and it'll be always up to date.

The Windows Store is starting (slowly) to roll out and include existing desktop apps and games by building and packaging those apps using the Universal Windows Platform. This was called "Project Centennial" when they announced it at the BUILD conference. It lets you basically put any Windows App in the Windows Store, which is cool. Apps that live there are safe, can't mess up your machine, and are quickly installed and uninstalled.

Here's some of the details about what's happening with your app behind the scenes, from this article. This is one of the main benefits of the Windows Store. Apps from the Store can't mess up your system on a global scale.

[The app] runs in a special environment where any accesses that the app makes to the file system and to the Registry are redirected. The file named Registry.dat is used for Registry redirection. It's actually a Registry hive, so you can view it in the Windows Registry Editor (Regedit). When it comes to the file system, the only thing redirected is the AppData folder, and it is redirected to the same location that app data is stored for all UWP apps. This location is known as the local app data store, and you access it by using the ApplicationData.LocalFolderproperty. This way, your code is already ported to read and write app data in the correct place without you doing anything. And you can also write there directly. One benefit of file system redirection is a cleaner uninstall experience.

The "DesktopAppConverter" is now packaged in the Windows Store as well, even though it runs at the command prompt! If your Windows Desktop app has a "silent installer" then you can run this DesktopAppConvertor on your installer to make an APPX package that you can then theoretically upload to the Store.

NOTE: This "Centennial" technology is in Windows 10 AU, so if you haven't auto-updated yet, you can get AU now.

They are also working with install vendors like InstallShield and WiX to so their installation creation apps will create Windows Store apps with the Desktop Bridge automatically. This way your existing MSIs and stuff can turn into UWP packages and live in the store.

DesktopAppConverter

It looks like there are a few ways to make your existing Windows apps into Windows 10 Store-ready apps. You can use this DesktopAppConverter and run it in your existing  silent installer. Once you've made your app a Store App, you can "light up" your app with Live Tiles and Notifications and  other features with code. Check out the https://github.com/Microsoft/DesktopBridgeToUWP-Samples GitHub Repro with samples that show you how to add Tiles or Background tasks. You can use [Conditional("DesktopUWP")] compilation if you have both a Windows Store and Windows desktop version of your app with a traditional installer.

If your app is a simple Xcopy-deploy app that has no installer, it's even easier. To prove this I installed Visual Basic 6 on my Windows 10 machine. OH YES I DID.

NOTE: I am using VB6 as a fun but also very cool example. VB6 is long out of support but apps created with it still run great on Windows because they are win32 apps. For me, this means that if I had a VB6 app that I wanted to move into the Store and widen my audience, I could.

I made a quick little Project1.exe in VB6 that runs on its own.

Visual Basic 6 on Windows 10

I made an AppxManifest.xml with these contents following this HelloWorld sample.


xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10"
xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"
xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities">
ProcessorArchitecture="x64"
Publisher="CN=HanselmanVB6"
Version="1.0.0.0" />

Scott Hanselman uses VB6
Reserved
I wish there was a description entered
Assets\Logo.png












BackgroundColor="#464646"
DisplayName="Hey it's VB6"
Square150x150Logo="Assets\SampleAppx.150x150.png"
Square44x44Logo="Assets\SampleAppx.44x44.png"
Description="Hey it's VB6" />


In the folder is my Project1.exe long with an Assets folder with my logo and a few PNGs.

Then I run the DesktopAppConverter and run this to test on my local machine.

Add-AppxPackage -register .\AppxManifest.xml

And now my little VB6 app is installed locally and in my Start Menu.

VB6 as a Windows App

When I am ready to get my app ready for production and submission to the Store I'll follow the guidance and docs here and use Visual Studio, or just do the work manually at the command line with the MakeAppx and SignTool utilities.

"C:\Program Files (x86)\Windows Kits\10\bin\x86\makeappx" pack /d . /p Project1.appx

Later I'll buy a code signing cert, but for now I'll make a fake local one, trust it, and make a pfx cert.

"C:\Program Files (x86)\Windows Kits\10\bin\x86\makecert" /n "CN=HanselmanVB6" /r /pe /h /0 /eku "1.3.6.1.5.5.7.3.3,1.3.6.1.4.1.311.10.3.13" /e 12/31/2016 /sv MyLocalKey1.pvk MyLocalKey1.cer
"C:\Program Files (x86)\Windows Kits\10\bin\x86\pvk2pfx" -po -pvk MyLocalKey1.pvk -spc MyLocalKey1.cer -pfx MyLocalKey1.pfx
certutil -user -addstore Root MyLocalKey1.cer

Now I'll sign my Appx.

NOTE: Make sure the Identity in the AppxManifest matches the code signing cert's CN=Identity. That's the FULL string from the cert. Otherwise you'll see weird stuff in your Event Viewer in Microsoft|Windows\AppxPackagingOM|Microsoft-Windows-AppxPackaging/Operational like "error 0x8007000B: The app manifest publisher name (CN=HanselmanVB6, O=Hanselman, L=Portland, S=OR, C=USA) must match the subject name of the signing certificate exactly (CN=HanselmanVB6)."

I'll use a command line like this. Remember that Visual Studio can hide a lot of this, but since I'm doing it manually it's good to understand the details.

"C:\Program Files (x86)\Windows Kits\10\bin\x86\signtool.exe" sign /debug /fd SHA256 /a /f MyLocalKey1.pfx Project1.appx

The following certificates were considered:
Issued to: HanselmanVB6
Issued by: HanselmanVB6
Expires: Sat Dec 31 00:00:00 2016
SHA1 hash: 19F384D1D0BD33F107B2D7344C4CA40F2A557749

After EKU filter, 1 certs were left.
After expiry filter, 1 certs were left.
After Private Key filter, 1 certs were left.
The following certificate was selected:
Issued to: HanselmanVB6
Issued by: HanselmanVB6
Expires: Sat Dec 31 00:00:00 2016
SHA1 hash: 19F384D1D0BD33F107B2D7344C4CA40F2A557749


The following additional certificates will be attached:
Done Adding Additional Store
Successfully signed: Project1.appx

Number of files successfully Signed: 1
Number of warnings: 0
Number of errors: 0

Now I've got a (local developer) signed, packaged Appx that has a VB6 app inside it. If I double click I'll get the Appx installer, but what I really want to do is sign it with a real cert and put it in the Windows Store!

VB6 in the Windows Store

Here's the app running. Pretty amazing UX, I know.

VB6 app as a Windows Store App

It's early days, IMHO, but I'm looking forward to a time when I can go to the Windows Store and get my favorite apps like Windows Open Live Writer, Office, Slack, and more! Now's the time for you to start exploring these tools.

Related Links


Sponsor: Big thanks to Redgate for sponsoring the feed this week. Discover the world’s most trusted SQL Server comparison tool. Enjoy a free trial of SQL Compare, the industry standard for comparing and deploying SQL Server schemas.



© 2016 Scott Hanselman. All rights reserved.
     

Smooth Interaction and Motion with the Visual Layer

$
0
0

The Composition APIs come with a robust animation engine that provides quick and fluid motion running in a separate process from your Universal Windows Platform (UWP) app. This provides a consistent 60 frames per second when running your app on an IoT device as well as on a screaming gaming machine. It is, quite simply, fast.

blogpost4-1

The Composition APIs also provide something you probably have never had access to before: the ability to create high-performing, low-level manipulation-driven custom animations like the one shown above.  Preview releases of the Composition APIs have already given you the ability to control animations with the XAML ScrollViewer’s ManipulationPropertySet. The Windows 10 Anniversary Update allows you to go even further, with the goal of empowering developers to use many types of input to drive animation.

This post will briefly cover the basics of expression animations. It will move on to a demonstration of how to drive expression animations from a ScrollViewer ManipulationPropertySet and, more importantly, why you really want to even if you don’t realize it yet. Finally, it will touch on the new InteractionTracker and give you an indication of just how much more powerful you are today as a developer than you were at the end of July.

A fast and fluid overview of expression animations

The Visual Layer supports both keyframe animations as well as expression animations. If you have worked with XAML animations before, then you are probably already familiar with how keyframes work. In a keyframe animation, you set values for some property you want to change over time and also assign the duration for the change: in the example below, a start value, a middle value, and then an ending value. The animation system will take care of tweening your animation – in other words, generating all the values between the ones you have explicitly specified.


ScalarKeyFrameAnimation blurAnimation = _compositor.CreateScalarKeyFrameAnimation();
blurAnimation.InsertKeyFrame(0.0f, 0.0f);
blurAnimation.InsertKeyFrame(0.5f, 100.0f);
blurAnimation.InsertKeyFrame(1.0f, 0.0f);
blurAnimation.Duration = TimeSpan.FromSeconds(4);
blurAnimation.IterationBehavior = AnimationIterationBehavior.Forever;
_brush.StartAnimation("Blur.BlurAmount", blurAnimation);

A keyframe animation is a fire-and-forget mechanism that is time based. There are situations, however, when you need your animations to be coordinated and actually driving each other instead of simply moving in synchronized fashion.

blogpost4-2

In the demo above (source code), each gray gear is animated based on the animation of the gear preceding it. If the preceding gear suddenly goes faster or reverses direction, it forces the following gear to do the same. A keyframe animations can’t create motion effects that work in this way, but expression animations can. They are able to do so because, while keyframe animations are time based, expression animations are reference based.

The critical code that hooks up the gears for animation in the demo is found in the following section that calls the CreateExpressionAnimation method on the Compositor instance. The expression basically says that the animation should reference and be driven by the RotationAngleInDegrees property of the Visual that is indicated by the parameter “previousGear”. In the next line, the reference parameter is assigned. In the final line, the current Visual’s RotationAngleInDegrees property is finally animated based on the value referred to in the ExpressionAnimation object.


private void ConfigureGearAnimation(Visual currentGear, Visual previousGear)
{
    // If rotation expression is null then create an expression of a gear rotating the opposite direction
    _rotationExpression = _rotationExpression ?? _compositor.CreateExpressionAnimation("-previousGear.RotationAngleInDegrees");

    // put in placeholder parameters
    _rotationExpression.SetReferenceParameter("previousGear", previousGear);

    // Start the animation based on the Rotation Angle in Degrees.
    currentGear.StartAnimation("RotationAngleInDegrees", _rotationExpression);
}

But if an animation can be driven by another animation, you may be wondering, couldn’t we also drive an animation with something more concrete like user input? Why, yes. Yes, we can.

The beauty of the ScrollViewer ManipulationPropertySet

Driving an animation from a ScrollViewer using XAML-Composition interop is fairly easy. With just a few lines of code, you can add an animation to a pre-existing ScrollViewer control by taking advantage of the GetScrollViewerManipulationPropertySet method on the ElementCompositionPreview class.

You would use this technique if you wanted to add a parallax effect to your XAML or to create a sticky header that stays in place as content scrolls beneath it. In the demo illustrated below (source code), a ScrollViewer is even used to drive a parallax effect on a ListView.

blogpost4-3

Adding parallax behavior to a XAML page can be accomplished in just a few lines, as the following sample code by James Clarke demonstrates.


CompositionPropertySet scrollerManipProps = ElementCompositionPreview.GetScrollViewerManipulationPropertySet(myScroller);

Compositor compositor = scrollerManipProps.Compositor;

// Create the expression
ExpressionAnimation expression = compositor.CreateExpressionAnimation("scroller.Translation.Y * parallaxFactor");

// wire the ParallaxMultiplier constant into the expression
expression.SetScalarParameter("parallaxFactor", 0.3f);

// set "dynamic" reference parameter that will be used to evaluate the current position of the scrollbar every frame
expression.SetReferenceParameter("scroller", scrollerManipProps);

// Get the background image and start animating it's offset using the expression
Visual backgroundVisual = ElementCompositionPreview.GetElementVisual(background);
backgroundVisual.StartAnimation("Offset.Y", expression);

The even more beautiful InteractionTracker

Driving expression animations with a ScrollViewer is extremely powerful, but what if you want to drive animations using touch gestures instead? What if you want to pull items toward you with your finger, as in the demo below (source code), or animate multiple flying images across and into the screen as happens in the demo at the top of this post (source code)?

blogpost4-4

In order to achieve these effects, you would use the new InteractionTracker and VisualInteractionSource classes. InteractionTracker is a state machine that can be driven by active input. This is what you hook up to your animations. The VisualInteractionSource class, on the other hand, determines what kind of input you will use to drive your InteractionTracker.

picture5

The following sample code demonstrates a basic implementation of an InteractionTracker that is driven by touch input. The viewportVisual is simply the backing Visual for the root element on the page. You use this as the VisualInteractionSource for the tracker. In doing so, you specify that you are tracking X and Y manipulations. You also indicate that you want to track inertial movement.


_tracker = InteractionTracker.Create(_compositor);

var interactionSource = VisualInteractionSource.Create(viewportVisual);

interactionSource.PositionXSourceMode = InteractionSourceMode.EnabledWithInertia;
interactionSource.PositionYSourceMode = InteractionSourceMode.EnabledWithInertia;

_tracker.InteractionSources.Add(interactionSource);

Hooking the tracker up to an expression animation works basically the same way as hooking up a gear Visual to another gear Visual, as you did earlier. You call the CreateExpressionAnimation factory method on the current Compositor and reference the Position property of the tracker. You then animate the Offset property of the Visual you want to add motion to your expression.


var positionExpression = _compositor.CreateExpressionAnimation("-tracker.Position");
positionExpression.SetReferenceParameter("tracker", _tracker);

contentVisual.StartAnimation("Offset", positionExpression);


Those are the basics of driving animation from almost any input. What you do with this amazing new power is entirely up to you.

Wrapping up

Expression animations and Visual Layer Interactions are both topics that can become very deep, very fast. To help you through these deeper waters, we highly recommend the following videos and articles:

Get started now – download Visual Studio.

The Windows team would love to hear your feedback. Please keep the feedback coming using our Windows Developer UserVoice site. If you have a direct bug, please use the Windows Feedback tool built directly into Windows 10.

Check Out this Fall’s New TV Shows, Movies & More

$
0
0
As summer fades and the weather cools, people begin to spend more time indoors, in front of their screens and devices, looking for entertainment. To help you navigate the deluge of offerings, the Bing team has curated carousels for this fall’s TV series, movies and books. We’ve also included predictions for top reality voting shows and the 2016 Primetime Emmy Awards®*, airing this Sunday, September 18.
 
Check out the list of Bing 2016 fall entertainment experiences, and stay tuned for new releases and updates coming this October and November.
 
TV
• Fall TV premieres: Search Bing for ‘Fall TV shows’ to see a list of this season’s lineup. Use the filters within the carousel to narrow your search by month of release, genre, or new versus returning shows.
 
 
• Cancelled TV shows: Many people search for a list of shows that won’t make it back to the small screen. If you’re among this group, Bing has you covered. Just search for ‘cancelled TV shows’ to see the list of the unfortunate programs .
• Primetime Emmy Awards: See the list of nominees and who Bing predicts will take home the statuette for each major category. For example, Game of Thrones is likely to take home an Emmy for Outstanding Drama Series for the second year in a row, and Veep is also predicted to repeat its Outstanding Comedy Series win.

 
• Reality voting shows: This season, we’re keeping a close eye on the two most searched-for reality voting shows: Dancing with the Stars (DWTS) and The Voice. In just a few weeks, we will begin making predictions for which contestants will be saved and which are destined for doom, so you’ll want to check back each week to see how things are going.
 
MOVIES
• Movies in theaters: Itching to get out of the house? How about a movie? Use Bing’s carousel of ‘fall movies’ to see what’s in theaters now, and coming soon. Click on each title to watch the trailer, read reviews, see the cast, check local show times (available starting three days prior to theater release), buy tickets, and more.
• Movies at home: Not a new feature to Bing, but always a great reminder that you can search what’s new on Netflix or Amazon to see what movies are available to stream.

 
BOOKS
• Predicted must-read books: With tens of thousands of new books published each season, it can be difficult to choose your next read. To help, we’ve enlisted our Bing Predicts technology that factors in the search, web and social buzz around the books, early reviews and more. From there, we used the data to showcase the top 50 books predicted to be the best sellers this autumn. Just search for ‘fall books’ to see which made Bing’s top list. From there you can use the filters in the carousel to search by release date and by paperback or hardback.
 
 
As you can see, it’s a jam-packed season for entertainment, but we’re just getting started. We’ll be back next month to share more. Until then, enjoy!
 
- The Bing Team


 
* The Emmy name and the Emmy statuette are the trademark property of The Academy of Television Arts & Sciences and the National Academy of Television Arts & Sciences. Additionally, the Emmy name, logo and statuette are licensed to the International Academy of Television Arts & Sciences for International Emmys.

“Throwing your voice” with Spatial Audio

$
0
0

The age-old act of ventroquilism sees a puppet move its mouth while the controlling ventriloquist speaks without moving their lips – pretty impressive! The underlying technique has the ventriloquist “throwing” their voice in a joint audial and visual illusion.

Enter Spatial Audio, a set of ground breaking technologies originally created by Microsoft for HoloLens and now being exposed to Universal Windows Platform (UWP) and Unity apps.

The underlying “technique” of Spatial Audio is mapping how audio reaches each ear and how headshape, ear contours, the inner ear and the brain make sense of this audio to determine the 3D source of a sound. Audio is then “positioned” for each ear, unique to its physical orientation. This is known as “binaural audio.” In many ways, binaural audio mirrors the various illusions used in the HoloLens to create the impression that digital objects seen through the device have a physical location.

Read on for a bit more on the theories behind spatial audio, as well as a how-to on enabling spatial audio in your app.

Think of this as a lesson in some very technologically advanced ventriloquism!

What you will need

  • Stereo headset. To get the most out of Spatial Audio, you will first need a headset. Spatial audio is made to project binaural sound into your ears from an audio headset in order to create the illusion of directional audio.
  • Visual Studio 2015 Update 3. Visual Studio 2015 Update 3 (and above) will ensure that you have the latest bits to work with.
  • Spatial Audio Samples on GitHub. The Spatial Audio Samples on GitHub will give you tons of information and useful code to walk through.

A little bit of theory: Understanding HRTFs

Understanding how position impacts the sounds that reach our ears is key to spatializing audio within your app.

picture1

HRTF stands for head-related transfer function, and is a representation of how sound reaches either ear. A pair of HRTFs provides enough information for the human brain to determine the direction, elevation, and distance of an audio source. As the listener’s head moves, the HRTFs likewise change, providing additional information to help eliminate an audio phenomenon known as front-back confusion while also improving elevation perception.

Next, we’ll run through the steps to position an audio source via audio node emitters.

The foundation: Audio Graphs

Spatial Audio is built atop the Windows 10 AudioGraph API and is available in the AudioGraph 1.1 API. The AudioGraph 1.0 API provided a set of classes to combine audio nodes in a workflow for audio routing and mixing.

The AudioGraph 1.1 API adds the AudioNodeEmitter and AudioNodeListener classes. These allow you to position both the audio source as well as the audio listener in 3-dimensional space relative to one another. Interestingly, you can have many audio emitters but only one listener.

picture2

By way of illustration, this sample code from the SpatialSphereDemo illustrates the creation of multiple audio sources that can be used as emitters in the same app with the first argument, a Vector3 class establishing the emitter’s location; the second argument, specifying an audio file to play; the third, audio gain.


private SpatialSoundSource[] _spatialSounds = new SpatialSoundSource[] {       
    //Go around the sphere horizontally 
    // Left-/Right+,Up+/Down-,Front-/Back+ 
    new SpatialSoundSource (new Vector3( 0f, -1f, -4f), "Files/Audio/FrontPosition.wav",       1f,   new Point(298d,208d)), 
    new SpatialSoundSource (new Vector3( 3f, -1f, -3f), "Files/Audio/FrontRightPosition.wav",  1f,   new Point(417d,215d)), 
    new SpatialSoundSource (new Vector3( 4f, -1f,  0f), "Files/Audio/RightPosition.wav",       1f,   new Point(543d,270d)), 
    new SpatialSoundSource (new Vector3( 3f, -1f,  3f), "Files/Audio/RearRightPosition.wav",   1f,   new Point(417d,347d)), 
    new SpatialSoundSource (new Vector3(-3f, -1f,  3f), "Files/Audio/RearLeftPosition.wav",    1f,   new Point(151d,345d)), 
    new SpatialSoundSource (new Vector3(-4f, -1f,  0f), "Files/Audio/LeftPosition.wav",        1f,   new Point(5d,270d)), 
    new SpatialSoundSource (new Vector3(-3f, -1f, -3f), "Files/Audio/FrontLeftPosition.wav",   1f,   new Point(149d,215d)), 
    new SpatialSoundSource (new Vector3( 0f, -1f, -4f), "Files/Audio/FrontPosition.wav",       1f,   new Point(298d,208d)), 
};

In the full demo, each of those emitters is associated with a ball on the outside of a glass sphere, shown below. As each ball lights up in turn, the audio plays a human voice announcing the location of the red ball while the Spatial Audio technology creates the 3D spatial illusion that the audio is coming from that location with respect to the listener.

picture3

A demo: “Hello, World” – in 3D!

The Spatial “Hello, World Demo” provides the clearest example of how to create an audio node emitter. It simply involves creating an audio node, providing it with some characteristics (such as an audio decay model and shape), then providing it with an initial position. Here are the steps to follow:

  1. Create emitter
  2. Place emitter in 3D space
  3. Play an audio file through emitter

// Create the input node 
AudioNodeEmitter audioNodeEmitter = new AudioNodeEmitter(AudioNodeEmitterShape.CreateOmnidirectional(),  
    AudioNodeEmitterDecayModels.CreateOutdoor(),  
    AudioNodeEmitterSettings.None); 
 
audioNodeEmitter.Position = new Vector3(-220f, 0, -220f); 
StorageFile file = await GetAudioFile();

In the full sample, you are able to move the position of the audio node around in order to use the one of the most recognizable directional sound experiences, the Doppler effect (exemplified in the sound variations you hear as a police siren passes by), in order to illustrate how spatial audio works.

Tip: For the best experience, make all spatialized audio files mono and target 48khz audio.

You can test the emitter created above by running the full demo and manually updating the position of the emitter in order to create the Doppler effect as it moves around the listener at X, Y coordinates 0, 0.

picture4

Hopefully this demo provides a good overview of audio node positioning, and the impact it has on the user.

Now for an example of implementing this spatialized audio in a game using Unity.

The application: Spatial audio for Unity

Unity3D already supports 3D audio with volume control and panning. However, spatialized audio is a different and more fine-grained technique —it places objects behind you and moving around you.

In order to use Spatial Audio in Unity, you will take advantage of the MS HRTF Spatializer plugin. Fortunately, it is already built into certain editions of Unity and all you have to do to enable it is go into Edit>Project Settings>Audio>Spatializer and select MS HRTF Spatializer as your Spatializer, as shown below.

picture5

In order to then use Spatial Audio, select your game object with an audio source attached and perform the following three steps:

  1. Check the Spatialize option.
  2. Set Spatial Blend to 3D.
  3. Expand 3D Sound Settings and set Volume Rolloff to Custom Rolloff.

picture6

That’s all there is to it! At this point, your audio source is effectively playing from a 3D spatial location.

Wrapping up

You can see a great demo of Spatial Audio in action starting at 20:14 in this //build/ video, with Microsoft rock stars Adam Tuliper and Steven Wilssens walking you through the feature.

picture7

Beyond demos, what are some real-world applications of spatial audio?

As mentioned before, the most immediate and obvious use for Spatial Audio is in mixed reality and virtual reality experiences for devices like the HoloLens. There are also other, subtler ways Spatial Audio can affect our lives. For instance, perhaps one day we will play movies and instead of getting the somewhat makeshift effect of our 5.1 or 7.1 audio system, we’ll be able to get highly accurate positioning of the various sound sources in a film.

Spatial Audio is also the core of music listening. Back in the day, we used to listen to music from large audio speakers that were typically positioned in front of us. Now we listen to music through earbuds, and the audio sources are perpendicular to our heads. Which is “more correct” for enjoying music? If you consider how live performances are set up, the music is actually supposed to be in front of us rather than coming from our flanks. Spatial Audio models can actually alter the sound coming from our headsets so that the direction of the audio emulates stereo speakers positioned in front of us, providing the “correct” sound location even if we prefer not to have physical stereo speakers in our homes.

One of the most stunning applications of Spatial Audio was demonstrated in the keynote at //build/ this year in the Cities Unlocked project. In this amazing project, Spatial Audio is used to help provide and enhance mobility for the visually impaired.

Finally, Spatial Audio can be used on the Xbox or our desktop computers to improve an extremely common annoyance: muddy audio on audio chat. By separating out different speakers and giving them distinct physical locations with respect to the listener, we are surprisingly able to easily pick out the different voices even when they are speaking at the same time. This could potentially be revolutionary both for online gaming and business.

To learn more about Spatial Audio and related technologies, check out the following links:

Get started building your own app with spatialized audio via Visual Studio.

The Windows team would love to hear your feedback. Please keep the feedback coming using our Windows Developer UserVoice site. If you have a direct bug, please use the Windows Feedback tool built directly into Windows 10.

Unity Interop and App Extensibility (App Dev on Xbox series)

$
0
0

Continuing what we started during the “App Dev on Xbox” event, today we are making available yet another app experience – Atmosphere. In this blog post, you will learn how to get started building great 2D and 3D experiences with Unity and XAML, how to open up your app so other app developers can extend your app functionality, and how you can make your app functionality available to other apps. Even though this blog post is part of the App Dev on Xbox series, the majority of the content applies to the entire Universal Windows Platform.

If you missed the previous blog post, we looked at how you can deliver the best possible experience for your app in a responsive and scalable way so it can target all device form factors and provide a premium experience on the TV. Among other things, we covered how to take advantage of the controller and enable direction navigation, how to optimize for the couch viewing distance, ways to customize the focus visual to make it your own and much more.

And if you missed the live event, you can still watch videos of all of the sessions on the “App Dev on Xbox” event page on Channel 9.

Check out this Channel 9 demo using the Atmosphere app, and read on for the how-to.

Atmosphere

picture1

The Atmosphere app is a weather app that showcases the use of the popular Unity Engine in a normal Universal Windows Platform (UWP) application. It renders a 3D layer below a 2D XAML layer. The 3D world renders the weather with special effects like rain, thunder, clouds and so on for each day, and then the XAML User Interface (UI) layer communicates the information to the user. The app also showcases the use of app extensions that enable other developers to extend certain areas of the app – in this case, the extension provides music that matches the mood of the current weather. In addition, the weather service used by the app is exposed through an app service that enables other apps to use that weather information, as illustrated by Fourth Coffee (the news app experience from the previous blog post). Let’s dive in.

picture2

The Design of Atmosphere

Atmosphere shows you what the weather is like using straightforward data and insightful visuals.

Numbers, short descriptions and icons tell users whether it’s cold or warm or windy outside. This leads to a clean and to-the-point design, so that people can gather its information as quickly and confidently as possible.

This is what most weather apps do, and it’s important.

Atmosphere also uses color, animation and 3D imagery to capture the emotion and personality of weather. Through subtle color changes and additional effects, like rain and shadows, the mood of weather is conveyed.

By combining clean visuals (through XAML) and smooth animations (with Unity), as well as the addition of weather-themed music, Atmosphere delivers a well-rounded experience that is simple and delightful.

This allows Atmosphere to apply itself across the platform, from cinematic viewing on the Xbox One to on-the-go weather updates on a phone, and everything in between.

Making your UWP work in three dimensions with Unity

Unity is a very popular 3D engine designed to develop 2D and 3D games and interactive experiences. The engine supports both C# and JavaScript as development languages and has a clean and beautiful editor. Unity supports exporting to a vast number of platforms, including UWP. It enables you to simply drag and drop 3D assets like models into your scene, position them around and write custom logic to develop the experience you want.

picture3

1. Creating worlds with Unity
How Atmosphere works is that we developed a generic world captured inside a glass-looking sphere, controlled by a class WorldController. Each world is essentially an instance of the WorldController.

picture4

It consists of a simple sphere that acts like the border of the world, and everything for each instance of the world happens within this border. For instance, we have the 3D models that represent the environment plus different weather effects that will be visible based on what type of weather we set the environment to in the WorldController instance.

Another class, called WeatherController, acts like the main class for controlling the Unity layer. This is what we expose to the UWP part of the application. The WeatherController controls each WorldController independently.

picture5

The functions we expose are: SetWeather(..), which sets the weather on one of the worlds; SetOrientation(..), which changes the orientation of the Unity layer so it matches the XAML layer; and lastly SetView(..), for positioning the worlds around in the canvas. Three views are needed: one for the close-up view, one for the detailed view and one for the 5-day forecast.

The positioning of the spheres on the screen can be done in many ways – we chose to manually distribute them on the screen based on the aspect ratio so it would be easier to align it with a XAML Grid on the UI layer.

2. Unity Interop
Since the 3D rendering layer will run on a different thread than the 2D XAML UI, we need to enable these two layers to communicate. This is done using static variables and functions, as well as events.

The first thing we do is fire an event called AssetsLoaded from the WeatherController class when Unity is ready and all the assets are loaded. We know this is true when the WeatherControllers Start() function is called automatically by Unity.


public static event EventHandler AssetsLoaded;
void Start()
{
    if(AssetsLoaded != null)
        AssetsLoaded(null, null);
}
We can then catch this event in the UWP part of the app and write custom logic related to this.
WeatherController.AssetsLoaded += WeatherController_AssetsLoaded;

private void WeatherController_AssetsLoaded(object sender, EventArgs e)
{
    ...
}

Since we defined SetWeather(..), SetView(..) and SetOrientation(..) as static functions, we can simply call them using WeatherController.SetWeather(..) from the UWP part of the application.

3. Exporting to UWP from Unity
Once we have this base logic in place, we can export it as a UWP from Unity. This is done from File -> Build Settings:

picture6

Windows Store is selected, the SDK is set to Windows 10 and the UWP Build Type is set to XAML since we want to add XAML and features on top of this.

Once exported, it will generate a normal UWP package that can run on any Windows 10 device, including Xbox. The generated UWP solution comes with three build configurations: Debug, Release and Master. The one you need to use when submitting your app to the store is the Master build.

4. Data, UWP and UI
The UI is developed using XAML and is placed on top of the SwapChain that renders the 3D content.

The weather data is then captured from a weather source and set using the functions we exposed in the WeatherController class, as well as bound using Data Binding to the XAML controls used for the UI.

picture7

Using XAML elements we define the layout of all the controls used for the UI using Grids, TextBlocks, Images for the weather icons and so on.

App Services

By implementing an app service in your UWP apps, you create an endpoint to which other apps on the same machine can call in to retrieve or provide data. The cool thing is that your app does not have to be running and it can be woken up in the background without having to load any UI. In Atmosphere, the weather service used by the application is made available through an app service so other apps, with only few lines of code, can consume the endpoint and get the current weather without needing to know how to communicate with the weather service.

1. Creating app service
There are two things that you as a developer need to do to expose an app service. First, you need to declare that your app exposes an app service by adding these lines of code in your app manifest:

<uap:Extension Category="windows.appService"><uap:AppService Name="com.atomosphere.weather" /></uap:Extension>

The AppService name (in this case com.atmosphere.weather) is what other apps will use to call into the app service. In addition, they will need to know your app package family name (found under Packaging in the manifest UI).

Second, you need to override the OnBackgroundActivated method in App.xaml.cs. This method will be called when another app accesses the app service, and it’s where we can get a reference to the app service connection that we can use to send and receive messages from/to the caller method in App.xaml.cs. This method will be called when another app accesses the app service, and it’s where we can get a reference to the app service connection that we can use to send and receive messages from/to the caller.


protected override void OnBackgroundActivated(BackgroundActivatedEventArgs args)
{
    base.OnBackgroundActivated(args);
    // Get a deferral so that the service isn't terminated.
    this.backgroundTaskDeferral = args.TaskInstance.GetDeferral();

    // Associate a cancellation handler with the background task.
    args.TaskInstance.Canceled += OnTaskCanceled; 

    // Retrieve the app service connection and set up a listener for incoming app service requests.
    var details = args.TaskInstance.TriggerDetails as AppServiceTriggerDetails;
    appServiceconnection = details.AppServiceConnection;
    appServiceconnection.RequestReceived += OnRequestReceived;
    appServiceconnection.ServiceClosed += AppServiceconnection_ServiceClosed;
}

All messages are passed as ValueSet, essentially a key and value map that can be used to implement your custom protocol. The only command that our app currently accepts is the CurrentWeather and it returns a ValueSet that contains the current Temperature. The full code is here.


private async void OnRequestReceived(AppServiceConnection sender, AppServiceRequestReceivedEventArgs args)
{
    var messageDeferral = args.GetDeferral();

    ValueSet message = args.Request.Message;
    ValueSet returnData = new ValueSet();

    if (message.ContainsKey("Command"))
    {
        string command = message["Command"] as string;
         // ... //
    }
    else
    {
        returnData.Add("Status", "Fail: Missing command");
    }

    await args.Request.SendResponseAsync(returnData); // Return the data to the caller.
    messageDeferral.Complete(); 

}


2. Consuming the app service
Calling into the app service allows other developers to use functionality that is part of your app and runs in the context of your app. To illustrate this, we used Fourth Coffee, the news app experience from the previous blog post, to implement the app service from Atmosphere and display the current weather on the home page. The code below comes from the app source code which is already available on the GitHub repository.

picture8

Apps can easily check to see if an app service is available by calling the FindAppServiceProvidesAsync method, which returns all app services with the name provided. Optionally, your app could also ask the user to install a specific app from the store, if not installed already, which returns all app services with the name provided. Optionally, your app could also ask the user to install a specific app from the store, if not installed already.


var services = await AppServiceCatalog.FindAppServiceProvidersAsync("com.atmosphere.weather");

Calling into the service requires the creation of a new AppServiceConnection and configuring it with the app service name and app package family name. Once the service is created, the channel can be opened and you can start sending messages in the form of ValueSet, then await a response. This is what it looks like in Fourth Coffee:


service = new AppServiceConnection();
service.AppServiceName = "com.atomosphere.weather";
service.PackageFamilyName = "WeahterCastPoly_pzq3xp76mxafg";
await service.OpenAsync();
var message = new ValueSet();
message.Add("Command", "CurrentWeather");
var response = await service.SendMessageAsync(message);
// use result

To call into the app service from another app, there are two things that developers must know about the app providing the app service: (1) the name of the app service, and (2) the package family name.

There are multiple ways to make the transfer of this information easier for developers who will be accessing your app service.

If your app service will be accessed by multiple app developers, you should consider creating a small library that developers can use within their apps without having to know anything about the app service. The library should wrap around your protocol and implement the calls to your service by including the app service name and package family name.

Alternately, an app service can be made discoverable through the use of App Extensions, which we will cover in the next section.

App Extensions

Creating an ecosystem of apps would not be possible without having some way for these apps to communicate and extend themselves. With the Windows 10 Anniversary Update, developers can now open up their apps so other developers can write extensions that provide functionality not otherwise available in the host app. The extensions themselves are just other UWP apps that can be downloaded from the store the same way and can work as standalone apps.

Getting started is really straightforward. First the host application, in this case Atmosphere, declares that it is an extension host and defines the name in the manifest:

<uap3:Extension Category="windows.appExtensionHost"><uap3:AppExtensionHost><uap3:Name>Atmosphere</uap3:Name></uap3:AppExtensionHost></uap3:Extension>

The extension can then define itself as an extension in its own manifest by providing the same name as the host:

<uap3:Extension Category="windows.appExtension"><uap3:AppExtension Name="Atmosphere" 
                     Id="Sounds" 
                     Description="Adds additional sound features to the Atmosphere compatible apps" 
                     DisplayName="Atmosphere Sounds" 
                     PublicFolder="Sounds"></uap3:AppExtension></uap3:Extension>

For both of these, make sure you have the namespace definition for UAP-3 and that it is added to the IgnorableNamespaces at the top of the manifest:


xmlns:uap3=http://schemas.microsoft.com/appx/manifest/uap/windows10/3

To use extensions in the host app, first you will need to open the AppExtensionCatalog for the name you defined in the manifest (e.g. Atmosphere) and subscribe to events for when other extensions are installed. This allows you to install extensions even when your app is running:for the name you defined in the manifest (e.g. Atmosphere) and subscribe to events for when other extensions are installed. This allows you to install extensions even when your app is running:


catalog = AppExtensionCatalog.Open("Atmosphere");
_catalog.PackageInstalled += _catalog_PackageInstalled; 

Once the AppExtensionCatalog is open, iterating over every extension installed can be done using the FindAllAsync() command.


foreach (var extension in await _catalog.FindAllAsync())
{
    // use extension
}

In general, there are two ways that an extension can help extend the functionality: by providing an app service, and by providing data files in the public folder.

1. AppService
First, the extension provider can expose an app service that provides functionality for other developers to take advantage of in their apps. The extension can then provide the endpoint information as part of the properties, and it can be accessed by the host as described in the previous section. To illustrate this, Atmosphere provides an extension for Fourth Coffee where the app service is defined and can be used by Fourth Coffee even without Fourth Coffee knowing the name of the service or the package family name.

To provide the name of the app service, the extension can add custom properties to the extension definition in the manifest:

<uap3:Extension Category="windows.appExtension"><uap3:AppExtension Name="FourthCoffee"
                      Id="weather"
                      Description="Describes com.atmosphere.weather app service"
                      DisplayName="Atmosphere"
                      PublicFolder="Public"><uap3:Properties><Service>com.atmosphere.weather</Service></uap3:Properties></uap3:AppExtension></uap3:Extension>

In this case, we added a new property called Service that includes the service name. In Fourth Coffee, we can then use the extension to read the properties and discover the name of the app service. In addition, the extension already provides the package family name to be used. You can see the code in Fourth Coffee here:


var properties = await extension.GetExtensionPropertiesAsync() as PropertySet;

if (properties != null && properties.ContainsKey("Service"))
{
    PropertySet service = properties["Service"] as PropertySet;
    var serviceName = service["#text"].ToString();
    var packageName = extension.Package.Id.FamilyName;

    Weather = await WeatherService.GetWeather(serviceName, packageName);
}

2. Public folder
Second, the extension provider can host data files that can be made available to the host to use. This allows assets to be shipped separately from the main app and extended over time through extensions. Other developers creating extensions for your app can also create assets that can be used within your app. Atmosphere has the ability to play sounds depending on what the current weather is, using sounds found in extensions provided by other developers. To see this in action, install the Atmosphere Music Extension app found in the same solution as Atmosphere. You will notice that Atmosphere will pick up the extension immediately and start playing the sounds.

Calling the GetPublicFolderAsync method on an extension allows you to get a StorageFolder that points to data files the extension has made available to your app. Here is the code from Atmosphere:


var folder = await extension.GetPublicFolderAsync();
var files = await folder.GetFilesAsync();

_soundFiles = files.Where(i => i.Name.EndsWith(".mp3"));

Until next time…

…check out the app source on our official GitHub repository, read through some of the resources provided, watch the event if you missed it, and let us know what you think through the comments below or on twitter.  if you missed it, and let us know what you think through the comments below or on twitter.

Next week we will release another app experience and go in-depth on how to develop cross-platform applications by sharing code with Xamarin. We will also cover how to enable background audio in your applications so the music can continue playing while the user is playing a game (or staying up late to finish up this blog post).

Until then, happy coding!

Resources

Get started now – download Visual Studio.

The Windows team would love to hear your feedback. Please keep the feedback coming using our Windows Developer UserVoice site. If you have a direct bug, please use the Windows Feedback tool built directly into Windows 10.


Microsoft discontinuing Project Server/TFS Integration. Partner to provide solution

$
0
0

As Agile practices continue to evolve and become our customer’s primary choice for work management, we are changing how TFS and Project Server integrate. With the next major version of TFS, TFS ’15’, we will no longer provide an out-of-box integration experience between Project Server and Team Foundation Server. Nor will we be providing an out-of-box integration for Project Online and Visual Studio Team Services.

We will continue to support our existing integration solution, which supports the following versions

  • TFS 2010 SP1, 2012, 2013, and 2015
  • Project Server 2007, 2010 and 2013

Going forward, we are turning to a partner that provides an integration solution for both Project Server/TFS and Project Online/Team Services.

Why the change?

When we first introduced our Project Server/TFS integration several years ago, Agile was not as prominent as it is today. Many projects in TFS were being run as traditional projects. As Agile became dominant, most TFS projects are being run as Agile projects. We found that our integration was not meeting customer’s expectations.

We followed up with several customers who were using the Project Server/TFS integration and found that nearly all customers who attempted the integration were no longer using it.

Many integrations were abandoned because Agile teams track progress differently than traditional projects. Traditional projects typically plan for the entire scope of a project and use hours to track progress. Agile projects plan on demand, typically 2-3 sprints out, and often use story points to track progress.

While we believe in integration between TFS and Project Server, our current integration was not meeting most customer’s needs.

We understand that some customers have a valid need for Project Server/TFS Integration. Therefore, we have decided to work with a partner who specializes in this area.

A partner solution

Tivitie is a partner who provides integration between Project Server/Project Online and TFS/Visual Studio Team Services. Tivitie’s solution has passed a design review performed by our engineering team. You can find more information on Tivitie’s website or in the Visual Studio Team Services Marketplace.

We are in the process of looking for other partners in this space. If you are a partner that provides this solution, please reach out to us. We’d love to talk with you.

 

If you have any questions or feedback, feel free to comment on this blog post or send email to pstfsintfeedback@microsoft.com. Sending email will allow us to follow up and dig into any specific concerns you have without divulging information in a public forum.

If you are an active user of the existing Project Server/TFS Integration, we want to hear from you.

Thank you

Animations with the Visual Layer

$
0
0

When the layout of your Universal Windows Platform (UWP) app changes, there is often a slight pause as your app rearranges content to fit the new window size or orientation. Composition APIs let you create smooth-as-butter animations between these states so your layout changes won’t jar your users. After all, layout changes are a basic fact of the app life cycle. It doesn’t mean we can’t handle them gracefully.

image1

Layout animations aren’t completely new, of course. UWP has always allowed you to hook up XAML transitions. These animations have tended to be, let’s just say, somewhat limited. By using implicit animations in the Visual Layer, however, you can have access to low-level animations that run at 60 frames a second in a separate process and all the freedom you need to create the layout animations you want.

Implicit versus Explicit animations

So what exactly is an implicit animation? This is best understood by contrasting it with explicit animations. Explicit animations are animations that you start running yourself in code-behind by calling a method like StartAnimation on a Visual.

For instance, here’s an example of a gear animation and the code used to get it started.

image2


_gearMotionScalarAnimation.Duration = TimeSpan.FromSeconds(secondsPerRotation); 
_gearVisuals.First().StartAnimation("RotationAngleInDegrees", _gearMotionScalarAnimation);

Implicit animations, on the other hand, are configured and then triggered by property changes. There’s a fire-and-forget quality to implicit animations. All you have to do is wire them up and they will just keep working for you, getting recreated and then cleaned up every time the trigger fires.

Here’s how you create and configure an implicit animation in four easy steps:

  1. Create an implicit animation collection.
  2. Create the animation or group of animations.
  3. Associate the animation value to a trigger key in the collection.
  4. Add the collection to your Visual’s ImplicitAnimations property.

The following code is used to create the fruit animations in the animated GIF at the top of this post:


// Create an implicit animation collection (just one member in this case) 
var implicitAnimationCollection = _compositor.CreateImplicitAnimationCollection(); 
 
// Create the animation 
var offsetKeyFrameAnimation = _compositor.CreateVector3KeyFrameAnimation(); 
offsetKeyFrameAnimation.Target = "Offset"; 
 
// Final Value signifies the target value to which the visual will animate 
// in this case it will be defined by new offset 
offsetKeyFrameAnimation.InsertExpressionKeyFrame(1.0f, "this.FinalValue"); 
offsetKeyFrameAnimation.Duration = TimeSpan.FromSeconds(3); 
 
// Associate the animation to the trigger 
implicitAnimationCollection["Offset"] = offsetKeyFrameAnimation; 
 
// Finally, add the implicit animation to individual Visuals 
foreach (var child in _root.Children) 
{ 
    child.ImplicitAnimations = implicitAnimationCollection; 
}

There are two things worth noting about this code:

  • First, only one trigger property is being used, Offset, so the ImplicitAnimationCollection has only one member.
  • Second, the animation uses the Offset property as a trigger, but also uses the Offset property for the animation itself. This is actually pretty common since you will usually want to animate the same property that sets off the transition – for instance, if an element’s scale or rotation changes you would want to create a transition animation between the start and end scale sizes or the start and end rotations.

For extra visual flair you could also decide to have a change in a Visual’s Offset trigger more than one animation – for instance, a position animation as well as a bit of spinning and pulsing. Go to the Windows UI Dev Labs GitHub repository for the full source code for this implicit animations sample.

Using implicit animations as layout animations

In order to apply implicit animations to your XAML layout, the only additional step you need to do, beyond what has been covered in the previous section, is to grab the backing Visuals for any UIElements you intend to animate.

image3

The Layout Animations demo from the Windows UI Dev Labs Sample Gallery on GitHub is basically a GridView control with several images in its Items collection.


        . . . 

Whenever the XAML page is resized, images inside the GridView are automatically shifted around by the underlying framework, altering the Offset property of each of the Visuals as it is moved from one position to another.
Here’s how you create and configure an implicit animation and add it to XAML elements in five easy steps:

  1. Create an implicit animation collection.
  2. Create the animation.
  3. Associate the animation value to a trigger key in the collection.
  4. In the ContainerContentChanging event handler, use the interop method GetElementVisual to peel of the backing Visual from a UIElement.
  5. Add the collection to your backing Visual’s ImplicitAnimations property.

The first three steps can all be done in the page’s constructor.


_compositor = ElementCompositionPreview.GetElementVisual(this).Compositor; 
 
// Create ImplicitAnimations Collection.  
_elementImplicitAnimation = _compositor.CreateImplicitAnimationCollection(); 
 
// Define trigger and animation that should play when the trigger is triggered.  
_elementImplicitAnimation["Offset"] = createOffsetAnimation();

In the Layout Animations demo, the final two steps are completed in the GridView’s ContainerContentChanging event handler.


private void gridView_ContainerContentChanging(ListViewBase sender, ContainerContentChangingEventArgs args) 
{ 
    var photo = args.ItemContainer; 
 
    var elementVisual = ElementCompositionPreview.GetElementVisual(photo); 
    elementVisual.ImplicitAnimations = _elementImplicitAnimation; 
}

It really is that simple to add fast, fluid and beautiful layout animations to your XAML page with the Visual layer.

Connected animations

For navigation transitions between pages, the Visual Layer provides a different mechanism known as connected animations to help you make your UI sweeter. Connected animations help the user stay oriented when she is performing common tasks such as context switching from a list of items to a details page.

image4

You can download the full source for this connected animations sample on GitHub.

Wrapping up

The visual power being made available to developers through the Composition APIs have basically always been a part of the UI Frameworks. They just haven’t been accessible until now. Think of this as a UI nuclear reactor being handed over to you to play with. With this awesome power, however, also comes the responsibility to create sweet UI and beautiful interactions. Go forth and be amazing.

To learn more about the topics covered in this post, you are encouraged to voraciously consume the following articles and videos:

Try out your animation skills – download Visual Studio and get designing!

The Windows team would love to hear your feedback.  Please keep the feedback coming using our Windows Developer UserVoice site. If you have a direct bug, please use the Windows Feedback tool built directly into Windows 10.

Self-contained .NET Core Applications

$
0
0

Just in case you missed it, .NET is all open source now and .NET Core is a free, open source, cross-platform framework that you can download and start with in <10 minutes. You can get it on Mac, Windows, and a half-dozen Unixes at http://dot.net. Take that along with the free, cross-platform Visual Studio Code and you'll be writing C# and F# all over the place.

Ok, that said, there's two ways to deploy a .NET Core application. There's FDD and SCD. Since TLAs (three letter acronyms) are stupid, that's Framework-dependent and Self-contained. When .NET Core is installed it ends up in C:\program files\dotnet on Windows, for example. In the "Shared" folder there's a bunch of .NET stuff that is, well, shared. There may be multiple folders, as you can see in my folder below. You can have many and multiple installs of .NET Core.

When you're installing your app and its dependencies BUT NOT .NET Core itself, you're dependent on .NET Core already being on the target machine. That's fine for Web Apps or systems with lots of apps, but what if I want to write an app and give it to you as zip or on a USB key and and I just want it to work. I'll include .NET Core as well so the whole thing is a Self Contained Deployment.

It will make my "Hello World" application larger than if I was using an existing system-wide install, but I know it'll Just Work because it'll be totally self-contained.

Where is .NET Core installed to?

If I deploy my app along with .NET Core it's important to remember that I'll be responsible for servicing .NET Core and keeping it up to date. I also need to decide on my target platforms ahead of time. If I want it to run on Windows, Mac, and Linux AND just work, I'll need to include those target platforms and build deployment packages for them. This all makes mostly intuitive sense but it's good to know.

I'll take my little app (I'm just using a "dotnet new" app) and I'll modify project.json in a text editor.

My app is a .NETCore.App, but it's not going to use the .NET Core platform that's installed. It'll use a local version so I'll remove "type="platform"" from this dependency.

"frameworks": {
"netcoreapp1.0": {
"dependencies": {
"Microsoft.NETCore.App": {
"version": "1.0.1"
}
}
}
}

Next I'll make a runtimes section to specify which ones I want to target. There's a list of ALL the Runtime IDs here.

"runtimes": {
"win10-x64": {},
"osx.10.10-x64": {},
"ubuntu.14.04-x64": {}
}

After running "dotnet restore" you'll want to build for each of these like this:

dotnet build -r win10-x64
dotnet build -r osx.10.10-x64
dotnet build -r ubuntu.14.04-x64

And then publish release versions after you've tested, etc.

dotnet publish -c release -r win10-x64
dotnet publish -c release -r osx.10.10-x64
dotnet publish -c release -r ubuntu.14.04-x64

Once this is done, I've got my app self-contained in n folders, ready to deploy to whatever systems I want.

Self-contained .NET app built for 3 OSs

You can see in the Win10 folder there's my "MYAPPLICATION.exe" (mine is called scd.exe) that can be run, rather than running things like developers do with "dotnet run."

I run foo.exe, not dotnet.exe now

There's lots of good documentation about how you can tune and define exactly what gets deployed with your self contained application over at the .NET Core Docs. You can do considerable trimming to .NET Core, and there's talk of that becoming more and more automated in the future, possibly down to the method level.


Sponsor: Big thanks to Redgate for sponsoring the feed this week. Discover the world’s most trusted SQL Server comparison tool. Enjoy a free trial of SQL Compare, the industry standard for comparing and deploying SQL Server schemas.



© 2016 Scott Hanselman. All rights reserved.
     

TFVC Support in Preview for Team Services Plugin for IntelliJ and Android Studio

$
0
0

We are proud to announce that Team Foundation Version Control (TFVC) support is being added to the Team Services plugin for IntelliJ and Android Studio. Currently, the 1.106.0 version of the plugin will contain preview functionality to support TFVC repositories in the IDEs. Android Studio developers stuck with no TFVC support to create mobile apps now have an alternative to the command line. You made your needs known on User Voice and now we are here to meet them!

The initial functionality available for preview is:

  • Checkout a TFVC repository from Team Services or Team Foundation Server 2015
  • View, add, and rollback local changes in your repository
  • Create, view, and edit your workspace
  • Checkin and update local files
  • Merge conflicts from updates

Pasted image at 2016_09_16 09_27 AM

To start using the TFVC features, download the latest version of the plugin and follow the setup requirement steps.

With this preview release, we welcome any feedback from you so please let us know what needs to be improved and what else you would like to see. Instant feedback can be given in the IDE with the smile/frown icons.

To keep up-to-date on the growing TFVC feature set, check out our team site.

If you would like to contribute to our plugin, we have open sourced our code on GitHub.

Vcpkg: a tool to acquire and build C++ open source libraries on Windows

$
0
0

We are delighted to announce the availability of VCPkg on GitHub https://github.com/Microsoft/vcpkg . Vcpkg and its associated open sourced port tree simplify acquiring and rebuilding open source libraries on Windows. s

Acquiring Native Libraries on Windows is a critical part of the application development process; our surveys results show that 80% of C++ projects depend on 2 or more 3rd party libraries. Despite this the current process for acquiring Native Libraries falls far below C++ developers’ expectations when compared to other platforms such as Homebrew on Mac and apt-get on many Linux distributions.

At the beginning of this project we spend lot of time analyzing the different solutions available today on different platforms, what are the success factor and failures. We saw that C++ developers have more variables than “managed” developers (.NET but also Java, JavaScript, node…) like compiler flavors and options. We saw that the successful approaches always give the ability to have access to the source code and to rebuild from it. We created a document (FAQ) explaining some of our choices.

The core of our approach is to provide a public GitHub repo which contains a collection of build script and patches (not the source itself, but just a port tree as defined in https://en.wikipedia.org/wiki/Ports_collection) to allow developers building the libraries on Windows.

Get it Started

To acquire the tool, 2 solutions:

  1. Rebuild the tool from github: git clone https://github.com/Microsoft/vcpkg
    • Once cloned, run this command:
    • C:\src\vcpkg> powershell -exec bypass scripts\bootstrap.ps
    • That will generate the “lib folder” hierarchy and build the tool itself (vcpkg.exe)
  2. Download the binary distribution, containing the exe here and unzip it in the folder of your choice.

Pre requisite:

  1. Visual Studio 2015 installed
  2. Windows 7 (min)

You are all set (no gac, no registry… the tool and the associated “lib folder” are xcopyable)

search, install, list, integrate will be the main options you’ll use with the tool, to search a library in the catalog, install a given library, list the already installed ones and integrate the “lib folder” to Visual Studio to simplify the usage of the libs (no need to manually add headers and lib on the VC directories)

See a short demo video here

You will find few documents in the Repo:

· Readme.md explains how to build the tool and setup it on your machine

· Examples.md describes how to start with the tool

· FAQ: contains useful information about the tool and its design.

· Privacy document: contains all the privacy information like the data collected.

Available libraries and contributing to adding more

To see the list of available libraries, use vcpkg search

The current list (9/2016) is

image

This is just the beginning, and we’ll accept contributions and pull request to add lib port files in the catalog. See the example 2 in examples.md to create a new port file in the catalog.

The Visual studio and CMake integration

The Visual studio (VC2015) integration can be done in different ways: (See details of all this options in the examples.md on the GitHub repo).

Option A: VS Project (User-wide integration)

The recommended and most productive way to use Vcpkg is via user-wide integration, making the system available for all projects you build. The user-wide integration will require administrator access the first time it is used on a given machine. After the first use, administrator access is no longer required and the integration is on a per-user basis.

vcpkg integrate install

Option B: CMake (Toolchain File)

The best way to use installed libraries with CMake is via the toolchain file integration\sysroot.cmake. To use this file, you simply need to add it onto your CMake command line as -DCMAKE_TOOLCHAIN_FILE=D:\src\cpp-packages\integration\sysroot.cmake.

Option C: Other buildsystems

Libraries are installed into the installed subfolder, partitioned by architecture (e.g. x86-windows):

  • The header files are installed to vcpkg\installed\x86-windows\include
  • Release .lib files are installed to vcpkg\installed\x86-windows\lib
  • Release .dll files are installed to vcpkg\installed\x86-windows\bin
  • Debug .lib files are installed to vcpkg\installed\x86-windows\debug\lib
  • Debug .dll files are installed to vcpkg\installed\x86-windows\debug\bin
  • See your build system specific documentation for how to use prebuilt binaries.
    Option D: VS Project (NuGet package)

    We also provide VS project integration through a NuGet package. This will modify the project file, so we do not recommend this approach for open source projects. When you modify the project file this way, the paths are hard coded and specific to your environment, sharing this have no sense in an distributed environment.

    vcpkg integrate project

    Note: The generated NuGet package does not contain the actual libraries. It instead acts like a shortcut (or symlink) to the Vcpkg install and will “automatically” update with any changes (install/remove) to the libraries. You do not need to regenerate or update the NuGet package.

    This tool is for you, and we need your feedback suggestion. Create an Issue or a Pull Request on the GitHub repo to let us know what’s cool, what wrong and what we could add to this tool to better fit to your needs. Let us know which libraries you would love to have in the list…

    You can also contact us at vcpkg@microsoft.com

    The Vcpkg Team

Microsoft at CppCon 2016

$
0
0

The Microsoft Visual C++ team is at CppCon 2016 next week, September 18 – 23 in Bellevue, WA.

CppCon is the annual, week-long face-to-face gathering for the entire C++ community. The conference is organized by the C++ community for the community. It features sessions, lightning rounds, and hundreds of smart developers ready to chat C++.

We have a booth Tuesday and Wednesday with members of the team planning to be available for your questions: Gabriel Dos Reis, STL, Herb Sutter, Casey Carter, James McNellis, Gor Nishanov, Kenny Kerr and more.

Microsoft is also hosting a few talks:

This year (as with last year), talks will be videotaped and made available later in the week.

We created a one-page handout for attendees, so if you are unable to attend this year you can still see the latest news. It includes a survey open to everyone. If you opt-in, we may reach out to learn more about your experiences with C++.

As always, thanks for your continued feedback and suggestions.

See you there.

Visual C++ 2015 Migration Documentation Update

$
0
0

Upgrading to the latest C++ compiler and toolset is sometimes not so easy and can be time consuming. You are likely to encounter some compiler and linker errors and warnings in code that previously compiled cleanly. There are several possible sources for these errors, including improvements in the compiler, and changes in the C++ language, Standard Library, C runtime (CRT), and other libraries such as MFC and ATL.

We know by your feedback that having good documentation is a key part of this process. That’s why we have been updating the migration documentation to include lessons learned by working with our customers and migrating our own samples. We will continue to add to this documentation based on our learnings, and on your feedback! The Migration Guide can be found here .

We also know that samples are very useful. That is why we migrated old samples like Spy++, Scribble… (sure this names ring a bell for the older ones ;-)) to the latest compiler. They are now published on a GitHub repo . We created several folders to jump from different versions of earlier code (2008, 2010) to the latest (2015). You will also find some documents on the repo wiki to help you preparing a repro case, reporting an ICE compiler internal error, and so on.

We hope that this documentation upgrade, and these samples, are useful in your migration effort, and we want to hear from you! What do you need? What subjects need more information? You can also create an Issue on the GitHub repo to tell us what you need, or create a pull request to submit your code migration issue, so everyone can help you.

For a more in-depth help to migrate we still have space available in the Virtual DevLab. Here is the link to register:

Questions or comments about the upgrade process can also be sent to vcupgrade@microsoft.com.


Custom ASP.NET Core Middleware Example

$
0
0

One of the great things about ASP.NET Core is its extensibility. The behavior of an ASP.NET Core app’s HTTP request handling pipeline can be easily customized by specifying different middleware components. This allows developers to plug in request handlers like MVC middleware, static file providers, authentication, error pages, or even their own custom middleware. In this article, I will walk you through how to create custom middleware to handle requests with simple SOAP payloads.

A Disclaimer

Hopefully this article provides a useful demonstration of creating custom middleware for ASP.NET Core in a real-world scenario. Some users might also find the SOAP handling itself useful for processing requests from old clients that previously communicated with a basic WCF endpoint. Be aware, though, that this sample does not provide general WCF host support for ASP.NET Core. Among other things, it has no support for message security, WSDL generation, duplex channels, non-HTTP transports, etc. The recommended way of providing web services with ASP.NET Core is via RESTful web API solutions. The ASP.NET MVC framework provides a powerful and flexible model for routing and handling web requests with controllers and actions.

Getting Started

To start, create a .NET Core library (the project type is under web templates and is called Class Library (package)). Throughout this article I will be using the Preview 2 version of the .NET Core tools.    

Creating a new .NET Core library project

ASP.NET Core middleware uses the explicit dependencies principle, so all dependencies should be provided through dependency injection via arguments to the middleware’s constructor. The one dependency common to most middleware is a RequestDelegate object representing the next delegate in the HTTP request processing pipeline. If our middleware does not completely handle a request, the request’s context should be passed along to this next delegate. Later, we’ll specify more dependencies in our constructor but, for now, let’s add a basic constructor to our middleware class.

Add a dependency to Microsoft.AspNetCore.Http.Abstractions to your project.json (since that’s the contract containing RequestDelegate), give your class a descriptive name (I’m using SOAPEndpointMiddleware), and create a constructor for the middleware class like this:

Next, we need to handle incoming HTTP request contexts. For this, middleware is expected to have an Invoke method taking an HttpContext parameter. This method should take whatever actions are necessary based on the HttpContext being processed and then call the next middleware in the HTTP request processing pipeline (unless no further processing is needed). For the moment, add this trivial Invoke method:

To try out our middleware as we create it, we will need a test ASP.NET Core app. Add an ASP.NET Core web API project to your solution and set it as the startup project.

Creating a new web API project

ASP.NET Core middleware (custom or otherwise) can be added to an application’s pipeline with the IApplicationBuilder.UseMiddleware extension method. After adding a project reference to your middleware project ("CustomMiddleware": "1.0.0.0"), add the middleware to your test app’s pipeline in the Configure method of its Startup.cs file:

You may notice that the other middleware components (MVC, static files, etc.) all have custom extension methods to make adding them easy. Let’s add an extension method for our custom middleware, too. I added the following method in a new source file in the custom middleware library project (notice the Microsoft.AspNetCore.Builder namespace so that IApplicationBuilder users can easily call the method):

The call to register the middleware in the test app then simplifies to app.UseSOAPEndpoint() instead of app.UseMiddleware().

At this point, we have successfully created a basic piece of custom middleware and injected it into our test app’s HTTP request processing pipeline.

Launch your test app (using Kestrel so that you can easily see Console output) and navigate to the hosted site with your web browser. Notice that the custom middleware logs messages as requests are received!

Specifying a Service Type

Now that we have a simple custom middleware component working, let’s have it start actually processing SOAP requests! The middleware should listen for SOAP requests to come in to a particular endpoint (URL) and then dispatch the calls to the appropriate service API based on the SOAP action specified. For this to work, our custom middleware will need a few more pieces of information:

  1. The path it should listen on for requests
  2. The type of the service to invoke methods from
  3. The MessageEncoder used to encode the incoming SOAP payloads

These arguments will all need to be provided when an app registers our middleware as part of its processing pipeline, so let’s add them to the constructor. Note that the MessageEncoder class is in the System.ServiceModel.Primitives contract.

After updating the constructor, it should look like this:

The UseSOAPEndpoint extension method will also need to be updated (and can be made generic to capture the service type parameter):

Because MessageEncoder is an abstract class without any implementations publicly exposed, users of this library will have to either implement their own encoders or (more likely) extract an encoder from a WCF binding. To make that easier, let’s also add a UseSOAPEndpoint overload that takes a binding (and extracts the encoder on the user’s behalf):

Discovering Service Type Operations

Requests handled by our SOAP-handling middleware will be requests to invoke some operation on the specified service type. We can use reflection to find methods on the given service type which correspond to contract operations.

Let’s create a new type (ServiceDescription) to store this metadata. It should take the service type as an input to its constructor and then should walk the type with reflection to discover implemented contracts and operations according to the following heuristic:

  1. Contracts should be discovered by finding ServiceContractAttribute elements on interfaces that the type implements
    1. Contract name and namespace information is taken from the attribute
  2. Operations should be discovered by finding OperationContractAttribute elements on methods within the contract interfaces
    1. Operation name, properties, and action name are taken from the attribute; the method to invoke is the service type’s implementation of the interface method

Note that ServiceDescription, ContractDescription, and OperationDescription used here are not the types from the System.ServiceModel.Description namespace (so you should not need to depend on that namespace). Rather, they are simple new types used for the purpose of this sample code. If the names are confusing, feel free to change them.

The ServiceDescription type (or whatever you have named it) should end up looking something like this:

The ContractDescription type is similar:

The OperationDescription class looks much the same except that it also contains metadata about how the operation should be invoked:

Once these types exist, the middleware’s constructor can be updated to store a ServiceDescription created from the specified Type instead of storing the Type itself:

Note that this could all be simplified by just having a dictionary of action names and OperationDescription or MethodInfo dispatch methods. I’ve opted to have the whole service/contract/operation structure stored, though, because it will allow expanding the sample with more complex functionality (such as supporting message inspectors) in the future.

Invoking the Operations

At this point, you should have a custom middleware class that takes a service type as input and discovers available operations. Now it’s time to update the middleware’s Invoke method to actually call those operations.

The first thing to check in the Invoke method is whether or not the incoming request’s path equals the path our service is listening on. If not, then we need to pass the request along to other pipeline members.

If the request’s path does equal the expected path for our service endpoint, we need to read the message and compose a response (this code replaces the ‘todo’ in the previous snippet).

After that, we need to get the requested action by looking for a ‘SOAPAction’ header (which is how SOAP actions are usually communicated). Again, this code replaces the ‘todo’ from the previous snippet.

Knowing the requested action, we can build on the previous snippet by finding the correct OperationDescription to invoke. Replace the previous ‘todo’ with the following:

Now that we have a MethodInfo to invoke, we need to extract the arguments to pass to the operation from the request’s body. This can be done in a helper method with an XmlReader and DataContractSerializer.

This argument reading helper assumes the arguments are provided in order in the message body. This is true for messages coming from .NET WCF clients, but may not be true for all SOAP clients. If needed, this method could be replaced with a slightly more complex variant that allows for re-ordered arguments and fuzzier parameter name matching.

With the operation and arguments known, all that remains is to retrieve an instance of the service type to call the operation method on. This can be done with ASP.NET Core’s built-in dependency injection.

Change the middleware’s Invoke method signature to add an IServiceProvider parameter (IServiceProvider serviceProvider). Then, we can use the IServiceProver.GetService API to retrieve service types that the user has registered in the ConfigureServices method of their Startup.cs file.

All together, the call to invoke the operation (replacing the ‘todo’ back in our Invoke method) should look something like this:

Encoding the Response

Finally, with a response in hand, we can use the MessageEncoder specified by the user to send the object back to the caller in the HTTP response. Message.CreateMessage requires an implementation of BodyWriter to output the body of the message with correct element names. So, add a class like the one below that implements BodyWriter.

Then we can update the middleware’s Invoke method (replacing the final ‘todo’) to create a response message (if the operation isn’t one way) and write it to the HTTP context’s response.

And that’s it! You have written custom ASP.NET Core middleware for handling SOAP requests.

Testing it Out

Now that our custom middleware actually works with service types, the simple test app we created before will need to be updated. We’ll need a simple service type to call into. If you don’t have one on-hand to test with, you can use this sample:

The UseSOAPEndpoint call we added to the Configure method in our test host’s Startup.cs file will need updated to point to this new type: app.UseSOAPEndpoint("/CalculatorService.svc", new BasicHttpBinding());. Note that we’ve also created an HttpBinding (to get a message encoder from). To use BasicHttpBinding, we will need to add a reference to the System.ServiceModel.Http contract in the test app’s project.json file.

Also, since the instance of our service is created with dependency injection, the following line will need added to the ConfigureServices method in our host’s startup.cs file: services.AddSingleton();

If you have a WSDL for your test service, you can create a client from that using WCF tools. Otherwise, create a client directly using ClientBase.

Here is a simple client I created (as a .NET Core console application) to test the middleware and host (be sure to reference System.ServiceModel.Http and System.ServiceModel.Primitives in the project.json file):

Launch the test host and point a test client (like the one pasted above) at it to see ASP.NET Core handle a SOAP request with our custom middleware!

ASP.NET Core Handling SOAP Requests

Using a network monitoring tool like Wireshark or Fiddler, we can observe the requests and responses.

Request from sample:

Response from sample:

Conclusion

I hope that this article has been helpful in demonstrating a real-world case of custom middleware expanding ASP.NET Core’s request processing capabilities. By creating a constructor that took the middleware’s dependencies as parameters and creating an Invoke method with the logic of deserializing and dispatching SOAP requests, we were able to serve responses to a simple WCF client from ASP.NET Core! SOAP handling middleware is just one example of how custom middleware can be used. More details on middleware are available in the ASP.NET Core documentation.

References

CppCon 2016: Latest and greatest for C++ Developers

The week in .NET: On .NET with Steeltoe – C# Functional Extensions – Firewatch

$
0
0

To read last week’s post, see The week in .NET: .NET Core 1.0.1 – On .NET with Peachpie – Avalonia – Folk Tale.

On .NET

Last week, we had David Morhovich and Zach Brown on the show to talk about Steeltoe:

This week, we’ll speak with Sébastien Ros about Orchard 2, the new version of the .NET CMS that can run on .NET Core. The show begins at 10AM Pacific Time on Channel 9. We’ll take questions on Gitter, on the dotnet/home channel. Please use the #onnet tag. It’s OK to start sending us questions in advance if you can’t do it live during the show.

Package of the week: C# Functional Extensions

C# functional extensions is a project that adds common functional patterns such as tuples, option types, monads, easier Lambda declaration: var add = fun( (int x, int y) => x + y );, or even pattern matching. It also implements “Erlang-like” concurrency, which is based on the concept of agents communicating through messages.

Game of the Week: Firewatch

Firewatch is a visually beautiful, story driven adventure game. The story takes place in 1989, where you witness a mystery that pulls you out of the sanctity of your lookout post and into the wilderness to investigate. Explore the Wyoming wilderness as Henry, a man who has retreated from his messy life to work as a fire lookout. Your only human interaction while you investigate is your supervisor, Delilah, who is available at any time over a handheld radio.

Firewatch

Firewatch was created by Campo Santo using Unity and C#. It is available on PlayStation 4, Windows, Mac and Linux (via Steam and Good Old Games) and will release for the Xbox One on September 21, 2016.

User group meeting of the week: PerfView and Warden in Wrocław, Poland

Tonight at 6:30 in Wrocław, Poland, the Wrocław .NET User Group has a meeting where Michal Malecki and Piotr Gankiewicz will talk about PerfView and Warden.

.NET

ASP.NET

F#

Check out F# Weekly for more great content from the F# community.

Xamarin

Azure

Games

And this is it for this week!

Contribute to the week in .NET

As always, this weekly post couldn’t exist without community contributions, and I’d like to thank all those who sent links and tips. The F# section is provided by Phillip Carter, the gaming section by Stacey Haffner, and the Xamarin section by Dan Rigby.

You can participate too. Did you write a great blog post, or just read one? Do you want everyone to know about an amazing new contribution or a useful library? Did you make or play a great game built on .NET?
We’d love to hear from you, and feature your contributions on future posts:

This week’s post (and future posts) also contains news I first read on The ASP.NET Community Standup, on Weekly Xamarin, on F# weekly, on ASP.NET Weekly, and on Chris Alcock’s The Morning Brew.

Recap: Bringing your UWP apps to Xbox – App Dev on Xbox Twitter Chat

$
0
0

Whether you bring your existing Universal Windows Platform (UWP) app to Xbox or create an engaging new concept, Xbox provides a great new place for your app to shine: The living room.

We recently hosted a live video event and Twitter chat explaining exactly how developers can bring their UWP apps to Xbox, answering your questions live. We touched on topics such as protection for your Xbox One while in developer mode, frame rate limits and much more.

You can see videos from the live sessions on the App Dev on Xbox page, and check out the below highlights from our Twitter chat!

Looking for more information? Check out the individual App Dev on Xbox sessions here or send us your questions on Twitter.

Get started – download Visual Studio.

The Windows team would love to hear your feedback.  Please keep the feedback coming using our Windows Developer UserVoice site. If you have a direct bug, please use the Windows Feedback tool built directly into Windows 10.

Using physical boards alongside your Team Services/TFS Kanban and Taskboards – Agile Cards by Spartez

$
0
0

Agile transformation and ongoing process maintenance are often not as easy as they would seem. Despite the very open nature of Agile Manifesto it is important to maintain consistency between selected methods and the tools. This may become increasingly difficult with the growth of organisations, complexity of projects and internal team dynamics.

Spartez kitchen on a random day.

One of Microsoft partners, a company called Spartez, offers a unique solution to Visual Studio Team Services and Team Foundation Server (TFS) users, which might be helpful in combining the benefits of using modern digital Application Lifecycle Management (ALM) solutions with more traditional yet still very effective approaches. With Agile Cards, you can easily print customised work items cards from Team Services or TFS for use on your physical boards. It is also possible to synchronise the physical boards back with Team Services and TFS with just one mobile device photo of the whole board.

Spartez, the company behind Agile Cards, has recently started a campaign to collect and share pro tips, best practices and suggestions on how to use printed work item cards. The first results are already out.

Cool swag can also be won, so don’t wait and share your story.

 

Spartez will be showcasing their product during upcoming Microsoft Ignite 2016 in Atlanta. You will find them at booth #777.

Viewing all 10804 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>