Skip to content
This repository was archived by the owner on Aug 30, 2023. It is now read-only.

Windows SDK dependency as NuGet packages#109

Merged
michael-hawker merged 13 commits intomasterfrom
winSDKContracts
Apr 20, 2019
Merged

Windows SDK dependency as NuGet packages#109
michael-hawker merged 13 commits intomasterfrom
winSDKContracts

Conversation

@azchohfi
Copy link
Contributor

Issue: #66

PR Type

What kind of change does this PR introduce?

  • Bugfix

What is the current behavior?

Very hard to reference WinMDs.

What is the new behavior?

No work needed to reference WinMDs, but to reference the NuGet Package.

PR Checklist

Please check if your PR fulfills the following requirements:

  • Tested code with current supported SDKs
  • Pull Request has been submitted to the documentation repository instructions. Link:
  • Sample in sample app has been added / updated (for bug fixes / features)
  • Tests for the changes have been added (for bug fixes / features) (if applicable)
  • Header has been added to all new source files (run build/UpdateHeaders.bat)
  • Contains NO breaking changes

@azchohfi
Copy link
Contributor Author

We could probably remove build/Install-WindowsSdkISO.ps1 and build/Install-WindowsSdk.ps1

Copy link
Member

@michael-hawker michael-hawker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quick question, otherwise looks good. Did you want me to also validate on another machine? As I realized my laptop isn't on insider.

[STAThread]
public static void Main()
{
var startupKind = StartupKind.Normal;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was this the part you said wasn't supported anymore? Should we have a comment here calling that this must be set this way and throw an exception in the else case below?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should remove the else clause. It doesn't work. There will be a future PR with a more complex scenario covered.

@azchohfi
Copy link
Contributor Author

Let's validate it all on Monday.

@michael-hawker
Copy link
Member

Nugets from PR worked like a charm on my Insider machine. No large hassle with your instructions, just had one extra thing to do. So, it's now:

  1. Install the following
  • 18226 or later OS and SDK
  • .NET Core preview4
  • Suggested to install VS 2019 Preview
  1. File New WPF .NET Core project
  2. Add Microsoft.Toolkit.Wpf.UI.XamlHost package reference
  3. In project, Add -> New Item -> Application Manifest File
  4. Add following to compatibility/application section:
      <maxversiontested Id="10.0.18362.0"/>
      <supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />
  1. Add following to application/windowSettings section:
      <dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true/PM</dpiAware>
      <dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">PerMonitorV2, PerMonitor</dpiAwareness>
  1. Create a Program.cs file with:
namespace WpfCoreTestApp
{
    public static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        public static void Main()
        {
            using (var xamlApp = new Microsoft.Toolkit.Win32.UI.XamlHost.XamlApplication())
            {
                var appOwnedWindowsXamlManager = xamlApp.WindowsXamlManager;

                var app = new App();
                app.InitializeComponent();
                app.Run();
            }
        }
    }
}
  1. Edit the .csproj file and add the following to a PropertyGroup:
    <ApplicationManifest>app1.manifest</ApplicationManifest>
    <StartupObject>WpfCoreTestApp.Program</StartupObject>
  1. Voila! XamlHost in your XAML:
<xamlhost:WindowsXamlHost InitialTypeName="Windows.UI.Xaml.Controls.TextBox" />

image

Copy link
Member

@michael-hawker michael-hawker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing!

@michael-hawker michael-hawker merged commit dea259f into master Apr 20, 2019
@delete-merged-branch delete-merged-branch bot deleted the winSDKContracts branch April 20, 2019 23:13
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants