Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Btueffers dynamic dependency bootstrap initialize #187

Merged
merged 16 commits into from
Apr 22, 2022

Conversation

btueffers
Copy link
Collaborator

@btueffers btueffers commented Apr 8, 2022

Description

Updating to use new Bootstrap Initialize API

Target Release

1.1 Preview 2 timeline

Checklist

  • Samples build and run using the Visual Studio versions listed in the Windows development docs.
  • Samples build and run on all supported platforms (x64, x86, ARM64) and configurations (Debug, Release).
  • Samples set the minimum supported OS version to Windows 10 version 1809.
  • Samples build clean with no warnings or errors.
  • [For new samples]: Samples have completed the sample guidelines checklist and follow standardization/naming guidelines.
  • I have commented on my PR /azp run to have the CI build run on my branch. This must be done right before merging to ensure the build is up to date and accurate.

@@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net5.0-windows10.0.19041.0</TargetFramework>
<TargetFramework>net6.0-windows10.0.19041.0</TargetFramework>
Copy link
Member

Choose a reason for hiding this comment

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

Are samples supposed to use .NET 5 or 6?

Is there a doc of policies and guidelines what samples are supposed to do? E.g. what version of .NET they should use?

// Initialize Windows App SDK for unpackaged apps.
int result;

Bootstrap.TryInitialize(majorMinorVersion, versionTag, out result);
Copy link
Member

Choose a reason for hiding this comment

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

Replace lines 24-28 with

int result = 0;
if (!Bootstrap.TryInitialize(majorMinorVersion, versionTag, minVersion, out result))
{
    Application.Run...

same applies to all

@@ -3,6 +3,7 @@

using System;
using System.Windows.Forms;
using Microsoft.Windows.ApplicationModel.DynamicDependency;

namespace CsWinFormsActivation
{
Copy link
Member

Choose a reason for hiding this comment

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

Replace lines 13-14 with

static var majorMinorVersion = global::Microsoft.WindowsAppSDK.Release.MajorMinor;
static var versionTag = global::Microsoft.WindowsAppSDK.Release.VersionTag;
static var minVersion = new global::Microsoft.Windows.ApplicationModel.DynamicDependency.PackageVersion(Microsoft.WindowsAppSDK.Runtime.Version.UInt64);

same applies to all

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Just to confirm @DrusTheAxe, is replacing the types with var intentional in your recommendation?

Copy link
Member

Choose a reason for hiding this comment

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

Yes. It could go either way for majorMinorVersion and versionTag but general rule is objects are better as var when the right side of the = is the type e.g.

Widget x = new Widget();

is better as

var x = new Widget();

since it's unambiguous to the reader what the type of x is.

For majorMinorVersion and versionTag they're constants so for consistency var seemed better, though one could make a case for uint and string.

@@ -3,6 +3,7 @@

using System;
using System.Windows.Forms;
using Microsoft.Windows.ApplicationModel.DynamicDependency;
Copy link
Member

Choose a reason for hiding this comment

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

using global::Microsoft...

to avoid ambiguity if implicitUsings are enabled

@angelazhangmsft
Copy link
Contributor

angelazhangmsft commented Apr 8, 2022

@DrusTheAxe should we use <WindowsPackageType>None</WindowsPackageType> in the samples instead of calling the Bootstrap API? Is Bootstrap initialize/shutdown still required if you use that project property?

As documented here: https://docs.microsoft.com/en-us/windows/apps/winui/winui3/create-your-first-winui3-app

@btueffers
Copy link
Collaborator Author

btueffers commented Apr 9, 2022

/azp run SamplesCI-AppLifecycle

@azure-pipelines
Copy link

You have several pipelines (over 10) configured to build pull requests in this repository. Specify which pipelines you would like to run by using /azp run [pipelines] command. You can specify multiple pipelines using a comma separated list.

@azure-pipelines
Copy link

Azure Pipelines could not run because the pipeline triggers exclude this branch/path.

@kythant
Copy link
Contributor

kythant commented Apr 9, 2022

/azp run SamplesCI-AppLifecycle

@azure-pipelines
Copy link

Azure Pipelines could not run because the pipeline triggers exclude this branch/path.

@kythant
Copy link
Contributor

kythant commented Apr 9, 2022

/azp run SamplesCI-AppLifecycle

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@btueffers
Copy link
Collaborator Author

/azp run SamplesCI-AppLifecycle

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

int result = MddBootstrap.Initialize(majorMinorVersion, versionTag);
if (result == 0)
int result = 0;
if (!Bootstrap.TryInitialize(majorMinorVersion, versionTag, minVersion, out result))
Copy link
Member

Choose a reason for hiding this comment

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

NIT: Can remove versionTag + minVersion and just use the overloaded API to get the default. Not like the actual values are listed here anyway (just symbolic names)

@@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0-windows10.0.19041.0</TargetFramework>
<TargetFramework>net6.0-windows10.0.19041.0</TargetFramework>
Copy link
Member

Choose a reason for hiding this comment

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

We're using .net6 for all samples?
We're using VS2022?

WinAppSDK 1.1 still supports .NET5? Still supports VS2019?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

There's a PR out to change it for the C# samples template, but it's not all samples at this point. I was changing a number of C# samples all at once though so I decided to go ahead and tack on the .NET version as well.

@@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net5.0-windows10.0.19041.0</TargetFramework>
<TargetFramework>net6.0-windows10.0.19041.0</TargetFramework>
Copy link
Member

Choose a reason for hiding this comment

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

19041 == 20H1

Do all samples target that? RS5+19H2 are supported but not a target for samples?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The C# template still targets 19041 so if not all samples then most of them would still be targeting that. We can update it in the template as well though in the same PR that the .NET version is being update in if we want to do that.

@btueffers
Copy link
Collaborator Author

/azp run SamplesCI-AppLifecycle

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

2 similar comments
@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@btueffers btueffers marked this pull request as ready for review April 22, 2022 16:30
@btueffers btueffers merged commit 3c59da7 into main Apr 22, 2022
@btueffers btueffers deleted the btueffers-DynamicDependency-BootstrapInitialize branch April 22, 2022 20:32
beervoley pushed a commit to paulcam206/WindowsAppSDK-Samples that referenced this pull request Dec 8, 2022
* Removing MddBootstrap.cs and use the new Bootstrap.Initialize API

* Readding some removed code from program.cs

* AppLifecycle Instancing CSConsole unpackaged

* AppLifecycle StateNotifications CsConsole Unpackaged State

* App Lifecycle Instancing CsWpf unpackaged

* App Lifecycle Activation Cs Wpf unpackaged

* App Lifecycle StateNotifications Cs WinForms Unpackaged

* App Lifecycle Activation Cs console unpackaged

* App Lifecycle StateNotifications Cs Wpf unpackaged

* App Lifecycle Instancing Cs WinForms unpackaged

* implementing some of the PR feedback

* updating version variables and if statements

* Fixed AppLifecycle CsWpfInstancing

* Corrected variable declarations and logic
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants