WindowsAppSDK icon indicating copy to clipboard operation
WindowsAppSDK copied to clipboard

Creating a singleExe from UnPackaged app breaks the latest WindowsApp SDK

Open sudharsan-narayanan opened this issue 9 months ago • 7 comments

Describe the bug

Currently using the latest SDK 1.5.240428000, it fails to generate the resource.pri when creating the SingleExe. I think, it is breaking the latest SDK behavior.

If we use the SDK version 1.4.240211001, It creates the SingleExe properly with all dependency files.

It's replicate in the CustomControl library project also.

Steps to reproduce the bug

CustomControl.zip SimpleApp.zip

  1. Open the SimpleApp project.
  2. Tools->Commands->Developer Powershell. Use below command line for creating the SingleExe. dotnet publish SimpleApp.sln -c Release -p:Platform=x64 -p:PublishSingleFile=true --self-contained true -p:WindowsAppSDKSelfContained=true
  3. Now, open the Bin folder and check the exe.

Note: Exe will not launch in launch SDK.

Expected behavior

It should launch the exe properly as like windows SDK (1.4.240211001).

Screenshots

In Version 1.4.240211001

image

In Version 1.5.240428000

image

NuGet package version

Windows App SDK 1.5.3: 1.5.240428000

Packaging type

Unpackaged

Windows version

Windows 11 version 22H2 (22621, 2022 Update)

IDE

Visual Studio 2022

Additional context

No response

sudharsan-narayanan avatar May 06 '24 12:05 sudharsan-narayanan

You can Exclude Files using: <ExcludeFromSingleFile>true</ExcludeFromSingleFile>

I did not test new version, Its mechanism may have changed Use IncludeNativeLibrariesForSelfExtract or IncludeAllContentForSelfExtract and see if it makes a difference

<IncludeNativeLibrariesForSelfExtract>false</IncludeNativeLibrariesForSelfExtract>

dotnet publish SimpleApp.sln -c Release -p:Platform=x64 -p:PublishSingleFile=true --self-contained true -p:WindowsAppSDKSelfContained=true p:IncludeNativeLibrariesForSelfExtract=false

ghost1372 avatar May 06 '24 12:05 ghost1372

The resources.pri file (and all other native libraries) are actually embedded into the .exe file now and extracted to a temporary directory when you start the application. I checked your sample app to see why it does not work:

-You need to set WindowsAppSdkSelfContained to true (see warning during build). -The resource APIs in the Windows namespace are apparently not compatible with this scheme, thus you need to use the ones from the Microsoft namespace.

lhak avatar May 07 '24 10:05 lhak

Do the suggested actions fix the problem?

bpulliam avatar May 08 '24 14:05 bpulliam

Do the suggested actions fix the problem?

Thanks for answering,

No @bpulliam, Still exe not launched when I use above suggestion given by @lhak and @ghost1372

I have attached my project application and the command which I use to generate the single exe. Please go through and could you please check my problem and provide a solution for this?

Note: I feel it is broken in latest update SDK.

sudharsan-narayanan avatar May 08 '24 15:05 sudharsan-narayanan

@sudharsan-narayanan i tested your project and i can say that issue is from your library! you can see there is some error with your library Screenshot 2024-05-08 193229

i created a new project with a new class library and i can publish app as single file and exe can be run without any issues.

ghost1372 avatar May 08 '24 16:05 ghost1372

@sudharsan-narayanan i tested your project and i can say that issue is from your library! you can see there is some error with your library Screenshot 2024-05-08 193229

i created a new project with a new class library and i can publish app as single file and exe can be run without any issues.

We have tried the same with our provided sample, we can't be able to reproduce the error from our end. Can you please provide the sample which you created?

Myself also attached the video in this comment, which I have tried in my machine.

https://github.com/microsoft/WindowsAppSDK/assets/93642597/bedcfbf1-6715-49c0-9e3c-e608351be8e2

sudharsan-narayanan avatar Jun 14 '24 13:06 sudharsan-narayanan

Hi Team, Any update on this?

SubashiniMahendran avatar Jul 03 '24 04:07 SubashiniMahendran