-
Notifications
You must be signed in to change notification settings - Fork 330
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
PublishSingleFile with WindowsAppSDKSelfContained produces non runnable application #2597
Comments
Was able to get an application event trace containing:
The code for that method is here: WindowsAppSDK/UndockedRegFreeWinRT-AutoInitializer.cs at main · microsoft/WindowsAppSDK (github.com)
My relatively uninformed hunch is that the |
I've created an internal task to track this: https://task.ms/39946393 and assigning to @DrusTheAxe |
Do you have Microsoft.WindowsAppRuntime.dll as a file along with your "single file"? Does your project define Do you set the property PublishSingleFile has variation of behavior. Depending how you use it you may or may not run into problems
Which would be problematic as [DllImport(Microsoft.WindowsAppRuntime.dll,...)] == LoadLibrary(Microsoft.WindowsAppRuntime.dll) but .NET 5's not quite that simple as noted further down
More info at that link at the end
|
I set |
As of 1.1.2 an application published like this still crashes on startup:
|
Same issue for 1.1.5 <PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows10.0.19041.0</TargetFramework>
<TargetPlatformMinVersion>10.0.18362.0</TargetPlatformMinVersion>
<RootNamespace>TestApp</RootNamespace>
<ApplicationManifest>app.manifest</ApplicationManifest>
<Platforms>x64</Platforms>
<RuntimeIdentifiers>win10-x64</RuntimeIdentifiers>
<PublishProfile>win10-$(Platform).pubxml</PublishProfile>
<UseWinUI>true</UseWinUI>
<IncludeNativeLibrariesForSelfExtract>true</IncludeNativeLibrariesForSelfExtract>
<WindowsPackageType>None</WindowsPackageType>
<SupportedOSPlatformVersion>10.0.19041.0</SupportedOSPlatformVersion>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
<WindowsAppSDKSelfContained>true</WindowsAppSDKSelfContained>
</PropertyGroup> <PackageReference Include="Microsoft.WindowsAppSDK" Version="1.1.5" />
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.22621.755" /> Exception in Windows Event Viewer from .NET Runtime
If I remove Windows 11 (OS Build 22000.1098) |
Same problem here, same configs as above |
Not being supported is one thing, but then it should error out when trying to compile the app, listing the incompatible options. Producing a non runnable application is the worst that can happen. |
I've just removed Self Contained Windows App SDK and now I package the WindowsAppRuntimeInstall.exe separately with my inno installer that I send to the clients. I run the WindowsAppRuntimeInstall.exe on the install setup using the --quiet and --force parameters. Works well for me. Now I don't have to worry about trying to add it to single file on publish. |
Be carefull if your app has to be run under another user, because this works with WindowsAppSDKSelfContained, but breaks when using the installed runtime. |
I have the same issue. 🐈⬛ |
Same issue :( |
Is this supposed to work with the latest version of the SDK - I just tried with a blank project and it's the same as the issue reported |
Any updates on the topic? |
@DrusTheAxe This appears to be a URFW issue, am hitting the same problem here. Particularly, it doesn't appear URFW understands that in single-file scenarios, the single file host (my.exe) is in one directory and everything else is extracted into another directory. (.NET only appears to wire up enough hooks for DllImport scenarios to work and leaves the rest to the developer.) This particular URFW line has me curious: I was going to fix up the search directories myself but it's not clear how this is supposed to this piece of code is meant to behave; I'm seeing URFW pass a lpFileName of
|
Same issue :( @DrusTheAxe - can you please recommend any temporary work-around to unblock this scenario? Perhaps a custom build target to copy dependencies or something? Thanks! |
URFW expects DLLs+EXE are colocated. It's not specialized for DotNet (or other runtimes). I can think of several options but none particularly good. Need to investigate a little further and discuss with some folks. I suspect we can do something. @Scottj1s @bpulliam let's talk offline.
Why? Is it the That's standard fare how COM loads DLLs (even since Windows NT 4.0).
Hmmm. That should be an absolute filename (to avoid ambiguities). Thanks for pointing this out! But even if that's changed to an absolute filename that won't fix your single-file .NET scenario, right? |
Agreed.
I think ensuring URFW attempts to find its libraries via search path traversal would allow .NET developers to add the extracted directory to the search path. (Perhaps a stretch goal could be to do that for developers via the .NET bootstrap.) We should also consider adding a note somewhere that dissuades folks from trying single-file publishing as it's known to be completely unsupported/incompatible. Would save some folks a few hours/days of digging! |
What search path? URFW is native code. One question is what .NET needs, then if/how to teach URFW where to look in ways that also work for .NET (w/o negatively impacting others, and w/o 1off solutions for every language and framework). And of course there's the key question: how's this work for OS reg-free WinRT? Is that any different? Of course if the OS RegFree WinRT is no help we have the merit of consistency, but also potential opportunity to do something beyond the OS. Following up but this will likely involve key experts across a few teams and some vacations and other scheduling fine print so please be patient on this topic.
Perhaps. I need to talk to some folks more deeply immersed in that.
Is it? I've heard it mentioned but I haven't kept track of its current status. Something else to check with folks. |
Some additional dev notes/thoughts as I poke around more: It looks like the issue is ultimately a result of OS SxS not performing a traditional LoadLibrary-like DLL search for the components in the app's fusion manifest. That is, SxS sees We wouldn't normally need the manifest but Windows App SDK does due to some component naming decisions made in the past. (Perhaps activation factory stubs following the traditional pattern could help here?) Enterprising developers wanting to bounce through a loader, to externalize the fusion manifest at runtime, may discover URFW doesn't support loose manifests. But perhaps putting a new activation context on the stack with an auto-generated manifest could work here? (Might be tricky with threading and WASDK/WinUI may have some assumptions built around the active context...) Anyway, thanks @DrusTheAxe for looking into this. We will all wait (impatiently) for you to return with more news! |
I have the problem that a build exe works fine, but I can't run it from visual studio until my custom dll is in system32! Next to the exe is not enough.. |
It's been 6 months since the issue was opened. Any updates on it? |
Thanks for your patience folks. Support is in the works! |
PublishSingleFile will be supported in Windows App SDK 1.5 |
Closing as completed with 1.5.240205001-preview1. If we've missed any edge cases, please enter new issues. |
Describe the bug
If
PublishSingleFile
andWindowsAppSDKSelfContained
are set to true while publishing, an exe is produced which crashes on startup.Steps to reproduce the bug
Expected behavior
No response
Screenshots
No response
NuGet package version
No response
Packaging type
Unpackaged
Windows version
Windows 10 version 21H2 (19044, November 2021 Update)
IDE
Visual Studio 2022
Additional context
NuGet package version is 1.1.0
The text was updated successfully, but these errors were encountered: