microsoft / WindowsAppSDK

The Windows App SDK empowers all Windows desktop apps with modern Windows UI, APIs, and platform features, including back-compat support, shipped via NuGet.
https://docs.microsoft.com/windows/apps/windows-app-sdk/
MIT License
3.85k stars 323 forks source link

Resource files not copied to publish directory once app upgraded to Windows App SDK 1.5 #4603

Open jabberscript opened 3 months ago

jabberscript commented 3 months ago

Describe the bug

When publishing an unpackaged app configured to publish as a single file using the latest stable version of the 1.5 App SDK, the resource files are not copied to the publish directory as they were when using Windows App SDK v1.4. This includes any assets set to copy always, the resources.pri and bootstrap dll.

This causes the published app to be unable to launch when using v.1.5.

I notice that there is a warning generated during the build and publish for a 1.5 app. Is there a new way that we're supposed to achieve this? I would really prefer to publish my app as a single exe, if possible.

PublishSingleFile is recommended only for Windows App SDK Self-Contained apps:
<PropertyGroup>
<WindowsAppSDKSelfContained>true</WindowsAppSDKSelfContained>
</PropertyGroup> 

Steps to reproduce the bug

PublishTest.zip

The attached test app recreates the issue. I used this command (cribbed from our devops build agent) to publish the projects, substituting in the path to each project file:

"C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\msbuild.exe" "<PATH TO .csproj>" /nologo /nr:false /t:Rebuild;Publish /p:DebugSymbols=false /p:DebugType=None /p:DeleteExistingFiles=True /p:RuntimeIdentifier=win-x64 /p:PublishSingleFile=True /p:SelfContained=False /p:NuGetInteractive=True /p:platform="x64" /p:configuration="Release" /p:VisualStudioVersion="17.0"

It will likely be necessary to restore the nuget packages before running this command.

Expected behavior

Expect that the resource files should be copied to the publish directory so that the app is able to run.

Screenshots

1.4 output:

1 4

1.5 output:

1 5

NuGet package version

Windows App SDK 1.5.5: 1.5.240627000

Packaging type

Unpackaged

Windows version

Windows 10 version 21H2 (19044, November 2021 Update)

IDE

Visual Studio 2022

Additional context

No response

WyrmUK commented 3 months ago

Could this be related to #4390 ?

jabberscript commented 3 months ago

Looking at it, it could very well be. Thanks! I'll go through the suggested steps and see if it helps in our case.

jabberscript commented 3 months ago

OK, so setting <WindowsAppSDKSelfContained>true</WindowsAppSDKSelfContained>on the 1.5 test project and publishing as /p:SelfContained=True makes it so that the published app is able to be launched.

Is the plan, then, that it will only be possible in future to publish as a single file if the app is self contained? Fine, if so. I just need to make a decision which way to go.

Balkoth commented 3 months ago

I believe it was <EnableMsixTooling>true</EnableMsixTooling> that messes with the copying of the resource file.