forked from microsoft/WinUI-Gallery
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WinUI gallery unpackaged mode working + single project config for bot…
…h packaged and unpackaged (microsoft#1329) Unpackaged mode no longer crashes on launch The WinUI gallery unpacakged mode was broken and crashed on launch - no matter whether building from msbuild cmd line or VS. It was happening because at some places in the code resource was getting accessed through URI which only makes sense for packaged app and not unpackaged. To remedy this, other parts of the code had separate code under UNPACKAGED which would build a non-URI path for unpackaged app config. This UNPACKAGED constant was not defined anywhere and as a result, that alternative code was not getting accessed. Some places had missing alternative code entirely. This PR removes dependence on UNPACKAGED compile time variable entirely. This PR side steps compile time variable for a easier to maintain runtime function which uses Appmodel/GetCurrentPackageId() system api to determine whether an app is running in packaged mode or unpackaged mode during runtime. Single project configuration As a need arose for cleaning up the project files for unpackaged winui gallery to work, I used this opportunity to build upon @Scottj1s 's work in unpkg-module branch and get rid of WAP configuration, have single project configuration for building any flavor of WinUI gallery. As a result, using launch configurations, you can build WinUI gallery in either packaged or unpackaged mode. I have introduced more solution configurations to aid in that. image If you want to build a Packaged winui gallery, select Packaged launch configuration and choose between Debug or Release solution configs. If you want to build a Unpackaged winui gallery, select Unpackaged launch configuration and choose between Debug-Unpackaged or Release-Unpackaged solution configs. A mix and match config will result in error because that's how Visual Studio works.
- Loading branch information
Showing
18 changed files
with
496 additions
and
406 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
//********************************************************* | ||
// | ||
// Copyright (c) Microsoft. All rights reserved. | ||
// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF | ||
// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY | ||
// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR | ||
// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. | ||
// | ||
//********************************************************* | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Runtime.InteropServices; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace AppUIBasics.Helper | ||
{ | ||
internal class NativeHelper | ||
{ | ||
public const int ERROR_SUCCESS = 0; | ||
public const int ERROR_INSUFFICIENT_BUFFER = 122; | ||
public const int APPMODEL_ERROR_NO_PACKAGE = 15700; | ||
|
||
[DllImport("api-ms-win-appmodel-runtime-l1-1-1", SetLastError = true)] | ||
[return: MarshalAs(UnmanagedType.U4)] | ||
internal static extern uint GetCurrentPackageId(ref int pBufferLength, out byte pBuffer); | ||
|
||
public static bool IsAppPackaged | ||
{ | ||
get | ||
{ | ||
int bufferSize = 0; | ||
byte byteBuffer = 0; | ||
uint lastError = NativeHelper.GetCurrentPackageId(ref bufferSize, out byteBuffer); | ||
bool isPackaged = true; | ||
|
||
if (lastError == NativeHelper.APPMODEL_ERROR_NO_PACKAGE) | ||
{ | ||
isPackaged = false; | ||
} | ||
return isPackaged; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.